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
This commit is contained in:
Nick Mathewson 2007-02-12 23:39:24 +00:00
parent b16c544509
commit 95b828b685
4 changed files with 26 additions and 5 deletions

View File

@ -6,6 +6,9 @@ Changes in version 0.1.2.8-alpha - 2007-??-??
o Major bugfixes (crashes):
- Stop crashing when the controller asks us to resetconf more than
one config option at once. (Vidalia 0.0.11 does this.)
- Fix a crash that happened on Win98 when we're given command-line
arguments: Don't try to load NT service functions from advapi32.dll
except when we need them. (bug introduced in 0.1.2.7-alpha).
o Minor bugfixes (controller):
- Give the controller END_STREAM_REASON_DESTROY events _before_ we
@ -31,8 +34,6 @@ Changes in version 0.1.2.8-alpha - 2007-??-??
other than file-not-found.
- Don't warn the user when cached-routers.new doesn't exist: that's
perfectly fine when starting up for the first time.
- Don't try to load NT service functions from advapi32.dll except when
we need them. (bug introduced in 0.1.2.7-alpha).
o Minor features:
- Warn the user when an application uses the obsolete binary v0
@ -49,6 +50,8 @@ Changes in version 0.1.2.8-alpha - 2007-??-??
protocol easier to recognize on the wire.)
- Revise messages on handshake failure again to be even more clear about
which are incoming connections and which are outgoing.
- Discard any v1 directory info that's over 1 month old (for
directories) or over 1 week old (for running-routers lists).
Changes in version 0.1.2.7-alpha - 2007-02-06

View File

@ -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

View File

@ -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);

View File

@ -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.*/