summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2016-04-13 01:08:17 -0400
committerRoger Dingledine <arma@torproject.org>2016-05-09 14:40:42 -0400
commit91c58013be735584acc674a60bb18d1efb38f25a (patch)
tree4be1e3cce74c4fcf41f8cb4f7bf6858508abad7b /src/or/circuituse.c
parentce8266d52d296333eb1a735225e620760aab8802 (diff)
downloadtor-91c58013be735584acc674a60bb18d1efb38f25a.tar.gz
tor-91c58013be735584acc674a60bb18d1efb38f25a.zip
avoid following through on a consensus fetch if we have one already arriving
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 31003ea095..f32763ad9e 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -2355,6 +2355,25 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
/* we're a general conn */
origin_circuit_t *circ=NULL;
+ /* Are we linked to a dir conn that aims to fetch a consensus?
+ * We check here because this conn might no longer be needed. */
+ if (base_conn->linked_conn &&
+ base_conn->linked_conn->type == CONN_TYPE_DIR &&
+ base_conn->linked_conn->purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
+
+ /* Yes we are. Is there a consensus fetch farther along than us? */
+ if (networkstatus_consensus_is_already_downloading(
+ TO_DIR_CONN(base_conn->linked_conn)->requested_resource)) {
+ /* We're doing the "multiple consensus fetch attempts" game from
+ * proposal 210, and we're late to the party. Just close this conn.
+ * The circuit and TLS conn that we made will time out after a while
+ * if nothing else wants to use them. */
+ log_info(LD_DIR, "Closing extra consensus fetch (to %s) since one "
+ "is already downloading.", base_conn->linked_conn->address);
+ return -1;
+ }
+ }
+
if (conn->chosen_exit_name) {
const node_t *node = node_get_by_nickname(conn->chosen_exit_name, 1);
int opt = conn->chosen_exit_optional;