summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-10-15 18:52:06 +0000
committerRoger Dingledine <arma@torproject.org>2008-10-15 18:52:06 +0000
commitd06182f0bd1f4f5944d20f73a86143b7566ec8dd (patch)
tree2a067c3d1483690e185531d4a29f2cb34dc0fa47 /src/or/circuituse.c
parent4520500cde57f940b68138e3a771f989afe8d60c (diff)
downloadtor-d06182f0bd1f4f5944d20f73a86143b7566ec8dd.tar.gz
tor-d06182f0bd1f4f5944d20f73a86143b7566ec8dd.zip
add patch2 from proposal 155:
Launch a second client-side introduction circuit in parallel after a delay of 15 seconds (based on work by Christian Wilms). svn:r17108
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 7da5508880..3537a73876 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -194,6 +194,7 @@ circuit_get_best(edge_connection_t *conn, int must_be_open, uint8_t purpose,
{
circuit_t *circ, *best=NULL;
time_t now = time(NULL);
+ int intro_going_on_but_too_old = 0;
tor_assert(conn);
@@ -206,6 +207,16 @@ circuit_get_best(edge_connection_t *conn, int must_be_open, uint8_t purpose,
need_uptime,need_internal,now))
continue;
+/* XXX022 make this 15 be a function of circuit finishing times we've
+ * seen lately, a la Fallon Chen's GSoC work -RD */
+#define REND_PARALLEL_INTRO_DELAY 15
+ if (purpose == CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT &&
+ !must_be_open && circ->state != CIRCUIT_STATE_OPEN &&
+ circ->timestamp_created + REND_PARALLEL_INTRO_DELAY < now) {
+ intro_going_on_but_too_old = 1;
+ continue;
+ }
+
/* now this is an acceptable circ to hand back. but that doesn't
* mean it's the *best* circ to hand back. try to decide.
*/
@@ -213,6 +224,11 @@ circuit_get_best(edge_connection_t *conn, int must_be_open, uint8_t purpose,
best = circ;
}
+ if (!best && intro_going_on_but_too_old)
+ log_info(LD_REND|LD_CIRC, "There is an intro circuit being created "
+ "right now, but it has already taken quite a while. Starting "
+ "one in parallel.");
+
return best ? TO_ORIGIN_CIRCUIT(best) : NULL;
}
@@ -1448,12 +1464,27 @@ connection_ap_handshake_attach_circuit(edge_connection_t *conn)
if (retval > 0) {
/* one has already sent the intro. keep waiting. */
+ circuit_t *c = NULL;
tor_assert(introcirc);
log_info(LD_REND, "Intro circ %d present and awaiting ack (rend %d). "
"Stalling. (stream %d sec old)",
introcirc->_base.n_circ_id,
rendcirc ? rendcirc->_base.n_circ_id : 0,
conn_age);
+ /* abort parallel intro circs, if any */
+ for (c = global_circuitlist; c; c = c->next) {
+ if (c->purpose == CIRCUIT_PURPOSE_C_INTRODUCING &&
+ CIRCUIT_IS_ORIGIN(c)) {
+ origin_circuit_t *oc = TO_ORIGIN_CIRCUIT(c);
+ if (oc->rend_data &&
+ !rend_cmp_service_ids(conn->rend_data->onion_address,
+ oc->rend_data->onion_address)) {
+ log_info(LD_REND|LD_CIRC, "Closing introduction circuit that we "
+ "built in parallel.");
+ circuit_mark_for_close(c, END_CIRC_REASON_TIMEOUT);
+ }
+ }
+ }
return 0;
}