diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-02-12 23:39:24 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-02-12 23:39:24 +0000 |
commit | 95b828b6857454329193a9531539b04915148f23 (patch) | |
tree | be381d81a190ca84fd0f1d633c98f2867f69abcc /src | |
parent | b16c544509045f09901499591e3c28763b1cdeb9 (diff) | |
download | tor-95b828b6857454329193a9531539b04915148f23.tar.gz tor-95b828b6857454329193a9531539b04915148f23.zip |
r11781@catbus: nickm | 2007-02-12 18:31:33 -0500
Discard any v1 directory info that is so old as to be useless. (Fixes bug 387)
svn:r9572
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirserv.c | 20 | ||||
-rw-r--r-- | src/or/or.h | 1 | ||||
-rw-r--r-- | src/or/routerlist.c | 3 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index b317a4baa4..e7ac7bccc2 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -937,10 +937,11 @@ dirserv_dump_directory_to_string(char **dir_out, return -1; } -/** Most recently generated encoded signed directory. (auth dirservers only.)*/ +/** Most recently generated encoded signed v1 directory. (auth dirservers + * only.)*/ static cached_dir_t *the_directory = NULL; -/* Used only by non-auth dirservers: The directory and runningrouters we'll +/* Used only by non-auth dirservers: The v1 directory and runningrouters we'll * serve when requested. */ static cached_dir_t *cached_directory = NULL; static cached_dir_t cached_runningrouters = { NULL, NULL, 0, 0, 0, -1 }; @@ -1135,7 +1136,22 @@ dirserv_clear_old_networkstatuses(time_t cutoff) iter = digestmap_iter_next(cached_v2_networkstatus, iter); } } +} +/** Remove any networkstatus from the directory cache that was published + * before <b>cutoff</b>. */ +void +dirserv_clear_old_v1_info(time_t now) +{ +#define MAX_V1_DIRECTORY_AGE (30*24*60*60) +#define MAX_V1_RR_AGE (7*24*60*60) + if (cached_directory && + cached_directory->published < (now-MAX_V1_DIRECTORY_AGE)) { + cached_dir_decref(cached_directory); + } + if (cached_runningrouters.published < (now - MAX_V1_RR_AGE)) { + clear_cached_dir(&cached_runningrouters); + } } /** Helper: If we're an authority for the right directory version (the diff --git a/src/or/or.h b/src/or/or.h index 519244b9e9..b68ac432be 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2427,6 +2427,7 @@ void dirserv_set_cached_networkstatus_v2(const char *directory, const char *identity, time_t published); void dirserv_clear_old_networkstatuses(time_t cutoff); +void dirserv_clear_old_v1_info(time_t now); void dirserv_get_networkstatus_v2(smartlist_t *result, const char *key); void dirserv_get_networkstatus_v2_fingerprints(smartlist_t *result, const char *key); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 84c546020d..023a9c2266 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2590,8 +2590,9 @@ networkstatus_list_clean(time_t now) } /* And now go through the directory cache for any cached untrusted - * networkstatuses. */ + * networkstatuses and other network info. */ dirserv_clear_old_networkstatuses(now - MAX_NETWORKSTATUS_AGE); + dirserv_clear_old_v1_info(now); } /** Helper for bsearching a list of routerstatus_t pointers.*/ |