[or-cvs] r10592: Add dnsport connection to the global connection list. (Bug f (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Wed Jun 13 19:50:18 UTC 2007


Author: nickm
Date: 2007-06-13 15:50:18 -0400 (Wed, 13 Jun 2007)
New Revision: 10592

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dnsserv.c
   tor/trunk/src/or/main.c
Log:
 r13401 at catbus:  nickm | 2007-06-13 15:50:16 -0400
 Add dnsport connection to the global connection list. (Bug found by mwenge.)



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13401] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-06-13 19:17:46 UTC (rev 10591)
+++ tor/trunk/ChangeLog	2007-06-13 19:50:18 UTC (rev 10592)
@@ -25,6 +25,9 @@
   o Minor bugfixes (dns):
     - Fix a crash when DNSPort is set more than once. (Patch from Robert
       Hogan.) [Bugfix on 0.2.0.2-alpha]
+    - Add DNSPort connections to the global connection list, so that we
+      can time them out correctly. (Bug found by mwenge) [Bugfix on
+      0.2.0.2-alpha]
 
   o Minor bugfixes (hidden services):
     - Stop tearing down the whole circuit when the user asks for a

Modified: tor/trunk/src/or/dnsserv.c
===================================================================
--- tor/trunk/src/or/dnsserv.c	2007-06-13 19:17:46 UTC (rev 10591)
+++ tor/trunk/src/or/dnsserv.c	2007-06-13 19:50:18 UTC (rev 10592)
@@ -122,6 +122,8 @@
 
   conn->dns_server_request = req;
 
+  connection_add(TO_CONN(conn));
+
   /* Now, throw the connection over to get rewritten (which will answer it
   * immediately if it's in the cache, or completely bogus, or automapped),
   * and then attached to a circuit. */

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-06-13 19:17:46 UTC (rev 10591)
+++ tor/trunk/src/or/main.c	2007-06-13 19:50:18 UTC (rev 10592)
@@ -162,18 +162,23 @@
 connection_add(connection_t *conn)
 {
   tor_assert(conn);
-  tor_assert(conn->s >= 0 || conn->linked);
+  tor_assert(conn->s >= 0 ||
+             conn->linked ||
+             (conn->type == CONN_TYPE_AP &&
+              TO_EDGE_CONN(conn)->dns_server_request));
 
   tor_assert(conn->conn_array_index == -1); /* can only connection_add once */
   conn->conn_array_index = smartlist_len(connection_array);
   smartlist_add(connection_array, conn);
 
-  conn->read_event = tor_malloc_zero(sizeof(struct event));
-  conn->write_event = tor_malloc_zero(sizeof(struct event));
-  event_set(conn->read_event, conn->s, EV_READ|EV_PERSIST,
-            conn_read_callback, conn);
-  event_set(conn->write_event, conn->s, EV_WRITE|EV_PERSIST,
-            conn_write_callback, conn);
+  if (conn->s >= 0) {
+    conn->read_event = tor_malloc_zero(sizeof(struct event));
+    conn->write_event = tor_malloc_zero(sizeof(struct event));
+    event_set(conn->read_event, conn->s, EV_READ|EV_PERSIST,
+              conn_read_callback, conn);
+    event_set(conn->write_event, conn->s, EV_WRITE|EV_PERSIST,
+              conn_write_callback, conn);
+  }
 
   log_debug(LD_NET,"new conn type %s, socket %d, n_conns %d.",
             conn_type_to_string(conn->type), conn->s,



More information about the tor-commits mailing list