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

[or-cvs] r9522: Backport fix for bug 386: fix a rare assertion failure. (in tor/branches/tor-0_1_1-patches: . src/or)



Author: nickm
Date: 2007-02-08 02:23:54 -0500 (Thu, 08 Feb 2007)
New Revision: 9522

Modified:
   tor/branches/tor-0_1_1-patches/
   tor/branches/tor-0_1_1-patches/ChangeLog
   tor/branches/tor-0_1_1-patches/src/or/circuitbuild.c
Log:
 r11706@catbus:  nickm | 2007-02-08 02:23:32 -0500
 Backport fix for bug 386: fix a rare assertion failure.



Property changes on: tor/branches/tor-0_1_1-patches
___________________________________________________________________
 svk:merge ticket from /tor/011 [r11706] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/branches/tor-0_1_1-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_1_1-patches/ChangeLog	2007-02-08 07:23:50 UTC (rev 9521)
+++ tor/branches/tor-0_1_1-patches/ChangeLog	2007-02-08 07:23:54 UTC (rev 9522)
@@ -6,6 +6,8 @@
       of descriptors we don't need.
     - Do not log IPs with TLS failures for incoming TLS connections.  (Fixes
       bug 382.)
+    - Refactor the way we handle pending circuits when an OR connection
+      completes or fails, to fix a rare crash bug.
 
 
 Changes in version 0.1.1.26 - 2006-12-14

Modified: tor/branches/tor-0_1_1-patches/src/or/circuitbuild.c
===================================================================
--- tor/branches/tor-0_1_1-patches/src/or/circuitbuild.c	2007-02-08 07:23:50 UTC (rev 9521)
+++ tor/branches/tor-0_1_1-patches/src/or/circuitbuild.c	2007-02-08 07:23:54 UTC (rev 9522)
@@ -406,6 +406,7 @@
 {
   extern smartlist_t *circuits_pending_or_conns;
   smartlist_t *changed_circs;
+  smartlist_t *pending_circs;
 
   log_debug(LD_CIRC,"or_conn to %s, status=%d",
             or_conn->nickname ? or_conn->nickname : "NULL", status);
@@ -413,6 +414,7 @@
   if (!circuits_pending_or_conns)
     return;
 
+  pending_circs = smartlist_create();
   changed_circs = smartlist_create();
 
   SMARTLIST_FOREACH(circuits_pending_or_conns, circuit_t *, circ,
@@ -423,6 +425,21 @@
     if (!circ->n_conn &&
         !memcmp(or_conn->identity_digest, circ->n_conn_id_digest,
                 DIGEST_LEN)) {
+      smartlist_add(pending_circs, circ);
+    }
+  });
+
+  SMARTLIST_FOREACH(pending_circs, circuit_t *, circ,
+    {
+      if (circ->marked_for_close)
+        continue;
+      if (circ->state != CIRCUIT_STATE_OR_WAIT)
+        continue;
+      if (! (!circ->n_conn &&
+             !memcmp(or_conn->identity_digest, circ->n_conn_id_digest,
+                     DIGEST_LEN)))
+        continue;
+
       if (!status) { /* or_conn failed; close circ */
         log_info(LD_CIRC,"or_conn failed. Closing circ.");
         circuit_mark_for_close(circ, END_CIRC_REASON_OR_CONN_CLOSED);
@@ -457,12 +474,12 @@
          * circs to change their state when we're done. */
         smartlist_add(changed_circs, circ);
       }
-    }
   });
 
   SMARTLIST_FOREACH(changed_circs, circuit_t *, circ,
     circuit_set_state(circ, CIRCUIT_STATE_OPEN));
   smartlist_free(changed_circs);
+  smartlist_free(pending_circs);
 }
 
 /** Find a new circid that isn't currently in use on the circ->n_conn