libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9
parent b484461cd399f4071d5787041f0bd3250b516d26
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 14 Nov 2016 21:15:30 +0300

Fixed unintentional usage of SO_REUSEPORT on W32.

Diffstat:
Msrc/microhttpd/daemon.c | 8++++++--
Msrc/microhttpd/internal.h | 3++-
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -4990,8 +4990,11 @@ MHD_start_daemon_va (unsigned int flags, /* Apply the socket options according to listening_address_reuse. */ if (0 == daemon->listening_address_reuse) { - /* No user requirement, use "traditional" default SO_REUSEADDR, - and do not fail if it doesn't work */ +#ifndef _WIN32 + /* No user requirement, use "traditional" default SO_REUSEADDR + * on non-W32 platforms, and do not fail if it doesn't work. + * Don't use it on W32, because on W32 it will allow multiple + * bind to the same address:port, like SO_REUSEPORT on others. */ if (0 > setsockopt (socket_fd, SOL_SOCKET, SO_REUSEADDR, @@ -5003,6 +5006,7 @@ MHD_start_daemon_va (unsigned int flags, MHD_socket_last_strerr_ ()); #endif } +#endif /* ! _WIN32 */ } else if (daemon->listening_address_reuse > 0) { diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1377,7 +1377,8 @@ struct MHD_Daemon /** * Whether to allow/disallow/ignore reuse of listening address. * The semantics is the following: - * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR) + * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR + * except W32) * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND * on Solaris)