commit 198181f17828a0c25079ace9d71f23682d99b8ad
parent 7f5c98bfa147997d58a60186a84d12a3a602d28c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Wed, 23 Nov 2016 15:28:03 +0300
Use both SO_REUSEADDR and SO_REUSEPORT on non-W32 if MHD_OPTION_LISTENING_ADDRESS_REUSE is set.
Diffstat:
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Nov 23 15:24:10 MSK 2016
+ Used SO_REUSEADDR (on non-W32) alongside with SO_REUSEPORT if option
+ MHD_OPTION_LISTENING_ADDRESS_REUSE was set. -EG
+
Wed Nov 23 12:48:23 MSK 2016
Move all gettext-related staff to 'po' subdirectory.
Excluded gettext files generation from normal build.
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -5041,8 +5041,23 @@ MHD_start_daemon_va (unsigned int flags,
}
else if (daemon->listening_address_reuse > 0)
{
- /* User requested to allow reusing listening address:port.
- * Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms.
+ /* User requested to allow reusing listening address:port. */
+#ifndef _WIN32
+ /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if
+ * it doesn't work. */
+ if (0 > setsockopt (socket_fd,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ (void*)&on, sizeof (on)))
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _("setsockopt failed: %s\n"),
+ MHD_socket_last_strerr_ ());
+#endif
+ }
+#endif /* ! _WIN32 */
+ /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms.
* Fail if SO_REUSEPORT is not defined or setsockopt fails.
*/
/* SO_REUSEADDR on W32 has the same semantics