diff options
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 1d4d267b7c..97e7c1c0f9 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -84,22 +84,26 @@ static void entry_guards_changed(void); static int circuit_build_times_disabled(void) { - int consensus_disabled = networkstatus_get_param(NULL, "cbtdisabled", - 0); - int config_disabled = !get_options()->LearnCircuitBuildTimeout; - int dirauth_disabled = get_options()->AuthoritativeDir; - int state_disabled = (get_or_state()->LastWritten == -1); - - if (consensus_disabled || config_disabled || dirauth_disabled || - state_disabled) { - log_info(LD_CIRC, - "CircuitBuildTime learning is disabled. " - "Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d", - consensus_disabled, config_disabled, dirauth_disabled, - state_disabled); - return 1; - } else { + if (unit_tests) { return 0; + } else { + int consensus_disabled = networkstatus_get_param(NULL, "cbtdisabled", + 0); + int config_disabled = !get_options()->LearnCircuitBuildTimeout; + int dirauth_disabled = get_options()->AuthoritativeDir; + int state_disabled = (get_or_state()->LastWritten == -1); + + if (consensus_disabled || config_disabled || dirauth_disabled || + state_disabled) { + log_info(LD_CIRC, + "CircuitBuildTime learning is disabled. " + "Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d", + consensus_disabled, config_disabled, dirauth_disabled, + state_disabled); + return 1; + } else { + return 0; + } } } @@ -1104,6 +1108,12 @@ circuit_build_times_filter_timeouts(circuit_build_times_t *cbt) return 0; } + /* Do not filter for unit tests. They expect the distribution to be + * unchanged from run to run. */ + if (unit_tests) { + return 0; + } + timeout_rate = circuit_build_times_timeout_rate(cbt); max_timeout = (build_time_t)tor_lround(circuit_build_times_calculate_timeout(cbt, circuit_build_times_max_synthetic_quantile())); |