[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17108: {tor} add patch2 from proposal 155: Launch a second client-side in (in tor/trunk: . src/or)



Author: arma
Date: 2008-10-15 14:52:06 -0400 (Wed, 15 Oct 2008)
New Revision: 17108

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuituse.c
Log:
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).


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-10-15 15:53:03 UTC (rev 17107)
+++ tor/trunk/ChangeLog	2008-10-15 18:52:06 UTC (rev 17108)
@@ -3,8 +3,10 @@
     - Now NodeFamily and MyFamily config options allow spaces in
       identity fingerprints, so it's easier to paste them in.
       Suggested by Lucky Green.
-    - Reduce extension timeout for introduction circuits from 60 to 30
-      seconds.
+    - Reduce extension timeout for introduction circuits on the hidden
+      service side from 60 to 30 seconds.
+    - Launch a second client-side introduction circuit in parallel
+      after a delay of 15 seconds (based on work by Christian Wilms).
 
   o Minor bugfixes:
     - Minor fix in the warning messages when you're having problems

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2008-10-15 15:53:03 UTC (rev 17107)
+++ tor/trunk/src/or/circuituse.c	2008-10-15 18:52:06 UTC (rev 17108)
@@ -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);
 
@@ -206,6 +207,16 @@
                                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 @@
       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 @@
 
     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;
     }