]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Tweak bug2716 patch a little
authorNick Mathewson <nickm@torproject.org>
Sat, 12 Mar 2011 05:19:52 +0000 (00:19 -0500)
committerNick Mathewson <nickm@torproject.org>
Sat, 12 Mar 2011 05:19:52 +0000 (00:19 -0500)
Name the magic value "10" rather than re-deriving it.

Comment more.

Use the pattern that works for periodic timers, not the pattern that
doesn't work. ;)

src/or/dirserv.c
src/or/dirserv.h
src/or/main.c

index 73869273a366b4d66695b641e8cc8ee7ef795924..b68e005531f770c230dd592545cd7feecbbf8047 100644 (file)
@@ -969,11 +969,17 @@ dirserv_set_router_is_running(routerinfo_t *router, time_t now)
   }
 
   if (!answer && running_long_enough_to_decide_unreachable()) {
-    /* not considered reachable. tell rephist. */
+    /* Not considered reachable. tell rephist about that.
+
+       Because we launch a reachability test for each router every
+       REACHABILITY_TEST_CYCLE_PERIOD seconds, then the router has probably
+       been down since at least that time after we last successfully reached
+       it.
+     */
     time_t when = now;
     if (router->last_reachable &&
-        router->last_reachable + REACHABILITY_TEST_PERIOD < now)
-      when = router->last_reachable + REACHABILITY_TEST_PERIOD;
+        router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD < now)
+      when = router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD;
     rep_hist_note_router_unreachable(router->cache_info.identity_digest, when);
   }
 
index 949482ba734a79aa3e4dd10b0ac3a37c41edad17..569abfca2ee500736b17e4bfe0a68b96c7545eb1 100644 (file)
  * test? */
 #define REACHABILITY_MODULO_PER_TEST 128
 
+/** How often (in seconds) do we launch reachability tests? */
+#define REACHABILITY_TEST_INTERVAL 10
+
 /** How many seconds apart are the reachability tests for a given relay? */
-#define REACHABILITY_TEST_PERIOD (10*REACHABILITY_MODULO_PER_TEST)
+#define REACHABILITY_TEST_CYCLE_PERIOD \
+  (REACHABILITY_TEST_INTERVAL*REACHABILITY_MODULO_PER_TEST)
 
 /** Maximum length of an exit policy summary. */
 #define MAX_EXITPOLICY_SUMMARY_LEN 1000
index 558608ec8c3676a104ee7fddc656bfdfd162468b..214a4fad5da01e4d41f7efb77f33f7cb2ca9b647 100644 (file)
@@ -872,6 +872,7 @@ run_scheduled_events(time_t now)
   static time_t time_to_check_for_expired_networkstatus = 0;
   static time_t time_to_write_stats_files = 0;
   static time_t time_to_write_bridge_stats = 0;
+  static time_t time_to_launch_reachability_tests = 0;
   static int should_init_bridge_stats = 1;
   static time_t time_to_retry_dns_init = 0;
   or_options_t *options = get_options();
@@ -962,9 +963,10 @@ run_scheduled_events(time_t now)
   if (accounting_is_enabled(options))
     accounting_run_housekeeping(now);
 
-  if (now % REACHABILITY_TEST_PERIOD/REACHABILITY_MODULO_PER_TEST == 0 &&
+  if (time_to_launch_reachability_tests < now &&
       (authdir_mode_tests_reachability(options)) &&
        !we_are_hibernating()) {
+    time_to_launch_reachability_tests = now + REACHABILITY_TEST_INTERVAL;
     /* try to determine reachability of the other Tor relays */
     dirserv_test_reachability(now);
   }