diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-09-20 14:18:17 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-27 18:04:44 -0400 |
commit | e34d0d3365f5263d2888d63a4d58dc479f191565 (patch) | |
tree | 578ef926e5cf0aacb8b9dac2645c3858e52ae9b1 /src | |
parent | 9f5b752e4f8d9252f0e3243f5101a98d3bc8de83 (diff) | |
download | tor-e34d0d3365f5263d2888d63a4d58dc479f191565.tar.gz tor-e34d0d3365f5263d2888d63a4d58dc479f191565.zip |
When updating routerdesc downloads, look specifically at the ns consensus
This will be needed when "get_live_consensus" potentially returns a
microdesc consensus.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/networkstatus.c | 16 | ||||
-rw-r--r-- | src/or/networkstatus.h | 3 | ||||
-rw-r--r-- | src/or/routerlist.c | 9 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 8b2a102490..4ccd1aed4d 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1210,6 +1210,7 @@ update_v2_networkstatus_cache_downloads(time_t now) } } +/** DOCDOC */ static int we_want_to_fetch_flavor(or_options_t *options, int flavor) { @@ -1485,13 +1486,15 @@ networkstatus_get_live_consensus(time_t now) /** As networkstatus_get_live_consensus(), but is way more tolerant of expired * consensuses. */ networkstatus_t * -networkstatus_get_reasonably_live_consensus(time_t now) +networkstatus_get_reasonably_live_consensus(time_t now, int flavor) { #define REASONABLY_LIVE_TIME (24*60*60) - if (current_consensus && - current_consensus->valid_after <= now && - now <= current_consensus->valid_until+REASONABLY_LIVE_TIME) - return current_consensus; + networkstatus_t *consensus = + networkstatus_get_latest_consensus_by_flavor(flavor); + if (consensus && + consensus->valid_after <= now && + now <= consensus->valid_until+REASONABLY_LIVE_TIME) + return consensus; else return NULL; } @@ -1890,7 +1893,8 @@ void routers_update_all_from_networkstatus(time_t now, int dir_version) { routerlist_t *rl = router_get_routerlist(); - networkstatus_t *consensus = networkstatus_get_live_consensus(now); + networkstatus_t *consensus = networkstatus_get_reasonably_live_consensus(now, + FLAV_NS); if (networkstatus_v2_list_has_changed) download_status_map_update_from_v2_networkstatus(); diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h index ad91e9d3e4..566171c799 100644 --- a/src/or/networkstatus.h +++ b/src/or/networkstatus.h @@ -65,7 +65,8 @@ networkstatus_t *networkstatus_get_latest_consensus(void); networkstatus_t *networkstatus_get_latest_consensus_by_flavor( consensus_flavor_t f); networkstatus_t *networkstatus_get_live_consensus(time_t now); -networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now); +networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now, + int flavor); #define NSSET_FROM_CACHE 1 #define NSSET_WAS_WAITING_FOR_CERTS 2 #define NSSET_DONT_DOWNLOAD_CERTS 4 diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1f542b1f46..27b870da3f 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -4539,10 +4539,13 @@ update_router_descriptor_downloads(time_t now) if (directory_fetches_dir_info_early(options)) { update_router_descriptor_cache_downloads_v2(now); } + update_consensus_router_descriptor_downloads(now, 0, - networkstatus_get_reasonably_live_consensus(now)); + networkstatus_get_reasonably_live_consensus(now, FLAV_NS)); /* XXXX021 we could be smarter here; see notes on bug 652. */ + /* XXXX NM Microdescs: if we're not fetching microdescriptors, we need + * to make something else invoke this. */ /* If we're a server that doesn't have a configured address, we rely on * directory fetches to learn when our address changes. So if we haven't * tried to get any routerdescs in a long time, try a dummy fetch now. */ @@ -4713,7 +4716,7 @@ count_loading_descriptors_progress(void) int num_present = 0, num_usable=0; time_t now = time(NULL); const networkstatus_t *consensus = - networkstatus_get_reasonably_live_consensus(now); + networkstatus_get_reasonably_live_consensus(now, FLAV_NS); double fraction; if (!consensus) @@ -4743,7 +4746,7 @@ update_router_have_minimum_dir_info(void) int res; or_options_t *options = get_options(); const networkstatus_t *consensus = - networkstatus_get_reasonably_live_consensus(now); + networkstatus_get_reasonably_live_consensus(now, FLAV_NS); if (!consensus) { if (!networkstatus_get_latest_consensus()) |