[or-cvs] [tor/master 4/6] When updating routerdesc downloads, look specifically at the ns consensus
nickm at torproject.org
nickm at torproject.org
Tue Sep 28 04:44:16 UTC 2010
Author: Nick Mathewson <nickm at torproject.org>
Date: Mon, 20 Sep 2010 14:18:17 -0400
Subject: When updating routerdesc downloads, look specifically at the ns consensus
Commit: e34d0d3365f5263d2888d63a4d58dc479f191565
This will be needed when "get_live_consensus" potentially returns a
microdesc consensus.
---
src/or/networkstatus.c | 16 ++++++++++------
src/or/networkstatus.h | 3 ++-
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 8b2a102..4ccd1ae 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 ad91e9d..566171c 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 1f542b1..27b870d 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())
--
1.7.1
More information about the tor-commits
mailing list