* 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.
This commit is contained in:
		| @@ -1,3 +1,12 @@ | |||||||
|  | 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> | 2009-11-23  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* fhandler_socket.cc (fhandler_socket::set_close_on_exec): Only call | 	* fhandler_socket.cc (fhandler_socket::set_close_on_exec): Only call | ||||||
|   | |||||||
| @@ -652,7 +652,7 @@ fhandler_socket::fixup_before_fork_exec (DWORD win_pid) | |||||||
|   if (ret) |   if (ret) | ||||||
|     set_winsock_errno (); |     set_winsock_errno (); | ||||||
|   else |   else | ||||||
|     debug_printf ("WSADuplicateSocket succeeded"); |     debug_printf ("WSADuplicateSocket succeeded (%lx)", prot_info_ptr->dwProviderReserved); | ||||||
|   return (int) ret; |   return (int) ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -669,7 +669,8 @@ fhandler_socket::fixup_after_fork (HANDLE parent) | |||||||
|     } |     } | ||||||
|      |      | ||||||
|   SOCKET new_sock = WSASocketW (FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, |   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) |   if (new_sock == INVALID_SOCKET) | ||||||
|     { |     { | ||||||
|       set_winsock_errno (); |       set_winsock_errno (); | ||||||
| @@ -681,7 +682,7 @@ fhandler_socket::fixup_after_fork (HANDLE parent) | |||||||
|          socket is potentially inheritable again. */ |          socket is potentially inheritable again. */ | ||||||
|       SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0); |       SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0); | ||||||
|       set_io_handle ((HANDLE) new_sock); |       set_io_handle ((HANDLE) new_sock); | ||||||
|       debug_printf ("WSASocket succeeded"); |       debug_printf ("WSASocket succeeded (%lx)", new_sock); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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 |      The only way to make these sockets usable in child processes is to | ||||||
|      duplicate them via WSADuplicateSocket/WSASocket calls.  This requires |      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 |      affected systems.  If we recognize a non-inheritable socket, or if | ||||||
|      the XP1_IFS_HANDLES flag is not set in a call to WSADuplicateSocket, |      the XP1_IFS_HANDLES flag is not set in a call to WSADuplicateSocket, | ||||||
|      we switch to inheritance/dup via WSADuplicateSocket/WSASocket for |      we switch to inheritance/dup via WSADuplicateSocket/WSASocket for | ||||||
|      that socket. */ |      that socket. */ | ||||||
|   DWORD flags; |   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; |   WSAPROTOCOL_INFOW wpi; | ||||||
|  | #endif | ||||||
|   if (!GetHandleInformation ((HANDLE) soc, &flags) |   if (!GetHandleInformation ((HANDLE) soc, &flags) | ||||||
|       || !(flags & HANDLE_FLAG_INHERIT) |       || !(flags & HANDLE_FLAG_INHERIT)) | ||||||
|  | #if 0 | ||||||
|       || WSADuplicateSocketW (soc, GetCurrentProcessId (), &wpi) |       || 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)) |       || !(wpi.dwServiceFlags1 & XP1_IFS_HANDLES)) | ||||||
|  | #endif | ||||||
|     ((fhandler_socket *) fd)->init_fixup_before (); |     ((fhandler_socket *) fd)->init_fixup_before (); | ||||||
|  |  | ||||||
|   /* Raise default buffer sizes (instead of WinSock default 8K). |   /* Raise default buffer sizes (instead of WinSock default 8K). | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user