summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/net.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-07-08 20:12:46 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-07-08 20:12:46 +0000
commit23672785ee63ee712b8ef05d0caa92e798683e53 (patch)
treee77921357b856c9fd859f298192d9b63cff7a98d /winsup/cygwin/net.cc
parentb8fbf5d4c4bb5998cadbc6031ada89799b69c291 (diff)
downloadcygnal-23672785ee63ee712b8ef05d0caa92e798683e53.tar.gz
cygnal-23672785ee63ee712b8ef05d0caa92e798683e53.tar.bz2
cygnal-23672785ee63ee712b8ef05d0caa92e798683e53.zip
* fhandler_socket.cc (fhandler_socket::bind): Don't run explicit
local socket test in SO_REUSEADDR case on systems supporting enhanced socket security. Explain why. Only call address_in_use for AF_INET sockets. * net.cc (cygwin_setsockopt): Don't call setsockopt to set SO_REUSEADDR on systems supporting enhanced socket security. Add comment. * wincap.h (wincaps::has_enhanced_socket_security): New element. * wincap.cc: Implement above element throughout.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index ded37aa05..8be32197c 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -649,8 +649,16 @@ cygwin_setsockopt (int fd, int level, int optname, const void *optval,
if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES)
optname = convert_ws1_ip_optname (optname);
- res = setsockopt (fh->get_socket (), level, optname,
- (const char *) optval, optlen);
+ /* On systems supporting "enhanced socket security (2K3 and later),
+ the default behaviour of socket binding is equivalent to the POSIX
+ behaviour with SO_REUSEADDR. Setting SO_REUSEADDR would only result
+ in wrong behaviour. See also fhandler_socket::bind(). */
+ if (level == SOL_SOCKET && optname == SO_REUSEADDR
+ && wincap.has_enhanced_socket_security ())
+ res = 0;
+ else
+ res = setsockopt (fh->get_socket (), level, optname,
+ (const char *) optval, optlen);
if (optlen == 4)
syscall_printf ("setsockopt optval=%x", *(long *) optval);