Quellcode durchsuchen

Implemented and documented MHD_OPTION_LISTEN_SOCKET followed by MHD_INVALID_SOCKET

Evgeny Grin (Karlson2k) vor 2 Jahren
Ursprung
Commit
75dbfbc716
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen
  1. 2 0
      src/include/microhttpd.h
  2. 6 4
      src/microhttpd/daemon.c

+ 2 - 0
src/include/microhttpd.h

@@ -1780,6 +1780,8 @@ enum MHD_OPTION
    * option is used, MHD will not open its own listen socket(s). The
    * argument passed must be of type `MHD_socket` and refer to an
    * existing socket that has been bound to a port and is listening.
+   * If followed by MHD_INVALID_SOCKET value, MHD ignores this option
+   * and creates socket by itself.
    */
   MHD_OPTION_LISTEN_SOCKET = 12,
 

+ 6 - 4
src/microhttpd/daemon.c

@@ -7405,11 +7405,12 @@ process_interim_params (struct MHD_Daemon *d,
 
   if (params->listen_fd_set)
   {
-    if (MHD_INVALID_SOCKET == params->listen_fd
+    if (MHD_INVALID_SOCKET == params->listen_fd)
+    {
+      (void) 0; /* Use MHD-created socket */
+    }
 #ifdef MHD_POSIX_SOCKETS
-        || 0 > params->listen_fd
-#endif /* MHD_POSIX_SOCKETS */
-        )
+    else if (0 > params->listen_fd)
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (d,
@@ -7418,6 +7419,7 @@ process_interim_params (struct MHD_Daemon *d,
 #endif /* HAVE_MESSAGES */
       return false;
     }
+#endif /* MHD_POSIX_SOCKETS */
     else if (0 != (d->options & MHD_USE_NO_LISTEN_SOCKET))
     {
 #ifdef HAVE_MESSAGES