* 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.
This commit is contained in:
Corinna Vinschen
2008-07-08 20:12:46 +00:00
parent b8fbf5d4c4
commit 23672785ee
5 changed files with 50 additions and 7 deletions

View File

@@ -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);