aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-11-23 14:50:14 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-11-23 14:50:14 +0000
commit27bbefdefd339676bee4238e996df70e89fcdfa1 (patch)
tree54a83e54cc0997621e6158beedb51a6a418245ea /winsup
parent013e402bfc6d661d5884cd65888be06fa6e19c4f (diff)
downloadnewlib-27bbefdefd339676bee4238e996df70e89fcdfa1.zip
newlib-27bbefdefd339676bee4238e996df70e89fcdfa1.tar.gz
newlib-27bbefdefd339676bee4238e996df70e89fcdfa1.tar.bz2
* fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Add
socket handle value to debug output. (fhandler_socket::fixup_after_fork): Ditto. Make new socket handle OVERLAPPED, just as if it has been created with socket(). * net.cc (fdsock): Close duplicated socket and explain why. Disable the entire WSADuplicateSocket test for now and explain why.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/fhandler_socket.cc7
-rw-r--r--winsup/cygwin/net.cc14
3 files changed, 25 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index ab6cf6f..2c94913 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,14 @@
2009-11-23 Corinna Vinschen <corinna@vinschen.de>
+ * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Add
+ socket handle value to debug output.
+ (fhandler_socket::fixup_after_fork): Ditto. Make new socket handle
+ OVERLAPPED, just as if it has been created with socket().
+ * net.cc (fdsock): Close duplicated socket and explain why. Disable
+ the entire WSADuplicateSocket test for now and explain why.
+
+2009-11-23 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler_socket.cc (fhandler_socket::set_close_on_exec): Only call
fhandler_base::set_close_on_exec for inheritable sockets.
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index ba230df..5f22d7d 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -652,7 +652,7 @@ fhandler_socket::fixup_before_fork_exec (DWORD win_pid)
if (ret)
set_winsock_errno ();
else
- debug_printf ("WSADuplicateSocket succeeded");
+ debug_printf ("WSADuplicateSocket succeeded (%lx)", prot_info_ptr->dwProviderReserved);
return (int) ret;
}
@@ -669,7 +669,8 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
}
SOCKET new_sock = WSASocketW (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO, prot_info_ptr, 0, 0);
+ FROM_PROTOCOL_INFO, prot_info_ptr, 0,
+ WSA_FLAG_OVERLAPPED);
if (new_sock == INVALID_SOCKET)
{
set_winsock_errno ();
@@ -681,7 +682,7 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
socket is potentially inheritable again. */
SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0);
set_io_handle ((HANDLE) new_sock);
- debug_printf ("WSASocket succeeded");
+ debug_printf ("WSASocket succeeded (%lx)", new_sock);
}
}
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index f9cb1de..61a9157 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -510,17 +510,27 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
The only way to make these sockets usable in child processes is to
duplicate them via WSADuplicateSocket/WSASocket calls. This requires
- some incredible amount of extra processing so we only do this on
+ to start the child process in SUSPENDED state so we only do this on
affected systems. If we recognize a non-inheritable socket, or if
the XP1_IFS_HANDLES flag is not set in a call to WSADuplicateSocket,
we switch to inheritance/dup via WSADuplicateSocket/WSASocket for
that socket. */
DWORD flags;
+#if 0
+ /* Disable checking for IFS handle for now. In theory, checking the fact
+ that the socket handle is not inheritable should be sufficient. */
WSAPROTOCOL_INFOW wpi;
+#endif
if (!GetHandleInformation ((HANDLE) soc, &flags)
- || !(flags & HANDLE_FLAG_INHERIT)
+ || !(flags & HANDLE_FLAG_INHERIT))
+#if 0
|| WSADuplicateSocketW (soc, GetCurrentProcessId (), &wpi)
+ /* dwProviderReserved contains the actual SOCKET value of the duplicated
+ socket. Close it or suffer a handle leak. Worse, one socket for each
+ connection remains in CLOSE_WAIT state. */
+ || (closesocket ((SOCKET) wpi.dwProviderReserved), FALSE)
|| !(wpi.dwServiceFlags1 & XP1_IFS_HANDLES))
+#endif
((fhandler_socket *) fd)->init_fixup_before ();
/* Raise default buffer sizes (instead of WinSock default 8K).