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

[or-cvs] forward-port the logic skew and double-free thing



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

Modified Files:
	connection_edge.c directory.c dns.c 
Log Message:
forward-port the logic skew and double-free thing


Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -d -r1.272 -r1.273
--- connection_edge.c	1 Feb 2005 12:19:44 -0000	1.272
+++ connection_edge.c	4 Feb 2005 01:49:58 -0000	1.273
@@ -866,12 +866,7 @@
       connection_exit_connect(n_stream);
       return 0;
     case -1: /* resolve failed */
-      log_fn(LOG_INFO,"Resolve failed (%s).", n_stream->address);
-      if (!n_stream->marked_for_close) {
-        connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED,
-                            n_stream->cpath_layer);
-      }
-      connection_free(n_stream);
+      /* n_stream got freed. don't touch it. */
       break;
     case 0: /* resolve added to pending list */
       /* add it into the linked list of resolving_streams on this circuit */
@@ -916,8 +911,7 @@
   switch (dns_resolve(dummy_conn)) {
     case 1: /* The result was cached; a resolved cell was sent. */
     case -1:
-      circuit_detach_stream(circuit_get_by_conn(dummy_conn), dummy_conn);
-      connection_free(dummy_conn);
+      /* dummy_conn got freed, don't touch it */
       return 0;
     case 0: /* resolve added to pending list */
       assert_circuit_ok(circ);

Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -d -r1.208 -r1.209
--- directory.c	1 Feb 2005 00:37:16 -0000	1.208
+++ directory.c	4 Feb 2005 01:49:58 -0000	1.209
@@ -694,7 +694,7 @@
       tor_free(body); tor_free(headers);
       return -1;
     }
-    if (router_load_routerlist_from_directory(body, NULL, skewed, 0) < 0) {
+    if (router_load_routerlist_from_directory(body, NULL, !skewed, 0) < 0) {
       log_fn(LOG_NOTICE,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
     } else {
       log_fn(LOG_INFO,"updated routers.");

Index: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- dns.c	1 Feb 2005 00:37:16 -0000	1.133
+++ dns.c	4 Feb 2005 01:49:58 -0000	1.134
@@ -194,7 +194,7 @@
 
 /** See if we have a cache entry for <b>exitconn</b>-\>address. if so,
  * if resolve valid, put it into <b>exitconn</b>-\>addr and return 1.
- * If resolve failed, return -1.
+ * If resolve failed, unlink exitconn if needed, free it, and return -1.
  *
  * Else, if seen before and pending, add conn to the pending list,
  * and return 0.
@@ -207,6 +207,7 @@
   struct cached_resolve search;
   struct pending_connection_t *pending_connection;
   struct in_addr in;
+  circuit_t *circ;
   uint32_t now = time(NULL);
   assert_connection_ok(exitconn, 0);
   tor_assert(exitconn->s == -1);
@@ -250,6 +251,10 @@
                exitconn->s, exitconn->address);
         if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
           send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
+        circ = circuit_get_by_conn(exitconn);
+        if (circ)
+          circuit_detach_stream(circ, exitconn);
+        connection_free(exitconn);
         return -1;
     }
     tor_assert(0);
@@ -288,7 +293,7 @@
     log_fn(LOG_WARN,"no idle dns workers. Failing.");
     if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
       send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR_TRANSIENT);
-    dns_cancel_pending_resolve(exitconn->address); /* also sends end */
+    dns_cancel_pending_resolve(exitconn->address); /* also sends end and frees! */
     return -1;
   }