[or-cvs] Fix assertion failure spotted by arma.

Nick Mathewson nickm at seul.org
Tue Mar 2 07:24:13 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv6060/src/or

Modified Files:
	connection.c connection_edge.c or.h 
Log Message:
Fix assertion failure spotted by arma.

Apparently, when a DNS failure was already cached, then when we tried
to mark the exit connection as closed, we'd try to remove it from the
pending queue anyway, and hit an assert.  Now, we put failed-resolve
connections in a separate state so that mark_for_close does the right
thing.



Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- connection.c	29 Feb 2004 00:11:37 -0000	1.167
+++ connection.c	2 Mar 2004 07:24:11 -0000	1.168
@@ -37,16 +37,18 @@
   { "",                          /* exit, 0 */
     "waiting for dest info",           /* 1 */
     "connecting",                      /* 2 */
-    "open" },                          /* 3 */
+    "open"                             /* 3 */
+    "resolve failed" },                /* 4 */
   { "ready" }, /* app listener, 0 */
   { "", /* 0 */
     "", /* 1 */
     "", /* 2 */
     "", /* 3 */
-    "awaiting dest info",         /* app, 4 */
-    "waiting for safe circuit",        /* 5 */
-    "waiting for connected",           /* 6 */
-    "open" },                          /* 7 */
+    "", /* 4 */
+    "awaiting dest info",         /* app, 5 */
+    "waiting for safe circuit",        /* 6 */
+    "waiting for connected",           /* 7 */
+    "open" },                          /* 8 */
   { "ready" }, /* dir listener, 0 */
   { "",                           /* dir, 0 */
     "connecting (fetch)",              /* 1 */

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- connection_edge.c	1 Mar 2004 12:37:45 -0000	1.106
+++ connection_edge.c	2 Mar 2004 07:24:11 -0000	1.107
@@ -867,15 +867,13 @@
       return 0;
     case -1: /* resolve failed */
       log_fn(LOG_INFO,"Resolve failed (%s).", n_stream->address);
+      /* Set the state so that we don't try to remove n_stream from a DNS
+       * pending list. */
+      n_stream->state = EXIT_CONN_STATE_RESOLVEFAILED; 
       connection_mark_for_close(n_stream, END_STREAM_REASON_RESOLVEFAILED);
-/* XXX BUG: we're in state RESOLVING here, but we haven't been added to the
- * 'pending' list, because the dns lookup was already cached as failed.
- * But the mark_for_close will try to remove us from the pending list,
- * and we'll trigger an assert (dns.c line 209).
- * Should we add another EXIT_CONN state? Should we put an exception
- * here? Or there?
- */
-    /* case 0, resolve added to pending list */
+      break;
+    case 0: /* resolve added to pending list */
+      ;
   }
   return 0;
 }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- or.h	29 Feb 2004 00:11:37 -0000	1.238
+++ or.h	2 Mar 2004 07:24:11 -0000	1.239
@@ -148,19 +148,20 @@
 #define EXIT_CONN_STATE_RESOLVING 1 /* waiting for response from dns farm */
 #define EXIT_CONN_STATE_CONNECTING 2 /* waiting for connect() to finish */
 #define EXIT_CONN_STATE_OPEN 3
-#define _EXIT_CONN_STATE_MAX 3
+#define EXIT_CONN_STATE_RESOLVEFAILED 4 /* waiting to be remoed*/
+#define _EXIT_CONN_STATE_MAX 4
 #if 0
 #define EXIT_CONN_STATE_CLOSE 3 /* flushing the buffer, then will close */
 #define EXIT_CONN_STATE_CLOSE_WAIT 4 /* have sent a destroy, awaiting a confirmation */
 #endif
 
 /* the AP state values must be disjoint from the EXIT state values */
-#define _AP_CONN_STATE_MIN 4
-#define AP_CONN_STATE_SOCKS_WAIT 4
-#define AP_CONN_STATE_CIRCUIT_WAIT 5
-#define AP_CONN_STATE_CONNECTING 6
-#define AP_CONN_STATE_OPEN 7
-#define _AP_CONN_STATE_MAX 7
+#define _AP_CONN_STATE_MIN 5
+#define AP_CONN_STATE_SOCKS_WAIT 5
+#define AP_CONN_STATE_CIRCUIT_WAIT 6
+#define AP_CONN_STATE_CONNECTING 7
+#define AP_CONN_STATE_OPEN 8
+#define _AP_CONN_STATE_MAX 8
 
 #define _DIR_CONN_STATE_MIN 1
 #define DIR_CONN_STATE_CONNECTING_FETCH 1



More information about the tor-commits mailing list