From 8fdfdc5bbb0575d94603d4843ca85b15b3e63203 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 12 Oct 2007 17:13:09 +0000 Subject: [PATCH] r15719@catbus: nickm | 2007-10-12 13:07:45 -0400 Add the routers in the latest consensus to the list of routers to retain when removing old ones. svn:r11895 --- src/or/routerlist.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/or/routerlist.c b/src/or/routerlist.c index f7da316ce9..5dc0af6666 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2860,6 +2860,7 @@ routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi, void routerlist_remove_old_routers(void) { + /* XXXX020 call me less often */ int i, hi=-1; const char *cur_id = NULL; time_t now = time(NULL); @@ -2878,7 +2879,7 @@ routerlist_remove_old_routers(void) retain = digestmap_new(); cutoff = now - OLD_ROUTER_DESC_MAX_AGE; - /* Build a list of all the descriptors that _anybody_ recommends. */ + /* Build a list of all the descriptors that _anybody_ lists. */ SMARTLIST_FOREACH(networkstatus_list, networkstatus_t *, ns, { /* XXXX The inner loop here gets pretty expensive, and actually shows up @@ -2894,6 +2895,16 @@ routerlist_remove_old_routers(void) digestmap_set(retain, rs->descriptor_digest, (void*)1)); }); + { + /* Retain anything listed in the consensus. */ + networkstatus_vote_t *ns = networkstatus_get_latest_consensus(); + if (ns) { + SMARTLIST_FOREACH(ns->routerstatus_list, routerstatus_t *, rs, + if (rs->published_on >= cutoff) + digestmap_set(retain, rs->descriptor_digest, (void*)1)); + } + } + /* If we have a bunch of networkstatuses, we should consider pruning current * routers that are too old and that nobody recommends. (If we don't have * enough networkstatuses, then we should get more before we decide to kill