aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@fscked.org>2009-09-14 04:03:57 -0700
committerMike Perry <mikeperry-git@fscked.org>2009-09-16 15:58:42 -0700
commit0352d4391756cf80c220d9daf49f2cbc55856e89 (patch)
tree5721f8004e8dcd3b3b17f311700e4882915811e4 /src/or/circuitbuild.c
parent09a75ad31609b30f9e4a057373f2c4f17427eaf9 (diff)
downloadtor-0352d4391756cf80c220d9daf49f2cbc55856e89.tar
tor-0352d4391756cf80c220d9daf49f2cbc55856e89.tar.gz
Move circuitbuildtimeout config check.
We want it to be under our control so it doesn't mess up initialization. This is likely the cause for the bug the previous assert-adding commit (09a75ad) was trying to address.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 4999078c9..a141795a1 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -141,6 +141,11 @@ circuit_build_times_init(circuit_build_times_t *cbt)
if (!unit_tests && get_options()->CircuitBuildTimeout) {
cbt->timeout = get_options()->CircuitBuildTimeout;
+ if (cbt->timeout < BUILD_TIMEOUT_MIN_VALUE) {
+ log_warn(LD_CIRC, "Config CircuitBuildTimeout too low. Setting to %d",
+ BUILD_TIMEOUT_MIN_VALUE);
+ cbt->timeout = BUILD_TIMEOUT_MIN_VALUE;
+ }
} else {
cbt->timeout = BUILD_TIMEOUT_INITIAL_VALUE;
}
@@ -697,6 +702,12 @@ circuit_build_times_check_too_many_timeouts(circuit_build_times_t *cbt)
cbt->timeout = lround(timeout/1000.0);
+ if (cbt->timeout < BUILD_TIMEOUT_MIN_VALUE) {
+ log_warn(LD_CIRC, "Reset buildtimeout to low value %lf. Setting to %d",
+ timeout, BUILD_TIMEOUT_MIN_VALUE);
+ cbt->timeout = BUILD_TIMEOUT_MIN_VALUE;
+ }
+
log_notice(LD_CIRC,
"Reset circuit build timeout to %d (%lf, Xm: %d, a: %lf) based "
"on %d recent circuit times", cbt->timeout, timeout, cbt->Xm,
@@ -761,6 +772,12 @@ circuit_build_times_set_timeout(circuit_build_times_t *cbt)
cbt->have_computed_timeout = 1;
cbt->timeout = lround(timeout/1000.0);
+ if (cbt->timeout < BUILD_TIMEOUT_MIN_VALUE) {
+ log_warn(LD_CIRC, "Set buildtimeout to low value %lf. Setting to %d",
+ timeout, BUILD_TIMEOUT_MIN_VALUE);
+ cbt->timeout = BUILD_TIMEOUT_MIN_VALUE;
+ }
+
log_info(LD_CIRC,
"Set circuit build timeout to %d (%lf, Xm: %d, a: %lf) based on "
"%d circuit times", cbt->timeout, timeout, cbt->Xm, cbt->alpha,