diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-14 20:53:24 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-14 20:54:40 +0300 |
commit | b484461cd399f4071d5787041f0bd3250b516d26 (patch) | |
tree | 0ff08ff9ac455faff95e83b14576442e6cfbccbe | |
parent | e5eade4a320e9a36ffe54548802172e30e418da3 (diff) | |
download | libmicrohttpd-b484461cd399f4071d5787041f0bd3250b516d26.tar.gz libmicrohttpd-b484461cd399f4071d5787041f0bd3250b516d26.zip |
Added support for SO_EXCLBIND socket option on Solaris.
Enabled by MHD_OPTION_LISTENING_ADDRESS_REUSE with zero.
-rw-r--r-- | src/microhttpd/daemon.c | 13 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 9931e6b7..c4ea8d0b 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -5063,13 +5063,20 @@ MHD_start_daemon_va (unsigned int flags, | |||
5063 | { | 5063 | { |
5064 | /* User requested to disallow reusing listening address:port. | 5064 | /* User requested to disallow reusing listening address:port. |
5065 | * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE | 5065 | * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE |
5066 | * is used. Fail if it does not exist or setsockopt fails. | 5066 | * is used and Solaris with SO_EXCLBIND. |
5067 | * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE | ||
5068 | * or setsockopt fails. | ||
5067 | */ | 5069 | */ |
5068 | #ifdef _WIN32 | 5070 | #if (defined(_WIN32) && defined(SO_EXCLUSIVEADDRUSE)) || \ |
5071 | (defined(__sun) && defined(SO_EXCLBIND)) | ||
5069 | #ifdef SO_EXCLUSIVEADDRUSE | 5072 | #ifdef SO_EXCLUSIVEADDRUSE |
5070 | if (0 > setsockopt (socket_fd, | 5073 | if (0 > setsockopt (socket_fd, |
5071 | SOL_SOCKET, | 5074 | SOL_SOCKET, |
5075 | #ifdef SO_EXCLUSIVEADDRUSE | ||
5072 | SO_EXCLUSIVEADDRUSE, | 5076 | SO_EXCLUSIVEADDRUSE, |
5077 | #else /* SO_EXCLBIND */ | ||
5078 | SO_EXCLBIND, | ||
5079 | #endif /* SO_EXCLBIND */ | ||
5073 | (void *) &on, | 5080 | (void *) &on, |
5074 | sizeof (on))) | 5081 | sizeof (on))) |
5075 | { | 5082 | { |
@@ -5080,7 +5087,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5080 | #endif | 5087 | #endif |
5081 | goto free_and_fail; | 5088 | goto free_and_fail; |
5082 | } | 5089 | } |
5083 | #else /* SO_EXCLUSIVEADDRUSE not defined on W32? */ | 5090 | #elif defined(_WIN32) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ |
5084 | #ifdef HAVE_MESSAGES | 5091 | #ifdef HAVE_MESSAGES |
5085 | MHD_DLOG (daemon, | 5092 | MHD_DLOG (daemon, |
5086 | _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); | 5093 | _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 05775dbc..36ec6d8c 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -1379,7 +1379,8 @@ struct MHD_Daemon | |||
1379 | * The semantics is the following: | 1379 | * The semantics is the following: |
1380 | * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR) | 1380 | * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR) |
1381 | * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) | 1381 | * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) |
1382 | * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows) | 1382 | * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND |
1383 | * on Solaris) | ||
1383 | */ | 1384 | */ |
1384 | int listening_address_reuse; | 1385 | int listening_address_reuse; |
1385 | 1386 | ||