[or-cvs] add more debugging info to help us find the weird dns freeb...

Roger Dingledine arma at seul.org
Tue Apr 26 19:08:08 UTC 2005


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

Modified Files:
	dns.c 
Log Message:
add more debugging info to help us find the weird dns freebsd pthreads bug.


Index: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- dns.c	26 Apr 2005 18:52:15 -0000	1.148
+++ dns.c	26 Apr 2005 19:08:06 -0000	1.149
@@ -138,7 +138,7 @@
     resolve = oldest_cached_resolve;
     log(LOG_DEBUG,"Forgetting old cached resolve (expires %lu)", (unsigned long)resolve->expire);
     if (resolve->state == CACHE_STATE_PENDING) {
-      log_fn(LOG_WARN,"Bug: Expiring a dns resolve that's still pending. Forgot to cull it?");
+      log_fn(LOG_WARN,"Bug: Expiring a dns resolve ('%s') that's still pending. Forgot to cull it?", resolve->address);
       tor_fragile_assert();
     }
     if (resolve->pending_connections) {
@@ -631,8 +631,19 @@
   tor_assert(conn->type == CONN_TYPE_DNSWORKER);
 
   if (conn->state != DNSWORKER_STATE_BUSY && buf_datalen(conn->inbuf)) {
-    log_fn(LOG_WARN,"Bug: read data (%d bytes) from an idle dns worker (address '%s'.  Please report.", (int)buf_datalen(conn->inbuf), conn->address);
+    log_fn(LOG_WARN,"Bug: read data (%d bytes) from an idle dns worker (fd %d, address '%s'). Please report.",
+           (int)buf_datalen(conn->inbuf), conn->s, conn->address);
     tor_fragile_assert();
+
+    /* Pull it off the buffer anyway, or it will just stay there.
+     * Keep pulling things off because sometimes we get several
+     * answers at once (!). */
+    while (buf_datalen(conn->inbuf)) {
+      connection_fetch_from_buf(&success,1,conn);
+      connection_fetch_from_buf((char *)&addr,sizeof(uint32_t),conn);
+      log_fn(LOG_WARN,"Discarding idle dns answer (success %d, addr %d.)",
+             success, addr);
+    }
     return 0;
   }
   if (buf_datalen(conn->inbuf) < 5) /* entire answer available? */



More information about the tor-commits mailing list