diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-07-09 16:14:14 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-07-09 16:15:05 -0400 |
commit | ed3d7892c721c9495215ecad2e18c026d29fbb9b (patch) | |
tree | c24abed153d4b2ef77748c41333f2dac5b2bd377 /src/or/circuituse.c | |
parent | f5ce580babc5ca8466da02c53669a58bde8f5445 (diff) | |
download | tor-ed3d7892c721c9495215ecad2e18c026d29fbb9b.tar.gz tor-ed3d7892c721c9495215ecad2e18c026d29fbb9b.zip |
Fix a bug where streams would linger forever when we had no dirinfo
fixes bug 8387; fix on 0.1.1.11-alpha (code), or on 0.2.4.10-alpha (behavior).
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index c2d2b2e87c..9933b9c47e 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -969,7 +969,6 @@ circuit_predict_and_launch_new(void) void circuit_build_needed_circs(time_t now) { - static time_t time_to_new_circuit = 0; const or_options_t *options = get_options(); /* launch a new circ for any pending streams that need one */ @@ -978,14 +977,34 @@ circuit_build_needed_circs(time_t now) /* make sure any hidden services have enough intro points */ rend_services_introduce(); - if (time_to_new_circuit < now) { + circuit_expire_old_circs_as_needed(now); + + if (!options->DisablePredictedCircuits) + circuit_predict_and_launch_new(); +} + +/** + * Called once a second either directly or from + * circuit_build_needed_circs(). As appropriate (once per NewCircuitPeriod) + * resets failure counts and expires old circuits. + */ +void +circuit_expire_old_circs_as_needed(time_t now) +{ + static time_t time_to_expire_and_reset = 0; + + if (time_to_expire_and_reset < now) { circuit_reset_failure_count(1); - time_to_new_circuit = now + options->NewCircuitPeriod; + time_to_expire_and_reset = now + get_options()->NewCircuitPeriod; if (proxy_mode(get_options())) addressmap_clean(now); circuit_expire_old_circuits_clientside(); #if 0 /* disable for now, until predict-and-launch-new can cull leftovers */ + + /* If we ever re-enable, this has to move into + * circuit_build_needed_circs */ + circ = circuit_get_youngest_clean_open(CIRCUIT_PURPOSE_C_GENERAL); if (get_options()->RunTesting && circ && @@ -995,8 +1014,6 @@ circuit_build_needed_circs(time_t now) } #endif } - if (!options->DisablePredictedCircuits) - circuit_predict_and_launch_new(); } /** If the stream <b>conn</b> is a member of any of the linked |