commit 75dbfbc71634af3dae9b5af1bc1e82fec32062e1
parent a56499312204a8da5a555f5512b1c898183a8ae2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 12 Nov 2023 11:14:49 +0300
Implemented and documented MHD_OPTION_LISTEN_SOCKET followed by MHD_INVALID_SOCKET
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/include/microhttpd.h b/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,
diff --git a/src/microhttpd/daemon.c b/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