[or-cvs] Attach dummy resolve connections to a circuit *before* call...

Nick Mathewson nickm at seul.org
Tue Sep 21 18:12:15 UTC 2004


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

Modified Files:
	connection_edge.c dns.c 
Log Message:
Attach dummy resolve connections to a circuit *before* calling dns_resolve().  This fixes a bug where cached answers would never be sent in RESOLVED cells.

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- connection_edge.c	15 Aug 2004 20:05:35 -0000	1.207
+++ connection_edge.c	21 Sep 2004 18:12:12 -0000	1.208
@@ -855,19 +855,17 @@
   dummy_conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
   dummy_conn->purpose = EXIT_PURPOSE_RESOLVE;
 
+  dummy_conn->next_stream = circ->resolving_streams;
+  circ->resolving_streams = dummy_conn;
+
   /* send it off to the gethostbyname farm */
   switch(dns_resolve(dummy_conn)) {
-    case 1: /* resolve worked; resolved cell was sent. */
+    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);
       return 0;
-    case -1: /* resolve failed; resolved cell was sent. */
-      log_fn(LOG_INFO,"Resolve failed (%s).",dummy_conn->address);
-      connection_free(dummy_conn);
-      break;
     case 0: /* resolve added to pending list */
-      /* add it into the linked list of resolving_streams on this circuit */
-      dummy_conn->next_stream = circ->resolving_streams;
-      circ->resolving_streams = dummy_conn;
       assert_circuit_ok(circ);
       ;
   }

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- dns.c	21 Sep 2004 17:33:05 -0000	1.108
+++ dns.c	21 Sep 2004 18:12:12 -0000	1.109
@@ -225,6 +225,8 @@
           send_resolved_cell(exitconn, RESOLVED_TYPE_IPV4);
         return 1;
       case CACHE_STATE_FAILED:
+        log_fn(LOG_DEBUG,"Connection (fd %d) found cached error for '%s'",
+               exitconn->s, exitconn->address);
         if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
           send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
         return -1;



More information about the tor-commits mailing list