diff options
author | Andrea Shepard <andrea@persephoneslair.org> | 2012-06-12 19:27:37 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-06-13 16:45:13 -0400 |
commit | aa284561c804085ab2bb3e414165fdeff9872d05 (patch) | |
tree | 5aa83c450422a3e75cbcecf24117d85871d3c899 /src | |
parent | 825fb149cdbd30cd25a652d9f5921f6eedd49ad2 (diff) | |
download | tor-aa284561c804085ab2bb3e414165fdeff9872d05.tar.gz tor-aa284561c804085ab2bb3e414165fdeff9872d05.zip |
Move cbt->liveness.timeouts_after_firsthop free code into its own function
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitbuild.c | 29 | ||||
-rw-r--r-- | src/or/circuitbuild.h | 1 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 03b702bed9..4f46022f4c 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -493,12 +493,7 @@ circuit_build_times_new_consensus_params(circuit_build_times_t *cbt, "This disables adaptive timeouts since we can't keep track of " "any recent circuits."); - if (cbt->liveness.timeouts_after_firsthop) { - tor_free(cbt->liveness.timeouts_after_firsthop); - cbt->liveness.timeouts_after_firsthop = NULL; - } - - cbt->liveness.num_recent_circs = num; + circuit_build_times_free_timeouts(cbt); } } else { /* @@ -509,12 +504,7 @@ circuit_build_times_new_consensus_params(circuit_build_times_t *cbt, * if we have any. */ - if (cbt->liveness.timeouts_after_firsthop) { - tor_free(cbt->liveness.timeouts_after_firsthop); - cbt->liveness.timeouts_after_firsthop = NULL; - } - - cbt->liveness.num_recent_circs = 0; + circuit_build_times_free_timeouts(cbt); } } @@ -598,6 +588,21 @@ circuit_build_times_init(circuit_build_times_t *cbt) control_event_buildtimeout_set(cbt, BUILDTIMEOUT_SET_EVENT_RESET); } +/** + * Free the saved timeouts, if the cbtdisabled consensus parameter got turned + * on or something. + */ + +void circuit_build_times_free_timeouts(circuit_build_times_t *cbt) { + if (!cbt) return; + + if (cbt->liveness.timeouts_after_firsthop) { + tor_free(cbt->liveness.timeouts_after_firsthop); + } + + cbt->liveness.num_recent_circs = 0; +} + #if 0 /** * Rewind our build time history by n positions. diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h index 5b77399030..92811783d3 100644 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@ -121,6 +121,7 @@ int circuit_build_times_needs_circuits(circuit_build_times_t *cbt); int circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt); void circuit_build_times_init(circuit_build_times_t *cbt); +void circuit_build_times_free_timeouts(circuit_build_times_t *cbt); void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt, networkstatus_t *ns); double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt); |