diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-26 00:28:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-26 00:28:14 +0000 |
commit | 8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9 (patch) | |
tree | 5a9a12ed3df2a61c7277de29326801177367f7c7 | |
parent | 74e0a68567054b20e24ea79fecf1ccf2940fda9b (diff) | |
download | libmicrohttpd-8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9.tar.gz libmicrohttpd-8ba82afc4b43f46cb8496ed1e1ab1d9e26abb8c9.zip |
-fix shutdown race for wpipe on non-Linux systems
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 9 |
2 files changed, 11 insertions, 2 deletions
@@ -1,3 +1,7 @@ | |||
1 | Tue Nov 26 01:26:15 CET 2013 | ||
2 | Fix race on shutdown signal with thread pool on non-Linux | ||
3 | systems by signalling n times for n threads. -CG | ||
4 | |||
1 | Sun Nov 24 13:41:15 CET 2013 | 5 | Sun Nov 24 13:41:15 CET 2013 |
2 | Introduce state to mark connections in suspended state (with | 6 | Introduce state to mark connections in suspended state (with |
3 | epoll); add missing locking operations in MHD_suspend_connection. | 7 | epoll); add missing locking operations in MHD_suspend_connection. |
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]); |