]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
More win32 fixes: 1) tolerate extra "readable" events better. 2) when being multithre...
authorNick Mathewson <nickm@torproject.org>
Mon, 6 Dec 2004 23:19:55 +0000 (23:19 +0000)
committerNick Mathewson <nickm@torproject.org>
Mon, 6 Dec 2004 23:19:55 +0000 (23:19 +0000)
svn:r3092

src/or/cpuworker.c
src/or/dns.c

index dbe0f74a3e46b7fc7665c6ab12c82a8d3a3eecb9..b1fef2660b511d5959000ad9e0bcac88d4663b15 100644 (file)
@@ -125,6 +125,9 @@ int connection_cpu_process_inbuf(connection_t *conn) {
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_CPUWORKER);
 
+  if (!buf_datalen(conn->inbuf))
+    return 0;
+
   if (conn->state == CPUWORKER_STATE_BUSY_ONION) {
     if (buf_datalen(conn->inbuf) < LEN_ONION_RESPONSE) /* entire answer available? */
       return 0; /* not yet */
@@ -206,9 +209,9 @@ static int cpuworker_main(void *data) {
   char tag[TAG_LEN];
   crypto_pk_env_t *onion_key = NULL, *last_onion_key = NULL;
 
-  tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */
   fd = fdarray[1]; /* this side is ours */
 #ifndef MS_WINDOWS
+  tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */
   connection_free_all(); /* so the child doesn't hold the parent's fd's open */
 #endif
   handle_signals(0); /* ignore interrupts from the keyboard, etc */
index 7fb7f6b5032e2f88f99be2446663c8fb26fcaae0..e9f3eb93dffe7cac5dbdac161b747aa27ef3994a 100644 (file)
@@ -581,8 +581,8 @@ int connection_dns_process_inbuf(connection_t *conn) {
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_DNSWORKER);
 
-  if (conn->state != DNSWORKER_STATE_BUSY) {
-    log_fn(LOG_WARN,"Bug: poll() indicated than an idle dns worker was readable. Please report.");
+  if (conn->state != DNSWORKER_STATE_BUSY && buf_datalen(conn->inbuf)) {
+    log_fn(LOG_WARN,"Bug: read data from an idle dns worker.  Please report.");
     return 0;
   }
   if (buf_datalen(conn->inbuf) < 5) /* entire answer available? */
@@ -653,9 +653,9 @@ static int dnsworker_main(void *data) {
   int fd;
   int result;
 
-  tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */
   fd = fdarray[1]; /* this side is ours */
 #ifndef MS_WINDOWS
+  tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */
   connection_free_all(); /* so the child doesn't hold the parent's fd's open */
 #endif
   handle_signals(0); /* ignore interrupts from the keyboard, etc */