Index: /home/karsten/tor/tor-trunk-155-patch2/ChangeLog =================================================================== --- /home/karsten/tor/tor-trunk-155-patch2/ChangeLog (revision 17050) +++ /home/karsten/tor/tor-trunk-155-patch2/ChangeLog (working copy) @@ -3,6 +3,8 @@ - Now NodeFamily and MyFamily config options allow spaces in identity fingerprints, so it's easier to paste them in. Suggested by Lucky Green. + - Start extending introduction circuits in parallel after a delay of + 15 seconds (based on work by Christian Wilms). Changes in version 0.2.1.6-alpha - 2008-09-30 Index: /home/karsten/tor/tor-trunk-155-patch2/src/or/circuituse.c =================================================================== --- /home/karsten/tor/tor-trunk-155-patch2/src/or/circuituse.c (revision 17050) +++ /home/karsten/tor/tor-trunk-155-patch2/src/or/circuituse.c (working copy) @@ -194,6 +194,7 @@ { circuit_t *circ, *best=NULL; time_t now = time(NULL); + int intro_going_on_but_too_old = 0; tor_assert(conn); @@ -202,9 +203,16 @@ purpose == CIRCUIT_PURPOSE_C_REND_JOINED); for (circ=global_circuitlist;circ;circ = circ->next) { +#define REND_PARALLEL_INTRO_DELAY 15 if (!circuit_is_acceptable(circ,conn,must_be_open,purpose, need_uptime,need_internal,now)) continue; + else 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 +221,10 @@ 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; } @@ -1436,6 +1448,7 @@ 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)", @@ -1442,6 +1455,20 @@ 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; }