[or-cvs] Fix a symptom for a bug that straycat found.

Roger Dingledine arma at seul.org
Wed Aug 25 05:26:11 UTC 2004


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

Modified Files:
	dns.c 
Log Message:
Fix a symptom for a bug that straycat found.
Apparently in rare cases poll() is returning POLLIN for an idle
dns worker. It reads no bytes, presumably because the idle dns
worker didn't write anything in the first place. Gosh, who knows.

Now we only trigger the assert if the idle dns worker actually
tries to send an answer to us.


Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- dns.c	8 Aug 2004 07:25:45 -0000	1.105
+++ dns.c	25 Aug 2004 05:26:09 -0000	1.106
@@ -568,9 +568,13 @@
     return 0;
   }
 
-  tor_assert(conn->state == DNSWORKER_STATE_BUSY);
+  if(conn->state != DNSWORKER_STATE_BUSY) {
+    log_fn(LOG_WARN,"Bug: poll() indicated than an idle dns worker was readable. Please report.");
+    return 0;
+  }
   if(buf_datalen(conn->inbuf) < 5) /* entire answer available? */
     return 0; /* not yet */
+  tor_assert(conn->state == DNSWORKER_STATE_BUSY);
   tor_assert(buf_datalen(conn->inbuf) == 5);
 
   connection_fetch_from_buf(&success,1,conn);
@@ -646,7 +650,7 @@
   for(;;) {
 
     if(recv(fd, &address_len, 1, 0) != 1) {
-      log_fn(LOG_INFO,"dnsworker exiting because tor process died.");
+      log_fn(LOG_INFO,"dnsworker exiting because tor process closed connection (either pruned idle dnsworker or died).");
       spawn_exit();
     }
 



More information about the tor-commits mailing list