diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-23 16:15:58 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-23 16:15:58 +0000 |
commit | 32d09c83915ca7cab0890cdc246fc3bd63a2a97b (patch) | |
tree | 468ef3a868c7d7bd9ef244280331f3bf602cba5e | |
parent | b3903cffea8d3b4fda1a41ce9fa36f23bdfa68fa (diff) | |
download | libmicrohttpd-32d09c83915ca7cab0890cdc246fc3bd63a2a97b.tar.gz libmicrohttpd-32d09c83915ca7cab0890cdc246fc3bd63a2a97b.zip |
MHD_quiesce_daemon(): notify other threads so listen socket FD
is removed from awaiting select() and poll().
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 19 |
2 files changed, 20 insertions, 3 deletions
@@ -1,3 +1,7 @@ | |||
1 | Sat Apr 23 15:39:38 CET 2016 | ||
2 | Notify other threads in MHD_quiesce_daemon() so listen socket FD | ||
3 | is removed from awaiting select() and poll(). -EG | ||
4 | |||
1 | Sat Apr 23 14:17:15 CET 2016 | 5 | Sat Apr 23 14:17:15 CET 2016 |
2 | Revert "shutdown trigger select" on Darwin. Fixed daemon shutdown | 6 | Revert "shutdown trigger select" on Darwin. Fixed daemon shutdown |
3 | on Darwin without "MHD_USE_PIPE_FOR_SHUTDOWN" option. -EG | 7 | on Darwin without "MHD_USE_PIPE_FOR_SHUTDOWN" option. -EG |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 42b07c5e..091dff52 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -3105,9 +3105,9 @@ MHD_start_daemon (unsigned int flags, | |||
3105 | * clients to continue processing, but stops accepting new | 3105 | * clients to continue processing, but stops accepting new |
3106 | * connections. Note that the caller is responsible for closing the | 3106 | * connections. Note that the caller is responsible for closing the |
3107 | * returned socket; however, if MHD is run using threads (anything but | 3107 | * returned socket; however, if MHD is run using threads (anything but |
3108 | * external select mode), it must not be closed until AFTER | 3108 | * external select mode), socket will be removed from existing threads |
3109 | * #MHD_stop_daemon has been called (as it is theoretically possible | 3109 | * with some delay and it must not be closed while it's in use. To make |
3110 | * that an existing thread is still using it). | 3110 | * sure that socket is not used anymore, call #MHD_stop_daemon. |
3111 | * | 3111 | * |
3112 | * Note that some thread modes require the caller to have passed | 3112 | * Note that some thread modes require the caller to have passed |
3113 | * #MHD_USE_PIPE_FOR_SHUTDOWN when using this API. If this daemon is | 3113 | * #MHD_USE_PIPE_FOR_SHUTDOWN when using this API. If this daemon is |
@@ -3154,7 +3154,13 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
3154 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); | 3154 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); |
3155 | daemon->worker_pool[i].listen_socket_in_epoll = MHD_NO; | 3155 | daemon->worker_pool[i].listen_socket_in_epoll = MHD_NO; |
3156 | } | 3156 | } |
3157 | else | ||
3157 | #endif | 3158 | #endif |
3159 | if (MHD_INVALID_PIPE_ != daemon->worker_pool[i].wpipe[1]) | ||
3160 | { | ||
3161 | if (1 != MHD_pipe_write_ (daemon->worker_pool[i].wpipe[1], "q", 1)) | ||
3162 | MHD_PANIC ("failed to signal quiesce via pipe"); | ||
3163 | } | ||
3158 | } | 3164 | } |
3159 | daemon->socket_fd = MHD_INVALID_SOCKET; | 3165 | daemon->socket_fd = MHD_INVALID_SOCKET; |
3160 | #if EPOLL_SUPPORT | 3166 | #if EPOLL_SUPPORT |
@@ -3169,7 +3175,14 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) | |||
3169 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); | 3175 | MHD_PANIC ("Failed to remove listen FD from epoll set\n"); |
3170 | daemon->listen_socket_in_epoll = MHD_NO; | 3176 | daemon->listen_socket_in_epoll = MHD_NO; |
3171 | } | 3177 | } |
3178 | else | ||
3172 | #endif | 3179 | #endif |
3180 | if (MHD_INVALID_PIPE_ != daemon->wpipe[1]) | ||
3181 | { | ||
3182 | if (1 != MHD_pipe_write_ (daemon->wpipe[1], "q", 1)) | ||
3183 | MHD_PANIC ("failed to signal quiesce via pipe"); | ||
3184 | } | ||
3185 | |||
3173 | return ret; | 3186 | return ret; |
3174 | } | 3187 | } |
3175 | 3188 | ||