Unconditionally use config CircuitBuildTimeout if LearnCircuitBuildTimeout is disabled

This commit is contained in:
Andrea Shepard 2012-06-12 12:11:32 -07:00 committed by Nick Mathewson
parent 5177ab9e47
commit 7df26de948

View File

@ -535,16 +535,27 @@ static double
circuit_build_times_get_initial_timeout(void)
{
double timeout;
if (!unit_tests && get_options()->CircuitBuildTimeout) {
timeout = get_options()->CircuitBuildTimeout*1000;
if (timeout < circuit_build_times_min_timeout()) {
log_warn(LD_CIRC, "Config CircuitBuildTimeout too low. Setting to %ds",
circuit_build_times_min_timeout()/1000);
timeout = circuit_build_times_min_timeout();
/*
* Check if we have LearnCircuitBuildTimeout, and if we don't,
* always use CircuitBuildTimeout, no questions asked.
*/
if (get_options()->LearnCircuitBuildTimeout) {
if (!unit_tests && get_options()->CircuitBuildTimeout) {
timeout = get_options()->CircuitBuildTimeout*1000;
if (timeout < circuit_build_times_min_timeout()) {
log_warn(LD_CIRC, "Config CircuitBuildTimeout too low. Setting to %ds",
circuit_build_times_min_timeout()/1000);
timeout = circuit_build_times_min_timeout();
}
} else {
timeout = circuit_build_times_initial_timeout();
}
} else {
timeout = circuit_build_times_initial_timeout();
}
else {
timeout = get_options()->CircuitBuildTimeout*1000;
}
return timeout;
}