use !cbt_disabled in place of LearnCBT to avoid needless circs

This would make us do testing circuits "even when cbt is disabled by
consensus, or when we're a directory authority, or when we've failed
to write cbt history to our state file lately." (Roger's words.)

This is a fix for 9671 and an improvement in our fix for 5049.
The original misbehavior was in 0.2.2.14-alpha; the incomplete
fix was in 0.2.3.17-beta.
This commit is contained in:
Nick Mathewson 2013-09-04 15:51:13 -04:00
parent 8611195a00
commit 4f3dbb3c0a
4 changed files with 9 additions and 3 deletions

5
changes/bug9671_023 Normal file
View File

@ -0,0 +1,5 @@
o Major bugfixes:
- If the circuit build timeout logic is disabled (via the consensus,
or because we are an authority), then don't build testing circuits.
Fixes bug 9657; bugfix on 0.2.2.14-alpha.

View File

@ -147,7 +147,7 @@ static void pathbias_count_success(origin_circuit_t *circ);
* 3. If we are a directory authority
* 4. If we fail to write circuit build time history to our state file.
*/
static int
int
circuit_build_times_disabled(void)
{
if (unit_tests) {

View File

@ -32,6 +32,7 @@ char *circuit_list_path_for_controller(origin_circuit_t *circ);
void circuit_log_path(int severity, unsigned int domain,
origin_circuit_t *circ);
void circuit_rep_hist_note_result(origin_circuit_t *circ);
int circuit_build_times_disabled(void);
origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags);
origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
extend_info_t *exit,

View File

@ -746,7 +746,7 @@ circuit_predict_and_launch_new(void)
* want, don't do another -- we want to leave a few slots open so
* we can still build circuits preemptively as needed. */
if (num < MAX_UNUSED_OPEN_CIRCUITS-2 &&
get_options()->LearnCircuitBuildTimeout &&
! circuit_build_times_disabled() &&
circuit_build_times_needs_circuits_now(&circ_times)) {
flags = CIRCLAUNCH_NEED_CAPACITY;
log_info(LD_CIRC,
@ -882,7 +882,7 @@ circuit_expire_old_circuits_clientside(void)
tor_gettimeofday(&now);
cutoff = now;
if (get_options()->LearnCircuitBuildTimeout &&
if (! circuit_build_times_disabled() &&
circuit_build_times_needs_circuits(&circ_times)) {
/* Circuits should be shorter lived if we need more of them
* for learning a good build timeout */