Commit 6c765284 authored by Daniel Stutzbach's avatar Daniel Stutzbach

Fix Issue9753: socket.dup() does not always work right on Windows

parent 06a3c8ae
...@@ -155,6 +155,9 @@ Extensions ...@@ -155,6 +155,9 @@ Extensions
Library Library
------- -------
- Issue #9753: Fixed socket.dup, which did not always work correctly
on Windows.
- Issue #7005: Fixed output of None values for RawConfigParser.write and - Issue #7005: Fixed output of None values for RawConfigParser.write and
ConfigParser.write. ConfigParser.write.
......
...@@ -351,16 +351,13 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); ...@@ -351,16 +351,13 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
static SOCKET static SOCKET
dup_socket(SOCKET handle) dup_socket(SOCKET handle)
{ {
HANDLE newhandle; WSAPROTOCOL_INFO info;
if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)handle, if (WSADuplicateSocket(handle, GetCurrentProcessId(), &info))
GetCurrentProcess(), &newhandle,
0, FALSE, DUPLICATE_SAME_ACCESS))
{
WSASetLastError(GetLastError());
return INVALID_SOCKET; return INVALID_SOCKET;
}
return (SOCKET)newhandle; return WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO, &info, 0, 0);
} }
#define SOCKETCLOSE closesocket #define SOCKETCLOSE closesocket
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment