This fixes a couple problems when exiting due to signal:

 * connection threads exit without closing client socket
   (so client blocks waiting for response that never comes)

 * listen_queue_thread blocks on poll() until a new connection comes in
   (because no poll timeout specified)

-- 
 kevin brintnall =~ /[EMAIL PROTECTED]/

-----------------------------------------------------------------

diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index 436d0a0..6ac624b 100644
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
@@ -1479,12 +1479,11 @@ static void *connection_thread_main (void *args) /* {{{ 
*/
 
     status = handle_request (fd, buffer, /*buffer_size=*/ status);
     if (status != 0)
-    {
-      close (fd);
       break;
-    }
   }
 
+  close(fd);
+
   self = pthread_self ();
   /* Remove this thread from the connection threads list */
   pthread_mutex_lock (&connection_threads_lock);
@@ -1710,8 +1709,12 @@ static void *listen_thread_main (void *args 
__attribute__((unused))) /* {{{ */
       pollfds[i].revents = 0;
     }
 
-    status = poll (pollfds, pollfds_num, /* timeout = */ -1);
-    if (status < 1)
+    status = poll (pollfds, pollfds_num, /* timeout = */ 1000);
+    if (status == 0)
+    {
+      continue; /* timeout */
+    }
+    else if (status < 0)
     {
       status = errno;
       if (status != EINTR)

_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

Reply via email to