diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-12 21:52:33 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-04-12 21:52:33 +0000 |
commit | f5393bb0dd995c9d42c821ca16bd0fe4601e8e04 (patch) | |
tree | 3bdfb67c26dfdaf23ab73ee974a9079bcead22e4 | |
parent | 67a2d40e514fecaff9580ba7f8c31f160d735db0 (diff) |
Fixed handling of caller-supplied socket with MHD_OPTION_LISTEN_SOCKET.
Was regression in 0.9.49.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 32 |
2 files changed, 28 insertions, 18 deletions
@@ -1,3 +1,17 @@ +Tue Apr 13 21:46:01 CET 2016 + Removed unneeded locking for global timeout list in + MHD_USE_THREAD_PER_CONNECTION mode. + Added 'simplepost' and 'largepost' examples to VS projects. + Added strtoXX() locale-independent replacement functions. + Added more error checking and minor fixes in digest auth + functions - should improve security. + Ignored specific errors in 'test_post' test until libcurl + will implement workaround for WinSock bug. + Fixed handling of caller-supplied socket with + MHD_OPTION_LISTEN_SOCKET (regression in 0.9.49). + Minor fixes. + Various cosmetics and comments fixes. -EG + Sat Apr 09 13:05:42 CET 2016 Releasing libmicrohttpd 0.9.49. -EG diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 2c2d971a..e9a978aa 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -4114,24 +4114,6 @@ MHD_start_daemon_va (unsigned int flags, } } #endif - if (MHD_NO == make_nonblocking (daemon, socket_fd)) - { -#ifdef HAVE_MESSAGES - MHD_DLOG (daemon, - "Failed to make listen socket non-blocking: %s\n", - MHD_socket_last_strerr_ ()); -#endif /* HAVE_MESSAGES */ - if (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY) || - daemon->worker_pool_size > 0) - { - /* Accept must be non-blocking. Multiple children may wake up - * to handle a new connection, but only one will win the race. - * The others must immediately return. */ - if (0 != MHD_socket_close_ (socket_fd)) - MHD_PANIC ("close failed\n"); - goto free_and_fail; - } - } if (listen (socket_fd, daemon->listen_backlog_size) < 0) { #ifdef HAVE_MESSAGES @@ -4148,6 +4130,20 @@ MHD_start_daemon_va (unsigned int flags, { socket_fd = daemon->socket_fd; } + + if (MHD_NO == make_nonblocking (daemon, socket_fd)) + { + if (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY) || + daemon->worker_pool_size > 0) + { + /* Accept must be non-blocking. Multiple children may wake up + * to handle a new connection, but only one will win the race. + * The others must immediately return. */ + if (0 != MHD_socket_close_ (socket_fd)) + MHD_PANIC ("close failed\n"); + goto free_and_fail; + } + } #ifndef MHD_WINSOCK_SOCKETS if ( (socket_fd >= FD_SETSIZE) && (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY)) ) ) |