aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog3
-rw-r--r--doc/TODO2
-rw-r--r--src/or/main.c22
3 files changed, 22 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5955f1e5c7..95bfbdf825 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ Changes in version 0.2.0.18-alpha - 2008-01-??
- Avoid going directly to the directory authorities even if you're a
relay, if you haven't found yourself reachable yet or if you've
decided not to advertise your dirport yet. Addresses bug 556.
+ - 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.
o Minor features:
- Don't answer "/tor/networkstatus-bridges" directory requests if
diff --git a/doc/TODO b/doc/TODO
index ac757062e7..6036815caf 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -93,7 +93,7 @@ N - Before the feature freeze:
even when the network came back and arma clicked on things.
also 0.2.0.
R - for above two, roger should turn them into flyspray entry.
-R - we should do another bandwidth test every 12 hours or something
+ o we should do another bandwidth test every 12 hours or something
if we're showing less than 50KB and our bandwidthrate says we can
do more than that. I think some servers are forgetting the results
of their first test, and then never seeing use.
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