summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-01-18 04:58:40 +0000
committerRoger Dingledine <arma@torproject.org>2008-01-18 04:58:40 +0000
commit43dce232ad0f12fa02d713191e47502aaff96bf0 (patch)
treee647db0a2c3d12a734aa1267688b1b67c5913245 /src/or/main.c
parent3d3663a123873af350b6c3167481a013d05c2168 (diff)
downloadtor-43dce232ad0f12fa02d713191e47502aaff96bf0.tar.gz
tor-43dce232ad0f12fa02d713191e47502aaff96bf0.zip
If we've gone 12 hours since our last bandwidth check, and we
estimate we have less than 50KB bandwidth capacity but we could handle more, do another bandwidth test. svn:r13176
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 22c3175e61..dfd988f9d4 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -837,6 +837,7 @@ run_scheduled_events(time_t now)
static time_t time_to_save_stability = 0;
#define CLEAN_CACHES_INTERVAL (30*60)
static time_t time_to_clean_caches = 0;
+ static time_t time_to_recheck_bandwidth = 0;
or_options_t *options = get_options();
int i;
int have_dir_info;
@@ -1003,11 +1004,24 @@ run_scheduled_events(time_t now)
* 20 minutes of our uptime. */
if (server_mode(options) &&
(has_completed_circuit || !any_predicted_circuits(now)) &&
- stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT &&
!we_are_hibernating()) {
- consider_testing_reachability(1, dirport_reachability_count==0);
- if (++dirport_reachability_count > 5)
- dirport_reachability_count = 0;
+ if (stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) {
+ consider_testing_reachability(1, dirport_reachability_count==0);
+ if (++dirport_reachability_count > 5)
+ dirport_reachability_count = 0;
+ } else if (time_to_recheck_bandwidth < now) {
+ /* If we haven't checked for 12 hours and our bandwidth estimate is
+ * low, do another bandwidth test. This is especially important for
+ * bridges, since they might go long periods without much use. */
+ routerinfo_t *me = router_get_my_routerinfo();
+ if (time_to_recheck_bandwidth && me &&
+ me->bandwidthcapacity < me->bandwidthrate &&
+ me->bandwidthcapacity < 51200) {
+ reset_bandwidth_test();
+ }
+#define BANDWIDTH_RECHECK_INTERVAL (12*60*60)
+ time_to_recheck_bandwidth = now + BANDWIDTH_RECHECK_INTERVAL;
+ }
}
/* If any networkstatus documents are no longer recent, we need to