[or-cvs] backport from pre3:

Roger Dingledine arma at seul.org
Wed Oct 13 22:02:33 UTC 2004


Update of /home2/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/0081/src/or

Modified Files:
      Tag: tor-0_0_8-patches
	circuituse.c 
Log Message:
backport from pre3:
sometimes circuit_get_open_circ_or_launch() can return 0 but not
return a circuit, e.g. because too many circuits have failed recently
so the new one didn't launch. we need to tolerate that.


Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/src/or/circuituse.c,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -u -d -r1.11.2.1 -r1.11.2.2
--- circuituse.c	13 Oct 2004 21:56:35 -0000	1.11.2.1
+++ circuituse.c	13 Oct 2004 22:02:31 -0000	1.11.2.2
@@ -776,6 +776,7 @@
       return retval;
 
     /* We have found a suitable circuit for our conn. Hurray. */
+    tor_assert(circ);
 
     log_fn(LOG_DEBUG,"Attaching apconn to general circ %d (stream %d sec old).",
            circ->n_circ_id, conn_age);
@@ -802,9 +803,9 @@
 
     retval = circuit_get_open_circ_or_launch(conn, CIRCUIT_PURPOSE_C_REND_JOINED, &rendcirc);
     if(retval < 0) return -1; /* failed */
-    tor_assert(rendcirc);
 
     if(retval > 0) {
+      tor_assert(rendcirc);
       /* one is already established, attach */
       log_fn(LOG_INFO,"rend joined circ %d already here. attaching. (stream %d sec old)",
              rendcirc->n_circ_id, conn_age);
@@ -814,7 +815,7 @@
       return 1;
     }
 
-    if(rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) {
+    if(rendcirc && rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) {
       log_fn(LOG_INFO,"pending-join circ %d already here, with intro ack. Stalling. (stream %d sec old)", rendcirc->n_circ_id, conn_age);
       return 0;
     }
@@ -822,21 +823,21 @@
     /* it's on its way. find an intro circ. */
     retval = circuit_get_open_circ_or_launch(conn, CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT, &introcirc);
     if(retval < 0) return -1; /* failed */
-    tor_assert(introcirc);
 
     if(retval > 0) {
+      tor_assert(introcirc);
       /* one has already sent the intro. keep waiting. */
       log_fn(LOG_INFO,"Intro circ %d present and awaiting ack (rend %d). Stalling. (stream %d sec old)",
-             introcirc->n_circ_id, rendcirc->n_circ_id, conn_age);
+             introcirc->n_circ_id, rendcirc ? rendcirc->n_circ_id : 0, conn_age);
       return 0;
     }
 
-    /* now both rendcirc and introcirc are defined, and neither is finished */
+    /* now rendcirc and introcirc are each either undefined or not finished */
 
-    if(rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY) {
+    if(rendcirc && introcirc && rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY) {
       log_fn(LOG_INFO,"ready rend circ %d already here (no intro-ack yet on intro %d). (stream %d sec old)",
-             rendcirc->n_circ_id, introcirc->n_circ_id, conn_age);
-      /* look around for any new intro circs that should introduce */
+                     introcirc ? introcirc->n_circ_id : 0,
+                     rendcirc ? rendcirc->n_circ_id : 0, conn_age);
 
       tor_assert(introcirc->purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
       if(introcirc->state == CIRCUIT_STATE_OPEN) {



More information about the tor-commits mailing list