aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index ce14a944..231ac57f 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -6954,42 +6954,49 @@ MHD_start_daemon_va (unsigned int flags,
6954 } 6954 }
6955 } 6955 }
6956#endif /* HAVE_GETSOCKNAME */ 6956#endif /* HAVE_GETSOCKNAME */
6957 if ( (MHD_INVALID_SOCKET != listen_fd) && 6957
6958 (! MHD_socket_nonblocking_ (listen_fd)) ) 6958 if (MHD_INVALID_SOCKET != listen_fd)
6959 { 6959 {
6960 if (! MHD_socket_nonblocking_ (listen_fd))
6961 {
6960#ifdef HAVE_MESSAGES 6962#ifdef HAVE_MESSAGES
6961 MHD_DLOG (daemon, 6963 MHD_DLOG (daemon,
6962 _ ("Failed to set nonblocking mode on listening socket: %s\n"), 6964 _ ("Failed to set nonblocking mode on listening socket: %s\n"),
6963 MHD_socket_last_strerr_ ()); 6965 MHD_socket_last_strerr_ ());
6964#endif 6966#endif
6965 if (0 != (*pflags & MHD_USE_EPOLL) 6967 if (0 != (*pflags & MHD_USE_EPOLL)
6966#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 6968#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6967 || (daemon->worker_pool_size > 0) 6969 || (daemon->worker_pool_size > 0)
6968#endif 6970#endif
6969 ) 6971 )
6972 {
6973 /* Accept must be non-blocking. Multiple children may wake up
6974 * to handle a new connection, but only one will win the race.
6975 * The others must immediately return. */
6976 MHD_socket_close_chk_ (listen_fd);
6977 goto free_and_fail;
6978 }
6979 daemon->listen_nonblk = false;
6980 }
6981 else
6982 daemon->listen_nonblk = true;
6983 if ( (! MHD_SCKT_FD_FITS_FDSET_ (listen_fd,
6984 NULL)) &&
6985 (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) )
6970 { 6986 {
6971 /* Accept must be non-blocking. Multiple children may wake up 6987#ifdef HAVE_MESSAGES
6972 * to handle a new connection, but only one will win the race. 6988 MHD_DLOG (daemon,
6973 * The others must immediately return. */ 6989 _ ("Listen socket descriptor (%d) is not " \
6990 "less than FD_SETSIZE (%d).\n"),
6991 (int) listen_fd,
6992 (int) FD_SETSIZE);
6993#endif
6974 MHD_socket_close_chk_ (listen_fd); 6994 MHD_socket_close_chk_ (listen_fd);
6975 goto free_and_fail; 6995 goto free_and_fail;
6976 } 6996 }
6977 } 6997 }
6978 if ( (MHD_INVALID_SOCKET != listen_fd) && 6998 else
6979 (! MHD_SCKT_FD_FITS_FDSET_ (listen_fd, 6999 daemon->listen_nonblk = false; /* Actually listen socket does not exist */
6980 NULL)) &&
6981 (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) )
6982 {
6983#ifdef HAVE_MESSAGES
6984 MHD_DLOG (daemon,
6985 _ ("Listen socket descriptor (%d) is not " \
6986 "less than FD_SETSIZE (%d).\n"),
6987 (int) listen_fd,
6988 (int) FD_SETSIZE);
6989#endif
6990 MHD_socket_close_chk_ (listen_fd);
6991 goto free_and_fail;
6992 }
6993 7000
6994#ifdef EPOLL_SUPPORT 7001#ifdef EPOLL_SUPPORT
6995 if ( (0 != (*pflags & MHD_USE_EPOLL)) 7002 if ( (0 != (*pflags & MHD_USE_EPOLL))