Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-05-27 11:50:00 +0400
committerCorinna Vinschen <corinna@vinschen.de>2003-05-27 11:50:00 +0400
commitdae86e4507ca652a9222f3e61f2ebc65502ea119 (patch)
tree38770a7b58399b264203f684c0bb892fffd8f827 /winsup/cygwin/fhandler_socket.cc
parent2311f6b0e4d977492d54f6f3d3aa781fc56495ac (diff)
* fhandler_socket.cc (fhandler_socket::dup): First try duplicating
using WSADuplicateSocket/WSASocket, if that fails, try DuplicateHandle.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index c3c7b9a89..45b8bc12b 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -393,15 +393,16 @@ fhandler_socket::dup (fhandler_base *child)
drop this for NT systems at all and return to the good ol'
DuplicateHandle way of life. This worked fine all the time on
NT anyway and it's even a bit faster. */
- if (!wincap.has_security ())
+ WSASetLastError (0);
+ fhs->fixup_before_fork_exec (GetCurrentProcessId ());
+ if (WSAGetLastError () != WSAEINVAL && winsock2_active)
{
- fhs->fixup_before_fork_exec (GetCurrentProcessId ());
- if (winsock2_active)
- {
- fhs->fixup_after_fork (hMainProc);
- return get_io_handle () == (HANDLE) INVALID_SOCKET;
- }
+ fhs->fixup_after_fork (hMainProc);
+ if (WSAGetLastError () != WSAEINVAL)
+ return get_io_handle () == (HANDLE) INVALID_SOCKET;
}
+
+ debug_printf ("WSADuplicateSocket failed, trying DuplicateHandle");
/* We don't call fhandler_base::dup here since that requires to
have winsock called from fhandler_base and it creates only
inheritable sockets which is wrong for winsock2. */