summaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-11-17 08:49:30 -0500
committerNick Mathewson <nickm@torproject.org>2015-11-17 09:04:25 -0500
commit84b3350c83a995a7668c16cb06ae069664dc0633 (patch)
treedb6fd22961f3b1a6239593b58cd5cb4ea7f1ee3e /src/or/connection_edge.c
parentb1d56fc5890fb6d594e70520c09d040e9b2e1544 (diff)
downloadtor-84b3350c83a995a7668c16cb06ae069664dc0633.tar.gz
tor-84b3350c83a995a7668c16cb06ae069664dc0633.zip
Be more conservative in scanning the list of pending streams
Now we only re-scan the list in the cases we did before: when we have a new circuit that we should try attaching to, or when we have added a new stream that we haven't tried to attach yet. This is part of 17590.
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index ce6bacefd3..20a27dc90c 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -512,6 +512,8 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
/* XXXXX Free this list on exit. */
static smartlist_t *pending_entry_connections = NULL;
+static int untried_pending_connections = 0;
+
/** Common code to connection_(ap|exit)_about_to_close. */
static void
connection_edge_about_to_close(edge_connection_t *edge_conn)
@@ -766,24 +768,31 @@ connection_ap_rescan_and_attach_pending(void)
"in pending_entry_connections, but wasn't. No worries; "
"adding it.",
pending_entry_connections);
+ untried_pending_connections = 1;
smartlist_add(pending_entry_connections, entry_conn);
}
} SMARTLIST_FOREACH_END(conn);
- connection_ap_attach_pending();
+ connection_ap_attach_pending(1);
}
/** Tell any AP streams that are listed as waiting for a new circuit to try
* again, either attaching to an available circ or launching a new one.
+ *
+ * If <b>retry</b> is false, only check the list if it contains at least one
+ * streams that we have not yet tried to attach to a circuit.
*/
void
-connection_ap_attach_pending(void)
+connection_ap_attach_pending(int retry)
{
if (PREDICT_UNLIKELY(!pending_entry_connections)) {
return;
}
+ if (untried_pending_connections == 0 && !retry)
+ return;
+
SMARTLIST_FOREACH_BEGIN(pending_entry_connections,
entry_connection_t *, entry_conn) {
connection_t *conn = ENTRY_TO_CONN(entry_conn);
@@ -811,6 +820,8 @@ connection_ap_attach_pending(void)
}
} SMARTLIST_FOREACH_END(entry_conn);
+
+ untried_pending_connections = 0;
}
/** Mark <b>entry_conn</b> as needing to get attached to a circuit.
@@ -838,6 +849,7 @@ connection_ap_mark_as_pending_circuit(entry_connection_t *entry_conn)
return;
}
+ untried_pending_connections = 1;
smartlist_add(pending_entry_connections, entry_conn);
}