aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-26 00:28:14 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-26 00:28:14 +0000
commit8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9 (patch)
tree5a9a12ed3df2a61c7277de29326801177367f7c7 /src/microhttpd/daemon.c
parent74e0a68567054b20e24ea79fecf1ccf2940fda9b (diff)
downloadlibmicrohttpd-8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9.tar.gz
libmicrohttpd-8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9.zip
-fix shutdown race for wpipe on non-Linux systems
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 219e822f..ac0299b9 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1894,7 +1894,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
1894 const fd_set *except_fd_set) 1894 const fd_set *except_fd_set)
1895{ 1895{
1896 int ds; 1896 int ds;
1897 int tmp; 1897 char tmp;
1898 struct MHD_Connection *pos; 1898 struct MHD_Connection *pos;
1899 struct MHD_Connection *next; 1899 struct MHD_Connection *next;
1900 1900
@@ -3812,7 +3812,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3812 if (-1 != daemon->wpipe[1]) 3812 if (-1 != daemon->wpipe[1])
3813 { 3813 {
3814 if (1 != WRITE (daemon->wpipe[1], "e", 1)) 3814 if (1 != WRITE (daemon->wpipe[1], "e", 1))
3815 MHD_PANIC ("failed to signal shutdownn via pipe"); 3815 MHD_PANIC ("failed to signal shutdown via pipe");
3816 } 3816 }
3817#ifdef HAVE_LISTEN_SHUTDOWN 3817#ifdef HAVE_LISTEN_SHUTDOWN
3818 else 3818 else
@@ -3842,6 +3842,11 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3842 /* MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */ 3842 /* MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */
3843 for (i = 0; i < daemon->worker_pool_size; ++i) 3843 for (i = 0; i < daemon->worker_pool_size; ++i)
3844 { 3844 {
3845 if (-1 != daemon->wpipe[1])
3846 {
3847 if (1 != WRITE (daemon->wpipe[1], "e", 1))
3848 MHD_PANIC ("failed to signal shutdown via pipe");
3849 }
3845 if (0 != (rc = pthread_join (daemon->worker_pool[i].pid, &unused))) 3850 if (0 != (rc = pthread_join (daemon->worker_pool[i].pid, &unused)))
3846 MHD_PANIC ("Failed to join a thread\n"); 3851 MHD_PANIC ("Failed to join a thread\n");
3847 close_all_connections (&daemon->worker_pool[i]); 3852 close_all_connections (&daemon->worker_pool[i]);