[Top][All Lists]

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

[GNUnet-SVN] r35728 - in libmicrohttpd: . src/include src/microhttpd

From: gnunet
Subject: [GNUnet-SVN] r35728 - in libmicrohttpd: . src/include src/microhttpd
Date: Wed, 13 May 2015 11:35:33 +0200

Author: grothoff
Date: 2015-05-13 11:35:33 +0200 (Wed, 13 May 2015)
New Revision: 35728

>From ML:


I'm debugging a problem with a crash in MHD_select_thread.  We had
MHD_start_daemon_va fail while creating worker threads with the following
error: "file descriptor for worker control pipe exceeds maximum value".  We
know what caused this error and are fixing it.  But the problem was that a
MHD_select_thread worker thread was left running in the background after
MHD_start_daemon_va returned failure.  I think the problem is from this
code in the thread_failed case in daemon.c:

  /* Shutdown worker threads we've already created. Pretend
     as though we had fully initialized our daemon, but
     with a smaller number of threads than had been
     requested. */
  daemon->worker_pool_size = i - 1;
  MHD_stop_daemon (daemon);
  return NULL;

>From the code, it looks like "i" is actually the number of threads that
were successfully created, so the "i - 1" in this code will leave an extra
thread hanging since MHD_stop_daemon will clean up one less thread than it
should.  I'll probably try to work up a test to verify removing the "- 1"
is correct, but that could take me some time so I wanted to make sure I
wasn't missing something obvious before heading down that path.


He is right, this patch fixes it.

Modified: libmicrohttpd/ChangeLog
--- libmicrohttpd/ChangeLog     2015-05-07 18:20:38 UTC (rev 35727)
+++ libmicrohttpd/ChangeLog     2015-05-13 09:35:33 UTC (rev 35728)
@@ -1,3 +1,8 @@
+Wed May 13 11:33:59 CEST 2015
+       Fix off-by-one in MHD_start_daemon_va() error handling logic
+       when initialization of threads for thread pool fails for some
+       reason. -CG/JC
 Thu May  7 17:05:46 CEST 2015
        Add support for poll() in W32. -EG

Modified: libmicrohttpd/src/include/microhttpd.h
--- libmicrohttpd/src/include/microhttpd.h      2015-05-07 18:20:38 UTC (rev 
+++ libmicrohttpd/src/include/microhttpd.h      2015-05-13 09:35:33 UTC (rev 
@@ -130,7 +130,7 @@
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
-#define MHD_VERSION 0x00094102
+#define MHD_VERSION 0x00094103
  * MHD-internal return code for "YES".

Modified: libmicrohttpd/src/microhttpd/daemon.c
--- libmicrohttpd/src/microhttpd/daemon.c       2015-05-07 18:20:38 UTC (rev 
+++ libmicrohttpd/src/microhttpd/daemon.c       2015-05-13 09:35:33 UTC (rev 
@@ -4265,7 +4265,7 @@
      as though we had fully initialized our daemon, but
      with a smaller number of threads than had been
      requested. */
-  daemon->worker_pool_size = i - 1;
+  daemon->worker_pool_size = i;
   MHD_stop_daemon (daemon);
   return NULL;

reply via email to

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