aboutsummaryrefslogtreecommitdiff
path: root/src/or/dns.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-08-25 05:26:09 +0000
committerRoger Dingledine <arma@torproject.org>2004-08-25 05:26:09 +0000
commitbe7909f67000ac379839c4c204cb9b39f12402e7 (patch)
treeef834ba23a3e4e8627f602f4860c04bb8e1f37bf /src/or/dns.c
parentd91cacb8392dbea4dec69a48fbaf1fc9aa8a84dc (diff)
downloadtor-be7909f67000ac379839c4c204cb9b39f12402e7.tar
tor-be7909f67000ac379839c4c204cb9b39f12402e7.tar.gz
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. svn:r2311
Diffstat (limited to 'src/or/dns.c')
-rw-r--r--src/or/dns.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index 6cbecc02b..a3244ad0b 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -568,9 +568,13 @@ int connection_dns_process_inbuf(connection_t *conn) {
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 @@ static int dnsworker_main(void *data) {
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();
}