aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-25 01:53:49 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-25 01:53:49 +0000
commit93331ebf692eb77bf141d8e288eb701cdd5f332c (patch)
tree1ecd6c57ac229be0cdd3a734b2afa6998a70e610 /src/or
parente0204f211942d3d8fedb73b4015757ac8e2a739e (diff)
downloadtor-93331ebf692eb77bf141d8e288eb701cdd5f332c.tar
tor-93331ebf692eb77bf141d8e288eb701cdd5f332c.tar.gz
r16115@catbus: nickm | 2007-10-24 21:52:33 -0400
Tolerate a slightly dead consensus when deciding whether to download descriptors and build circuits. svn:r12167
Diffstat (limited to 'src/or')
-rw-r--r--src/or/networkstatus.c13
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/routerlist.c5
3 files changed, 17 insertions, 2 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index b82b0be17..332e7b0ad 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1122,6 +1122,19 @@ networkstatus_get_live_consensus(time_t now)
return NULL;
}
+/* XXXX020 remove this in favor of get_live_consensus. */
+networkstatus_vote_t *
+networkstatus_get_reasonably_live_consensus(time_t now)
+{
+#define REASONABLY_LIVE_TIME (24*60*60)
+ if (current_consensus &&
+ current_consensus->valid_after <= now+REASONABLY_LIVE_TIME &&
+ now <= current_consensus->valid_until)
+ return current_consensus;
+ else
+ return NULL;
+}
+
/** Copy all the ancillary information (like router download status and so on)
* from <b>old_c</b> to <b>new_c</b>. */
static void
diff --git a/src/or/or.h b/src/or/or.h
index 57f657dcf..344745d8e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3112,6 +3112,7 @@ void update_certificate_downloads(time_t now);
networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
networkstatus_vote_t *networkstatus_get_latest_consensus(void);
networkstatus_vote_t *networkstatus_get_live_consensus(time_t now);
+networkstatus_vote_t *networkstatus_get_reasonably_live_consensus(time_t now);
int networkstatus_set_current_consensus(const char *consensus, int from_cache,
int was_waiting_for_certs);
void networkstatus_note_certs_arrived(void);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 95e45fa42..9da42a3a2 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3685,7 +3685,8 @@ update_consensus_router_descriptor_downloads(time_t now)
smartlist_t *downloadable = smartlist_create();
int authdir = authdir_mode(options);
int dirserver = dirserver_mode(options);
- networkstatus_vote_t *consensus = networkstatus_get_live_consensus(now);
+ networkstatus_vote_t *consensus =
+ networkstatus_get_reasonably_live_consensus(now);
int n_delayed=0, n_have=0, n_would_reject=0, n_wouldnt_use=0,
n_inprogress=0;
@@ -3864,7 +3865,7 @@ update_router_have_minimum_dir_info(void)
int res;
or_options_t *options = get_options();
const networkstatus_vote_t *consensus =
- networkstatus_get_live_consensus(now);
+ networkstatus_get_reasonably_live_consensus(now);
if (!consensus) {
res = 0;