[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 01/03: Fixed ignored daemon port when MHD_OPTION_LISTEN_
From: |
gnunet |
Subject: |
[libmicrohttpd] 01/03: Fixed ignored daemon port when MHD_OPTION_LISTEN_SOCKET or MHD_OPTION_SOCK_ADDR are used as documented |
Date: |
Sun, 12 Nov 2023 18:16:48 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit c7998d3af303dab6cca664c361ea5706ee38bed9
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Nov 12 11:38:57 2023 +0300
Fixed ignored daemon port when MHD_OPTION_LISTEN_SOCKET or
MHD_OPTION_SOCK_ADDR are used as documented
---
src/microhttpd/daemon.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 644e134f..6aaeaae4 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -7450,6 +7450,9 @@ process_interim_params (struct MHD_Daemon *d,
d->listen_is_unix = _MHD_UNKNOWN;
#endif /* ! SO_DOMAIN || ! AF_UNIX */
d->listen_fd = params->listen_fd;
+#ifdef MHD_USE_GETSOCKNAME
+ d->port = 0; /* Force use of autodetection */
+#endif /* MHD_USE_GETSOCKNAME */
}
}
return true;
@@ -8032,6 +8035,43 @@ MHD_start_daemon_va (unsigned int flags,
servaddr = (struct sockaddr *) &servaddr4;
}
}
+ else
+ {
+#ifdef MHD_USE_GETSOCKNAME
+ daemon->port = 0; /* Force use of autodetection */
+#else /* ! MHD_USE_GETSOCKNAME */
+ switch (servaddr->sa_family)
+ {
+ case AF_INET:
+ {
+ struct sockaddr_in sa4;
+ memcpy (&sa4, servaddr, sizeof(sa4)); /* Required due to stronger
alignment */
+ daemon->port = ntohs (sa4.sin_port);
+ break;
+ }
+#ifdef HAVE_INET6
+ case AF_INET6:
+ {
+ struct sockaddr_in6 sa6;
+ memcpy (&sa6, servaddr, sizeof(sa6)); /* Required due to stronger
alignment */
+ daemon->port = ntohs (sa6.sin6_port);
+ mhd_assert (0 != (*pflags & MHD_USE_IPv6));
+ break;
+ }
+#endif /* HAVE_INET6 */
+#ifdef AF_UNIX
+ case AF_UNIX:
+ daemon->port = 0; /* special value for UNIX domain sockets */
+ daemon->listen_is_unix = _MHD_YES;
+ break;
+#endif
+ default:
+ daemon->port = 0; /* ugh */
+ daemon->listen_is_unix = _MHD_UNKNOWN;
+ break;
+ }
+#endif /* ! MHD_USE_GETSOCKNAME */
+ }
daemon->listen_fd = listen_fd;
if (0 != (*pflags & MHD_USE_IPv6))
{
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.