diff options
author | Roger Dingledine <arma@torproject.org> | 2004-09-23 19:58:44 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-09-23 19:58:44 +0000 |
commit | 185b9fddf2d7fbdfce4b1f273cb9bd99720c561a (patch) | |
tree | 812d1214808ecedb2c0c8a471b3ab61c0d47b2ce /src/or/dirserv.c | |
parent | 02e3e3327cedc1fc6015c74ef8180745f403dec3 (diff) | |
download | tor-185b9fddf2d7fbdfce4b1f273cb9bd99720c561a.tar tor-185b9fddf2d7fbdfce4b1f273cb9bd99720c561a.tar.gz |
protect dirservers from overzealous descriptor uploading
wait 10 seconds after directory gets dirty, before regenerating
svn:r2370
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 0d9d433a1..bba90b417 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -11,6 +11,8 @@ /** How far in the future do we allow a router to get? (seconds) */ #define ROUTER_ALLOW_SKEW (30*60) +/** How many seconds do we wait before regenerating the directory? */ +#define DIR_REGEN_SLACK_TIME 10 extern or_options_t options; /**< command-line and config-file options */ @@ -422,8 +424,12 @@ directory_remove_unrecognized(void) void directory_set_dirty() { - the_directory_is_dirty = 1; - runningrouters_is_dirty = 1; + time_t now = time(NULL); + + if(!the_directory_is_dirty) + the_directory_is_dirty = now; + if(!runningrouters_is_dirty) + runningrouters_is_dirty = now; } /** Load all descriptors from a directory stored in the string @@ -672,7 +678,8 @@ size_t dirserv_get_directory(const char **directory, int deflate) return 0; } } - if (the_directory_is_dirty) { + if (the_directory_is_dirty && + the_directory_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL)) { if (dirserv_regenerate_directory()) return 0; } else { @@ -792,7 +799,8 @@ static int generate_runningrouters(crypto_pk_env_t *private_key) * size of the directory on success, and 0 on failure. */ size_t dirserv_get_runningrouters(const char **rr) { - if (runningrouters_is_dirty) { + if (runningrouters_is_dirty && + runningrouters_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL)) { if(generate_runningrouters(get_identity_key())) { log_fn(LOG_ERR, "Couldn't generate running-routers list?"); return 0; |