Sfoglia il codice sorgente

Fixed handling of caller-supplied socket with MHD_OPTION_LISTEN_SOCKET.
Was regression in 0.9.49.

Evgeny Grin (Karlson2k) 9 anni fa
parent
commit
f5393bb0dd
2 ha cambiato i file con 28 aggiunte e 18 eliminazioni
  1. 14 0
      ChangeLog
  2. 14 18
      src/microhttpd/daemon.c

+ 14 - 0
ChangeLog

@@ -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
 

+ 14 - 18
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)) ) )