diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-04-04 21:18:56 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-04-04 21:18:56 +0000 |
commit | 85db675911d1b4bbba755266ebaa33404c40e5de (patch) | |
tree | f1f7f28f986e8e3afa8f7e709c6ccf7e045813f8 | |
parent | 4c04b7f4f67ef1c31f6368167ad27930e983947a (diff) | |
download | tor-85db675911d1b4bbba755266ebaa33404c40e5de.tar.gz tor-85db675911d1b4bbba755266ebaa33404c40e5de.zip |
r19202@catbus: nickm | 2008-04-04 17:18:47 -0400
Make last_served_at optional; make last_listed_as_valid_until take account (partially) of v2 statuses.
svn:r14299
-rw-r--r-- | src/or/dirserv.c | 4 | ||||
-rw-r--r-- | src/or/networkstatus.c | 20 | ||||
-rw-r--r-- | src/or/or.h | 6 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index aa4d8b717e..63bc2b0e28 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2939,7 +2939,9 @@ connection_dirserv_finish_spooling(dir_connection_t *conn) static int connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn) { +#ifdef TRACK_SERVED_TIME time_t now = time(NULL); +#endif int by_fp = (conn->dir_spool_src == DIR_SPOOL_SERVER_BY_FP || conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP); int extra = (conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP || @@ -2967,7 +2969,9 @@ connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn) * unknown bridge descriptor has shown up between then and now. */ continue; } +#ifdef TRACK_SERVED_TIME sd->last_served_at = now; +#endif body = signed_descriptor_get_body(sd); if (conn->zlib_state) { int last = ! smartlist_len(conn->fingerprint_stack); diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 0cc1b210a3..4ed4993b51 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -697,11 +697,24 @@ router_set_networkstatus_v2(const char *s, time_t arrived_at, if (!found) smartlist_add(networkstatus_v2_list, ns); - SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs, +/*XXXX021 magic. */ +/*DOCDOC */ +#define V2_NETWORKSTATUS_LIFETIME (3*60*60) + + { + time_t live_until = ns->published_on + V2_NETWORKSTATUS_LIFETIME; + SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs, { - if (!router_get_by_descriptor_digest(rs->descriptor_digest)) + signed_descriptor_t *sd = + router_get_by_descriptor_digest(rs->descriptor_digest); + if (sd) { + if (sd->last_listed_as_valid_until < live_until) + sd->last_listed_as_valid_until = live_until; + } else { rs->need_to_mirror = 1; + } }); + } log_info(LD_DIR, "Setting networkstatus %s %s (published %s)", source == NS_FROM_CACHE?"cached from": @@ -1286,6 +1299,7 @@ notify_control_networkstatus_changed(const networkstatus_t *old_c, if (old_remain) rs_old = smartlist_get(old_c->routerstatus_list, idx); + /* XXXX021 candidate for a foreach_matched macro. */ SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new, { if (!old_remain) { @@ -1323,6 +1337,7 @@ networkstatus_copy_old_consensus_info(networkstatus_t *new_c, return; rs_old = smartlist_get(old_c->routerstatus_list, idx); + /* XXXX021 candidate for a FOREACH_MATCHED macro. */ SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new, { int r; @@ -1709,6 +1724,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers, idx = 0; rs = smartlist_get(ns->routerstatus_list, idx); + /* Candidate for a FOREACH_MATCHED macro.XXX021 */ SMARTLIST_FOREACH(routers, routerinfo_t *, router, { const char *digest = router->cache_info.identity_digest; diff --git a/src/or/or.h b/src/or/or.h index e4766ba145..71397597e1 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1219,10 +1219,14 @@ typedef struct signed_descriptor_t { * routerlist->old_routers? -1 for none. */ int routerlist_index; /** The valid-until time of the most recent consensus that listed this - * descriptor. 0 for "never listed in a consensus, so far as we know." */ + * descriptor, or a bit after the publication time of the most recent v2 + * networkstatus that listed it. 0 for "never listed in a consensus or + * status, so far as we know." */ time_t last_listed_as_valid_until; +#ifdef TRACK_SERVED_TIME /** DOCDOC */ time_t last_served_at; /*XXXX021 remove if not useful. */ +#endif /* If true, we do not ever try to save this object in the cache. */ unsigned int do_not_cache : 1; /* If true, this item is meant to represent an extrainfo. */ |