diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-23 15:28:03 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-23 15:28:03 +0300 |
commit | 198181f17828a0c25079ace9d71f23682d99b8ad (patch) | |
tree | af31146dd24d5d07291778b05a3015a2e262e499 | |
parent | 7f5c98bfa147997d58a60186a84d12a3a602d28c (diff) | |
download | libmicrohttpd-198181f17828a0c25079ace9d71f23682d99b8ad.tar.gz libmicrohttpd-198181f17828a0c25079ace9d71f23682d99b8ad.zip |
Use both SO_REUSEADDR and SO_REUSEPORT on non-W32 if MHD_OPTION_LISTENING_ADDRESS_REUSE is set.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 19 |
2 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,7 @@ | |||
1 | Wed Nov 23 15:24:10 MSK 2016 | ||
2 | Used SO_REUSEADDR (on non-W32) alongside with SO_REUSEPORT if option | ||
3 | MHD_OPTION_LISTENING_ADDRESS_REUSE was set. -EG | ||
4 | |||
1 | Wed Nov 23 12:48:23 MSK 2016 | 5 | Wed Nov 23 12:48:23 MSK 2016 |
2 | Move all gettext-related staff to 'po' subdirectory. | 6 | Move all gettext-related staff to 'po' subdirectory. |
3 | Excluded gettext files generation from normal build. | 7 | Excluded gettext files generation from normal build. |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 55604eb8..9300a43f 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -5041,8 +5041,23 @@ MHD_start_daemon_va (unsigned int flags, | |||
5041 | } | 5041 | } |
5042 | else if (daemon->listening_address_reuse > 0) | 5042 | else if (daemon->listening_address_reuse > 0) |
5043 | { | 5043 | { |
5044 | /* User requested to allow reusing listening address:port. | 5044 | /* User requested to allow reusing listening address:port. */ |
5045 | * Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. | 5045 | #ifndef _WIN32 |
5046 | /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if | ||
5047 | * it doesn't work. */ | ||
5048 | if (0 > setsockopt (socket_fd, | ||
5049 | SOL_SOCKET, | ||
5050 | SO_REUSEADDR, | ||
5051 | (void*)&on, sizeof (on))) | ||
5052 | { | ||
5053 | #ifdef HAVE_MESSAGES | ||
5054 | MHD_DLOG (daemon, | ||
5055 | _("setsockopt failed: %s\n"), | ||
5056 | MHD_socket_last_strerr_ ()); | ||
5057 | #endif | ||
5058 | } | ||
5059 | #endif /* ! _WIN32 */ | ||
5060 | /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. | ||
5046 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. | 5061 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. |
5047 | */ | 5062 | */ |
5048 | /* SO_REUSEADDR on W32 has the same semantics | 5063 | /* SO_REUSEADDR on W32 has the same semantics |