summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-28 18:37:52 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-28 18:37:52 +0000
commit11d330be5e8c0cdb41784673699f18f9d206d4d4 (patch)
tree61b98bc262f16b20150305dc9d0ef75de25386b7 /src/or/main.c
parent36bbab2f2bd8fe8902f4852c240a09de13419325 (diff)
downloadtor-11d330be5e8c0cdb41784673699f18f9d206d4d4.tar.gz
tor-11d330be5e8c0cdb41784673699f18f9d206d4d4.zip
Tweaks to prevent obsolete restarting tors from hammering the dirservers. (1) Cache a received directory as soon as the signature checks out. (2) Treat a cached directory as "recent" based on its mtime. (3) If we have a recent directory, we dont need to fetch a newer one for DirFetchPostPeriod. This needs review!
svn:r2618
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 09836af4c2..a85ab53afb 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -31,6 +31,9 @@ static uint64_t stats_n_bytes_read = 0;
static uint64_t stats_n_bytes_written = 0;
/** How many seconds have we been running? */
long stats_n_seconds_uptime = 0;
+/** When do we next download a directory? */
+static time_t time_to_fetch_directory = 0;
+
/** Array of all open connections; each element corresponds to the element of
* poll_array in the same position. The first nfds elements are valid. */
@@ -359,11 +362,16 @@ static void conn_close_if_marked(int i) {
}
/** This function is called whenever we successfully pull down a directory */
-void directory_has_arrived(void) {
+void directory_has_arrived(time_t now) {
log_fn(LOG_INFO, "A directory has arrived.");
has_fetched_directory=1;
+ /* Don't try to upload or download anything for DirFetchPostPeriod
+ * seconds after the directory we had when we started.
+ */
+ if (!time_to_fetch_directory)
+ time_to_fetch_directory = now + options.DirFetchPostPeriod;
if(server_mode()) { /* connect to the appropriate routers */
router_retry_connections();
@@ -496,7 +504,6 @@ int proxy_mode(void) {
* second by prepare_for_poll.
*/
static void run_scheduled_events(time_t now) {
- static long time_to_fetch_directory = 0;
static time_t last_uploaded_services = 0;
static time_t last_rotated_certificate = 0;
static time_t time_to_check_listeners = 0;