diff options
author | Caio Valente <valentecaio95@gmail.com> | 2018-01-31 02:36:38 +0100 |
---|---|---|
committer | Caio Valente <valentecaio95@gmail.com> | 2018-01-31 02:36:38 +0100 |
commit | a4c85312604c1d215f9f46a24ac242baf666ed56 (patch) | |
tree | 1e2bc081862d5b31b2eefdc5b4efb4fb7d20ac15 /src/or/main.c | |
parent | d2ae1bfcb314965fd1ff1353308da0e92a00c958 (diff) | |
download | tor-a4c85312604c1d215f9f46a24ac242baf666ed56.tar.gz tor-a4c85312604c1d215f9f46a24ac242baf666ed56.zip |
refactor: using get_uptime() (and reset_uptime()) consistently.
Using get_uptime() and reset_uptime() instead of
accessing stats_n_seconds_working directly.
stats_n_seconds_working is not extern anymore.
Ticket #25081
Diffstat (limited to 'src/or/main.c')
-rw-r--r-- | src/or/main.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/or/main.c b/src/or/main.c index 96c7e77c79..7b88686fd2 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1094,7 +1094,7 @@ directory_all_unreachable(time_t now) { (void)now; - stats_n_seconds_working=0; /* reset it */ + reset_uptime(); /* reset it */ if (!directory_all_unreachable_cb_event) { directory_all_unreachable_cb_event = @@ -2062,7 +2062,7 @@ check_for_reachability_bw_callback(time_t now, const or_options_t *options) if (server_mode(options) && (have_completed_a_circuit() || !any_predicted_circuits(now)) && !net_is_disabled()) { - if (stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { + if (get_uptime() < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { consider_testing_reachability(1, dirport_reachability_count==0); if (++dirport_reachability_count > 5) dirport_reachability_count = 0; @@ -2319,8 +2319,8 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg) !net_is_disabled() && seconds_elapsed > 0 && have_completed_a_circuit() && - stats_n_seconds_working / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT != - (stats_n_seconds_working+seconds_elapsed) / + get_uptime() / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT != + (get_uptime()+seconds_elapsed) / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { /* every 20 minutes, check and complain if necessary */ const routerinfo_t *me = router_get_my_routerinfo(); @@ -2464,9 +2464,9 @@ ip_address_changed(int at_interface) } } else { if (server) { - if (stats_n_seconds_working > UPTIME_CUTOFF_FOR_NEW_BANDWIDTH_TEST) + if (get_uptime() > UPTIME_CUTOFF_FOR_NEW_BANDWIDTH_TEST) reset_bandwidth_test(); - stats_n_seconds_working = 0; + reset_uptime(); router_reset_reachability(); } } @@ -3004,6 +3004,13 @@ get_uptime,(void)) return stats_n_seconds_working; } +/** Reset Tor's uptime. */ +MOCK_IMPL(void, +reset_uptime,(void)) +{ + stats_n_seconds_working = 0; +} + /** * Write current memory usage information to the log. */ |