aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-11-14 21:15:30 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-11-14 21:15:30 +0300
commit8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9 (patch)
tree3f1bb9495123a0e9b5f683e2ea10cc05e1eaa572
parentb484461cd399f4071d5787041f0bd3250b516d26 (diff)
downloadlibmicrohttpd-8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9.tar.gz
libmicrohttpd-8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9.zip
Fixed unintentional usage of SO_REUSEPORT on W32.
-rw-r--r--src/microhttpd/daemon.c8
-rw-r--r--src/microhttpd/internal.h3
2 files changed, 8 insertions, 3 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index c4ea8d0b..3e2d9109 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4990,8 +4990,11 @@ MHD_start_daemon_va (unsigned int flags,
4990 /* Apply the socket options according to listening_address_reuse. */ 4990 /* Apply the socket options according to listening_address_reuse. */
4991 if (0 == daemon->listening_address_reuse) 4991 if (0 == daemon->listening_address_reuse)
4992 { 4992 {
4993 /* No user requirement, use "traditional" default SO_REUSEADDR, 4993#ifndef _WIN32
4994 and do not fail if it doesn't work */ 4994 /* No user requirement, use "traditional" default SO_REUSEADDR
4995 * on non-W32 platforms, and do not fail if it doesn't work.
4996 * Don't use it on W32, because on W32 it will allow multiple
4997 * bind to the same address:port, like SO_REUSEPORT on others. */
4995 if (0 > setsockopt (socket_fd, 4998 if (0 > setsockopt (socket_fd,
4996 SOL_SOCKET, 4999 SOL_SOCKET,
4997 SO_REUSEADDR, 5000 SO_REUSEADDR,
@@ -5003,6 +5006,7 @@ MHD_start_daemon_va (unsigned int flags,
5003 MHD_socket_last_strerr_ ()); 5006 MHD_socket_last_strerr_ ());
5004#endif 5007#endif
5005 } 5008 }
5009#endif /* ! _WIN32 */
5006 } 5010 }
5007 else if (daemon->listening_address_reuse > 0) 5011 else if (daemon->listening_address_reuse > 0)
5008 { 5012 {
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 36ec6d8c..64f3c65c 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1377,7 +1377,8 @@ struct MHD_Daemon
1377 /** 1377 /**
1378 * Whether to allow/disallow/ignore reuse of listening address. 1378 * Whether to allow/disallow/ignore reuse of listening address.
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 * except W32)
1381 * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) 1382 * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows)
1382 * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND 1383 * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND
1383 * on Solaris) 1384 * on Solaris)