libmicrohttpd

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

commit b484461cd399f4071d5787041f0bd3250b516d26
parent e5eade4a320e9a36ffe54548802172e30e418da3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 14 Nov 2016 20:53:24 +0300

Added support for SO_EXCLBIND socket option on Solaris.
Enabled by MHD_OPTION_LISTENING_ADDRESS_REUSE with zero.

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

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -5063,13 +5063,20 @@ MHD_start_daemon_va (unsigned int flags, { /* User requested to disallow reusing listening address:port. * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE - * is used. Fail if it does not exist or setsockopt fails. + * is used and Solaris with SO_EXCLBIND. + * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE + * or setsockopt fails. */ -#ifdef _WIN32 +#if (defined(_WIN32) && defined(SO_EXCLUSIVEADDRUSE)) || \ + (defined(__sun) && defined(SO_EXCLBIND)) #ifdef SO_EXCLUSIVEADDRUSE if (0 > setsockopt (socket_fd, SOL_SOCKET, +#ifdef SO_EXCLUSIVEADDRUSE SO_EXCLUSIVEADDRUSE, +#else /* SO_EXCLBIND */ + SO_EXCLBIND, +#endif /* SO_EXCLBIND */ (void *) &on, sizeof (on))) { @@ -5080,7 +5087,7 @@ MHD_start_daemon_va (unsigned int flags, #endif goto free_and_fail; } -#else /* SO_EXCLUSIVEADDRUSE not defined on W32? */ +#elif defined(_WIN32) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1379,7 +1379,8 @@ struct MHD_Daemon * The semantics is the following: * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR) * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) - * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows) + * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND + * on Solaris) */ int listening_address_reuse;