summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-07-16 10:01:56 +0200
committerNick Mathewson <nickm@torproject.org>2014-07-16 10:01:56 +0200
commit856114ab1c5a8a7a1b7993ee34adbb7cbf4eaa10 (patch)
tree49e3514ff0e2aa892c172bf5d522a2ed15c75c05
parent35791f4238bd6853c038d5fc68976dd74c93c577 (diff)
parented3d7892c721c9495215ecad2e18c026d29fbb9b (diff)
downloadtor-856114ab1c5a8a7a1b7993ee34adbb7cbf4eaa10.tar.gz
tor-856114ab1c5a8a7a1b7993ee34adbb7cbf4eaa10.zip
Merge remote-tracking branch 'public/bug8387_024' into maint-0.2.5
-rw-r--r--changes/bug838711
-rw-r--r--src/or/circuituse.c27
-rw-r--r--src/or/circuituse.h1
-rw-r--r--src/or/main.c5
4 files changed, 38 insertions, 6 deletions
diff --git a/changes/bug8387 b/changes/bug8387
new file mode 100644
index 0000000000..2ec0487bf8
--- /dev/null
+++ b/changes/bug8387
@@ -0,0 +1,11 @@
+ o Major bugfixes (client):
+
+ - Perform circuit cleanup operations even when circuit
+ construction operations are disabled (because the network is
+ disabled, or because there isn't enough directory information).
+ Previously, when we were not building predictive circuits, we
+ were not closing expired circuits either.
+
+ Fixes bug 8387; bugfix on 0.1.1.11-alpha. This bug became visible
+ in 0.2.4.10-alpha when we became more strict about when we have
+ "enough directory information to build circuits".
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 221afea912..600aede233 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1089,7 +1089,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 */
@@ -1098,14 +1097,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 &&
@@ -1115,8 +1134,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
diff --git a/src/or/circuituse.h b/src/or/circuituse.h
index f228a67585..4c5977bee0 100644
--- a/src/or/circuituse.h
+++ b/src/or/circuituse.h
@@ -22,6 +22,7 @@ int circuit_conforms_to_options(const origin_circuit_t *circ,
const or_options_t *options);
#endif
void circuit_build_needed_circs(time_t now);
+void circuit_expire_old_circs_as_needed(time_t now);
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
void circuit_expire_old_circuits_serverside(time_t now);
diff --git a/src/or/main.c b/src/or/main.c
index 1c49ba1482..9c1cabf037 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1512,8 +1512,11 @@ run_scheduled_events(time_t now)
* and we make a new circ if there are no clean circuits.
*/
have_dir_info = router_have_minimum_dir_info();
- if (have_dir_info && !net_is_disabled())
+ if (have_dir_info && !net_is_disabled()) {
circuit_build_needed_circs(now);
+ } else {
+ circuit_expire_old_circs_as_needed(now);
+ }
/* every 10 seconds, but not at the same second as other such events */
if (now % 10 == 5)