[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/release-0.2.2] Tweak bug2716 patch a little
commit 176fde505fde38afa56ddce04606118b9080546e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sat Mar 12 00:19:52 2011 -0500
Tweak bug2716 patch a little
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 | 12 +++++++++---
src/or/dirserv.h | 6 +++++-
src/or/main.c | 4 +++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 7386927..b68e005 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -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);
}
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 949482b..569abfc 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -17,8 +17,12 @@
* 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
diff --git a/src/or/main.c b/src/or/main.c
index 558608e..214a4fa 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -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);
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits