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 /src/or/networkstatus.c | |
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
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 20 |
1 files changed, 18 insertions, 2 deletions
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; |