libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9
parent 74e0a68567054b20e24ea79fecf1ccf2940fda9b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 26 Nov 2013 00:28:14 +0000

-fix shutdown race for wpipe on non-Linux systems

Diffstat:
MChangeLog | 4++++
Msrc/microhttpd/daemon.c | 9+++++++--
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Tue Nov 26 01:26:15 CET 2013 + Fix race on shutdown signal with thread pool on non-Linux + systems by signalling n times for n threads. -CG + Sun Nov 24 13:41:15 CET 2013 Introduce state to mark connections in suspended state (with epoll); add missing locking operations in MHD_suspend_connection. diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -1894,7 +1894,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *except_fd_set) { int ds; - int tmp; + char tmp; struct MHD_Connection *pos; struct MHD_Connection *next; @@ -3812,7 +3812,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) if (-1 != daemon->wpipe[1]) { if (1 != WRITE (daemon->wpipe[1], "e", 1)) - MHD_PANIC ("failed to signal shutdownn via pipe"); + MHD_PANIC ("failed to signal shutdown via pipe"); } #ifdef HAVE_LISTEN_SHUTDOWN else @@ -3842,6 +3842,11 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) /* MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */ for (i = 0; i < daemon->worker_pool_size; ++i) { + if (-1 != daemon->wpipe[1]) + { + if (1 != WRITE (daemon->wpipe[1], "e", 1)) + MHD_PANIC ("failed to signal shutdown via pipe"); + } if (0 != (rc = pthread_join (daemon->worker_pool[i].pid, &unused))) MHD_PANIC ("Failed to join a thread\n"); close_all_connections (&daemon->worker_pool[i]);