aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-04-12 21:52:33 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-04-12 21:52:33 +0000
commitf5393bb0dd995c9d42c821ca16bd0fe4601e8e04 (patch)
tree3bdfb67c26dfdaf23ab73ee974a9079bcead22e4
parent67a2d40e514fecaff9580ba7f8c31f160d735db0 (diff)
downloadlibmicrohttpd-f5393bb0dd995c9d42c821ca16bd0fe4601e8e04.tar.gz
libmicrohttpd-f5393bb0dd995c9d42c821ca16bd0fe4601e8e04.zip
Fixed handling of caller-supplied socket with MHD_OPTION_LISTEN_SOCKET.
Was regression in 0.9.49.
-rw-r--r--ChangeLog14
-rw-r--r--src/microhttpd/daemon.c32
2 files changed, 28 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index b3148d34..4ee9da5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
1Tue Apr 13 21:46:01 CET 2016
2 Removed unneeded locking for global timeout list in
3 MHD_USE_THREAD_PER_CONNECTION mode.
4 Added 'simplepost' and 'largepost' examples to VS projects.
5 Added strtoXX() locale-independent replacement functions.
6 Added more error checking and minor fixes in digest auth
7 functions - should improve security.
8 Ignored specific errors in 'test_post' test until libcurl
9 will implement workaround for WinSock bug.
10 Fixed handling of caller-supplied socket with
11 MHD_OPTION_LISTEN_SOCKET (regression in 0.9.49).
12 Minor fixes.
13 Various cosmetics and comments fixes. -EG
14
1Sat Apr 09 13:05:42 CET 2016 15Sat Apr 09 13:05:42 CET 2016
2 Releasing libmicrohttpd 0.9.49. -EG 16 Releasing libmicrohttpd 0.9.49. -EG
3 17
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,
4114 } 4114 }
4115 } 4115 }
4116#endif 4116#endif
4117 if (MHD_NO == make_nonblocking (daemon, socket_fd))
4118 {
4119#ifdef HAVE_MESSAGES
4120 MHD_DLOG (daemon,
4121 "Failed to make listen socket non-blocking: %s\n",
4122 MHD_socket_last_strerr_ ());
4123#endif /* HAVE_MESSAGES */
4124 if (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY) ||
4125 daemon->worker_pool_size > 0)
4126 {
4127 /* Accept must be non-blocking. Multiple children may wake up
4128 * to handle a new connection, but only one will win the race.
4129 * The others must immediately return. */
4130 if (0 != MHD_socket_close_ (socket_fd))
4131 MHD_PANIC ("close failed\n");
4132 goto free_and_fail;
4133 }
4134 }
4135 if (listen (socket_fd, daemon->listen_backlog_size) < 0) 4117 if (listen (socket_fd, daemon->listen_backlog_size) < 0)
4136 { 4118 {
4137#ifdef HAVE_MESSAGES 4119#ifdef HAVE_MESSAGES
@@ -4148,6 +4130,20 @@ MHD_start_daemon_va (unsigned int flags,
4148 { 4130 {
4149 socket_fd = daemon->socket_fd; 4131 socket_fd = daemon->socket_fd;
4150 } 4132 }
4133
4134 if (MHD_NO == make_nonblocking (daemon, socket_fd))
4135 {
4136 if (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY) ||
4137 daemon->worker_pool_size > 0)
4138 {
4139 /* Accept must be non-blocking. Multiple children may wake up
4140 * to handle a new connection, but only one will win the race.
4141 * The others must immediately return. */
4142 if (0 != MHD_socket_close_ (socket_fd))
4143 MHD_PANIC ("close failed\n");
4144 goto free_and_fail;
4145 }
4146 }
4151#ifndef MHD_WINSOCK_SOCKETS 4147#ifndef MHD_WINSOCK_SOCKETS
4152 if ( (socket_fd >= FD_SETSIZE) && 4148 if ( (socket_fd >= FD_SETSIZE) &&
4153 (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY)) ) ) 4149 (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY)) ) )