libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] [PATCH] Avoid silent misbehaviour on pthread join fa


From: Mike Crowe
Subject: Re: [libmicrohttpd] [PATCH] Avoid silent misbehaviour on pthread join failure
Date: Tue, 13 Oct 2009 15:48:20 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

I wrote:
>> Anyway, this patch means that libmicrohttpd should no longer continue
>> regardless. I've tried to follow the style of the existing code.

On Fri, Oct 09, 2009 at 03:24:48PM +0200, Christian Grothoff wrote:
> Makes sense.  I've fixed this in SVN HEAD, but with a slightly more verbose 
> report in case that --enable-messages was given to configure.

I've looked at the fix in SVN. Unfortunately pthread_join returns an
error rather than setting errno. :( This caused me confusion recently
too.

Here's a patch that fixes this. It passed 'make check' modulo the curl
error 66 put failures that seem to happen for me regardless:

Index: src/daemon/daemon.c
===================================================================
--- src/daemon/daemon.c (revision 9153)
+++ src/daemon/daemon.c (working copy)
@@ -778,12 +778,14 @@
             prev->next = pos->next;
           if (0 != (pos->daemon->options & MHD_USE_THREAD_PER_CONNECTION))
             {
+             int rc;
              pthread_kill (pos->pid, SIGALRM);
-              if (0 != pthread_join (pos->pid, &unused))
+             rc = pthread_join (pos->pid, &unused);
+              if (0 != rc)
                {
 #if HAVE_MESSAGES
                  MHD_DLOG (daemon, "Failed to join a thread: %s\n",
-                           STRERROR (errno));
+                           STRERROR (rc));
 #endif
                  abort();              
                }
@@ -1474,6 +1476,7 @@
 {
   void *unused;
   int fd;
+  int rc;
   unsigned int i;
 
   if (daemon == NULL)
@@ -1508,11 +1511,12 @@
     pthread_kill (daemon->worker_pool[i].pid, SIGALRM);
   for (i = 0; i < daemon->worker_pool_size; ++i)
     {
-      if (0 != pthread_join (daemon->worker_pool[i].pid, &unused))
+      rc = pthread_join (daemon->worker_pool[i].pid, &unused);
+      if (0 != rc)
        {
 #if HAVE_MESSAGES
          MHD_DLOG (daemon, "Failed to join a thread: %s\n",
-                   STRERROR (errno));
+                   STRERROR (rc));
 #endif
          abort();              
        }
@@ -1525,7 +1529,8 @@
         && (0 == daemon->worker_pool_size)))
     {
       pthread_kill (daemon->pid, SIGALRM);
-      if (0 != pthread_join (daemon->pid, &unused))
+      rc = pthread_join (daemon->pid, &unused);
+      if (0 != rc)
        {
 #if HAVE_MESSAGES
          MHD_DLOG (daemon, "Failed to join a thread: %s\n",

Thanks.

Mike.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]