]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Attach dummy resolve connections to a circuit *before* calling dns_resolve(). This...
authorNick Mathewson <nickm@torproject.org>
Tue, 21 Sep 2004 18:12:12 +0000 (18:12 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 21 Sep 2004 18:12:12 +0000 (18:12 +0000)
svn:r2360

src/or/connection_edge.c
src/or/dns.c

index e6b02257fde0ef404981cdcd4d3a2b1e159a607a..d1bf109f22d46b2c3d823d069879913145fdd91c 100644 (file)
@@ -855,19 +855,17 @@ int connection_exit_begin_resolve(cell_t *cell, circuit_t *circ) {
   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 3534de1b082a2640efc426051828f3784a427ac4..0e583c08448938baccd21fb6dbbee2ce6b8bb0d8 100644 (file)
@@ -225,6 +225,8 @@ int dns_resolve(connection_t *exitconn) {
           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;