mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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. ;)
This commit is contained in:
parent
977e396e86
commit
176fde505f
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user