diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-14 21:27:22 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-14 22:24:38 +0300 |
commit | 0af992b3a2aee012ae06ad9873694f581549d0c7 (patch) | |
tree | 4fdf7c855c1e300afe74b5046ac1367099f9e6a4 | |
parent | 8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9 (diff) | |
download | libmicrohttpd-0af992b3a2aee012ae06ad9873694f581549d0c7.tar.gz libmicrohttpd-0af992b3a2aee012ae06ad9873694f581549d0c7.zip |
Fixed usage of MHD with MHD_OPTION_LISTENING_ADDRESS_REUSE on Linux 3.2, 3.4 (longterm)
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/include/microhttpd.h | 2 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 35 |
3 files changed, 17 insertions, 29 deletions
@@ -1,3 +1,10 @@ | |||
1 | Mon Nov 14 22:18:30 MSK 2016 | ||
2 | Fixed unintentional usage of SO_REUSEADDR on W32. | ||
3 | Added support for SO_EXCLBIND on Solaris. | ||
4 | Fixed using MHD with MHD_OPTION_LISTENING_ADDRESS_REUSE | ||
5 | on Linux kernels before 3.9 (longterm 3.2 and 3.4 | ||
6 | are still supported). -EG | ||
7 | |||
1 | Sun Nov 13 19:16:38 CET 2016 | 8 | Sun Nov 13 19:16:38 CET 2016 |
2 | Fixed a few race issues on suspend-resume in cases where the | 9 | Fixed a few race issues on suspend-resume in cases where the |
3 | application uses threads even though MHD did not (or at least | 10 | application uses threads even though MHD did not (or at least |
@@ -5,7 +12,7 @@ Sun Nov 13 19:16:38 CET 2016 | |||
5 | the timeout list, avoiding manipulating it for suspended | 12 | the timeout list, avoiding manipulating it for suspended |
6 | connections. Finally, eliminated calling application logic | 13 | connections. Finally, eliminated calling application logic |
7 | on suspended connections (which before could happen under | 14 | on suspended connections (which before could happen under |
8 | certain circumstances). | 15 | certain circumstances). -CG |
9 | 16 | ||
10 | Thu Nov 11 20:49:23 MSK 2016 | 17 | Thu Nov 11 20:49:23 MSK 2016 |
11 | Added support for various forms of | 18 | Added support for various forms of |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index c91d0a54..d25ea8c2 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -126,7 +126,7 @@ typedef intptr_t ssize_t; | |||
126 | * Current version of the library. | 126 | * Current version of the library. |
127 | * 0x01093001 = 1.9.30-1. | 127 | * 0x01093001 = 1.9.30-1. |
128 | */ | 128 | */ |
129 | #define MHD_VERSION 0x00095209 | 129 | #define MHD_VERSION 0x00095210 |
130 | 130 | ||
131 | /** | 131 | /** |
132 | * MHD-internal return code for "YES". | 132 | * MHD-internal return code for "YES". |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 3e2d9109..ee43900d 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -5012,36 +5012,18 @@ MHD_start_daemon_va (unsigned int flags, | |||
5012 | { | 5012 | { |
5013 | /* User requested to allow reusing listening address:port. | 5013 | /* User requested to allow reusing listening address:port. |
5014 | * Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. | 5014 | * Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. |
5015 | * Fail if SO_REUSEPORT does not exist or setsockopt fails. | 5015 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. |
5016 | */ | 5016 | */ |
5017 | #ifdef _WIN32 | ||
5018 | /* SO_REUSEADDR on W32 has the same semantics | 5017 | /* SO_REUSEADDR on W32 has the same semantics |
5019 | as SO_REUSEPORT on BSD/Linux */ | 5018 | as SO_REUSEPORT on BSD/Linux */ |
5019 | #if defined(_WIN32) || defined(SO_REUSEPORT) | ||
5020 | if (0 > setsockopt (socket_fd, | 5020 | if (0 > setsockopt (socket_fd, |
5021 | SOL_SOCKET, | 5021 | SOL_SOCKET, |
5022 | SO_REUSEADDR, | 5022 | #ifndef _WIN32 |
5023 | (void*)&on, sizeof (on))) | ||
5024 | { | ||
5025 | #ifdef HAVE_MESSAGES | ||
5026 | MHD_DLOG (daemon, | ||
5027 | "setsockopt failed: %s\n", | ||
5028 | MHD_socket_last_strerr_ ()); | ||
5029 | #endif | ||
5030 | goto free_and_fail; | ||
5031 | } | ||
5032 | #else | ||
5033 | #ifndef SO_REUSEPORT | ||
5034 | #ifdef LINUX | ||
5035 | /* Supported since Linux 3.9, but often not present (or commented out) | ||
5036 | in the headers at this time; but 15 is reserved for this and | ||
5037 | thus should be safe to use. */ | ||
5038 | #define SO_REUSEPORT 15 | ||
5039 | #endif | ||
5040 | #endif | ||
5041 | #ifdef SO_REUSEPORT | ||
5042 | if (0 > setsockopt (socket_fd, | ||
5043 | SOL_SOCKET, | ||
5044 | SO_REUSEPORT, | 5023 | SO_REUSEPORT, |
5024 | #else /* _WIN32 */ | ||
5025 | SO_REUSEADDR, | ||
5026 | #endif /* _WIN32 */ | ||
5045 | (void *) &on, | 5027 | (void *) &on, |
5046 | sizeof (on))) | 5028 | sizeof (on))) |
5047 | { | 5029 | { |
@@ -5052,7 +5034,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5052 | #endif | 5034 | #endif |
5053 | goto free_and_fail; | 5035 | goto free_and_fail; |
5054 | } | 5036 | } |
5055 | #else | 5037 | #else /* !_WIN32 && !SO_REUSEPORT */ |
5056 | /* we're supposed to allow address:port re-use, but | 5038 | /* we're supposed to allow address:port re-use, but |
5057 | on this platform we cannot; fail hard */ | 5039 | on this platform we cannot; fail hard */ |
5058 | #ifdef HAVE_MESSAGES | 5040 | #ifdef HAVE_MESSAGES |
@@ -5060,8 +5042,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5060 | _("Cannot allow listening address reuse: SO_REUSEPORT not defined\n")); | 5042 | _("Cannot allow listening address reuse: SO_REUSEPORT not defined\n")); |
5061 | #endif | 5043 | #endif |
5062 | goto free_and_fail; | 5044 | goto free_and_fail; |
5063 | #endif | 5045 | #endif /* !_WIN32 && !SO_REUSEPORT */ |
5064 | #endif | ||
5065 | } | 5046 | } |
5066 | else /* if (daemon->listening_address_reuse < 0) */ | 5047 | else /* if (daemon->listening_address_reuse < 0) */ |
5067 | { | 5048 | { |