diff options
-rw-r--r-- | src/microhttpd/daemon.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index b433bff4..4ad9e458 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -7472,7 +7472,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) | |||
7472 | * if provided by application | 7472 | * if provided by application |
7473 | * @param[out] psockaddr_len the size memory area pointed by 'struct sockaddr' | 7473 | * @param[out] psockaddr_len the size memory area pointed by 'struct sockaddr' |
7474 | * if provided by application | 7474 | * if provided by application |
7475 | * @param[in] params the interim parameters to process | 7475 | * @param[in,out] params the interim parameters to process |
7476 | * @return true in case of success, | 7476 | * @return true in case of success, |
7477 | * false in case of critical error (the daemon must be closed). | 7477 | * false in case of critical error (the daemon must be closed). |
7478 | */ | 7478 | */ |
@@ -7596,7 +7596,11 @@ process_interim_params (struct MHD_Daemon *d, | |||
7596 | "specified for daemon with MHD_USE_NO_LISTEN_SOCKET " \ | 7596 | "specified for daemon with MHD_USE_NO_LISTEN_SOCKET " \ |
7597 | "flag set.\n")); | 7597 | "flag set.\n")); |
7598 | #endif /* HAVE_MESSAGES */ | 7598 | #endif /* HAVE_MESSAGES */ |
7599 | (void) MHD_socket_close_ (params->listen_fd); | 7599 | if (MHD_INVALID_SOCKET != d->listen_fd) |
7600 | { | ||
7601 | (void) MHD_socket_close_ (params->listen_fd); | ||
7602 | params->listen_fd = MHD_INVALID_SOCKET; | ||
7603 | } | ||
7600 | return false; | 7604 | return false; |
7601 | } | 7605 | } |
7602 | else | 7606 | else |
@@ -8301,11 +8305,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
8301 | #endif | 8305 | #endif |
8302 | } | 8306 | } |
8303 | #endif /* ! MHD_WINSOCK_SOCKETS */ | 8307 | #endif /* ! MHD_WINSOCK_SOCKETS */ |
8304 | /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. | 8308 | /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. |
8305 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. | 8309 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. |
8306 | */ | 8310 | */ |
8307 | /* SO_REUSEADDR on W32 has the same semantics | 8311 | /* SO_REUSEADDR on W32 has the same semantics |
8308 | as SO_REUSEPORT on BSD/Linux */ | 8312 | as SO_REUSEPORT on BSD/Linux */ |
8309 | #if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT) | 8313 | #if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT) |
8310 | if (0 > setsockopt (listen_fd, | 8314 | if (0 > setsockopt (listen_fd, |
8311 | SOL_SOCKET, | 8315 | SOL_SOCKET, |
@@ -8325,8 +8329,8 @@ MHD_start_daemon_va (unsigned int flags, | |||
8325 | goto free_and_fail; | 8329 | goto free_and_fail; |
8326 | } | 8330 | } |
8327 | #else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ | 8331 | #else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ |
8328 | /* we're supposed to allow address:port re-use, but | 8332 | /* we're supposed to allow address:port re-use, but |
8329 | on this platform we cannot; fail hard */ | 8333 | on this platform we cannot; fail hard */ |
8330 | #ifdef HAVE_MESSAGES | 8334 | #ifdef HAVE_MESSAGES |
8331 | MHD_DLOG (daemon, | 8335 | MHD_DLOG (daemon, |
8332 | _ ("Cannot allow listening address reuse: " \ | 8336 | _ ("Cannot allow listening address reuse: " \ |
@@ -9054,6 +9058,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
9054 | #ifdef MHD_USE_THREADS | 9058 | #ifdef MHD_USE_THREADS |
9055 | /* Remove externally added new connections that are | 9059 | /* Remove externally added new connections that are |
9056 | * not processed by the daemon thread. */ | 9060 | * not processed by the daemon thread. */ |
9061 | MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); | ||
9057 | while (NULL != (pos = daemon->new_connections_tail)) | 9062 | while (NULL != (pos = daemon->new_connections_tail)) |
9058 | { | 9063 | { |
9059 | mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); | 9064 | mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); |
@@ -9062,6 +9067,7 @@ close_all_connections (struct MHD_Daemon *daemon) | |||
9062 | pos); | 9067 | pos); |
9063 | new_connection_close_ (daemon, pos); | 9068 | new_connection_close_ (daemon, pos); |
9064 | } | 9069 | } |
9070 | MHD_mutex_unlock_chk_ (&daemon->new_connections_mutex); | ||
9065 | #endif /* MHD_USE_THREADS */ | 9071 | #endif /* MHD_USE_THREADS */ |
9066 | 9072 | ||
9067 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) | 9073 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) |