[or-cvs] r16850: {tor} Start extending introduction circuits in parallel after a de (tor/branches/hidserv-design-changes/src/or)

kloesing at seul.org kloesing at seul.org
Thu Sep 11 17:03:46 UTC 2008


Author: kloesing
Date: 2008-09-11 13:03:45 -0400 (Thu, 11 Sep 2008)
New Revision: 16850

Modified:
   tor/branches/hidserv-design-changes/src/or/circuituse.c
Log:
Start extending introduction circuits in parallel after a delay of 15 seconds.

Modified: tor/branches/hidserv-design-changes/src/or/circuituse.c
===================================================================
--- tor/branches/hidserv-design-changes/src/or/circuituse.c	2008-09-11 16:56:47 UTC (rev 16849)
+++ tor/branches/hidserv-design-changes/src/or/circuituse.c	2008-09-11 17:03:45 UTC (rev 16850)
@@ -190,6 +190,7 @@
 {
   circuit_t *circ, *best=NULL;
   time_t now = time(NULL);
+  int intro_going_on_but_too_old = 0;
 
   tor_assert(conn);
 
@@ -198,9 +199,17 @@
              purpose == CIRCUIT_PURPOSE_C_REND_JOINED);
 
   for (circ=global_circuitlist;circ;circ = circ->next) {
+/* TODO debug value; change to 15 for release */
+#define REND_PARALLEL_INTRO_DELAY 5
     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.
@@ -209,6 +218,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;
 }
 
@@ -1425,12 +1438,24 @@
 
     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) && 
+            !rend_cmp_service_ids(conn->rend_query,
+                                 TO_ORIGIN_CIRCUIT(c)->rend_query)) {
+          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;
     }
 



More information about the tor-commits mailing list