aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-19 02:15:47 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-19 02:15:47 +0000
commit29dfdac923dc0c20ce3f386c868bc4d43f816bf9 (patch)
tree0f75a77a241871d313ba9c919a4a6cef33a06a5d /src/or/routerlist.c
parent90de3ca9aeaddbbad092255f7e599a45ea503f24 (diff)
downloadtor-29dfdac923dc0c20ce3f386c868bc4d43f816bf9.tar.gz
tor-29dfdac923dc0c20ce3f386c868bc4d43f816bf9.zip
r15939@catbus: nickm | 2007-10-18 22:14:15 -0400
Remember the valid-until time of the most recent consensus that listed a router, and (if we are a cache) never delete the routerdesc until that conensus is expired. This is way easier than retaining multiple consensuses. (Of course, the info isn't retained across restarts, but that only affects a few caches at a time.) svn:r12041
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 6c7b252d9e..27fb2dbf81 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2791,7 +2791,8 @@ _compare_duration_idx(const void *_d1, const void *_d2)
* indices <b>lo</b> or higher may be changed.
*/
static void
-routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi,
+routerlist_remove_old_cached_routers_with_id(time_t now,
+ time_t cutoff, int lo, int hi,
digestmap_t *retain)
{
int i, n = hi-lo+1;
@@ -2827,7 +2828,8 @@ routerlist_remove_old_cached_routers_with_id(time_t cutoff, int lo, int hi,
signed_descriptor_t *r = smartlist_get(lst, i);
signed_descriptor_t *r_next;
lifespans[i-lo].idx = i;
- if (retain && digestmap_get(retain, r->signed_descriptor_digest)) {
+ if (r->last_listed_as_valid_until >= now ||
+ (retain && digestmap_get(retain, r->signed_descriptor_digest))) {
must_keep[i-lo] = 1;
}
if (i < hi) {
@@ -2933,6 +2935,7 @@ routerlist_remove_old_routers(void)
for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
router = smartlist_get(routerlist->routers, i);
if (router->cache_info.published_on <= cutoff &&
+ router->cache_info.last_listed_as_valid_until < now &&
!digestmap_get(retain,router->cache_info.signed_descriptor_digest)) {
/* Too old: remove it. (If we're a cache, just move it into
* old_routers.) */
@@ -2952,6 +2955,7 @@ routerlist_remove_old_routers(void)
for (i = 0; i < smartlist_len(routerlist->old_routers); ++i) {
sd = smartlist_get(routerlist->old_routers, i);
if (sd->published_on <= cutoff &&
+ sd->last_listed_as_valid_until < now &&
!digestmap_get(retain, sd->signed_descriptor_digest)) {
/* Too old. Remove it. */
routerlist_remove_old(routerlist, sd, i--);
@@ -2987,13 +2991,14 @@ routerlist_remove_old_routers(void)
hi = i;
}
if (memcmp(cur_id, r->identity_digest, DIGEST_LEN)) {
- routerlist_remove_old_cached_routers_with_id(cutoff, i+1, hi, retain);
+ routerlist_remove_old_cached_routers_with_id(now,
+ cutoff, i+1, hi, retain);
cur_id = r->identity_digest;
hi = i;
}
}
if (hi>=0)
- routerlist_remove_old_cached_routers_with_id(cutoff, 0, hi, retain);
+ routerlist_remove_old_cached_routers_with_id(now, cutoff, 0, hi, retain);
//routerlist_assert_ok(routerlist);
done: