summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-03 12:38:33 (GMT)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-03 12:38:33 (GMT)
commit6c765284a305db7a1afbbd8b05ef39835848e7c1 (patch)
tree9907b78d5de829908ef5f97930a81cc7f0825d27 /Modules/socketmodule.c
parent06a3c8ae82c76bd0ea21d3860a65bd6ece6ab72e (diff)
downloadcpython-6c765284a305db7a1afbbd8b05ef39835848e7c1.zip
cpython-6c765284a305db7a1afbbd8b05ef39835848e7c1.tar.gz
cpython-6c765284a305db7a1afbbd8b05ef39835848e7c1.tar.bz2
Fix Issue9753: socket.dup() does not always work right on Windows
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 8c743d8..6ebb9d9 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -351,16 +351,13 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
static SOCKET
dup_socket(SOCKET handle)
{
- HANDLE newhandle;
+ WSAPROTOCOL_INFO info;
- if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)handle,
- GetCurrentProcess(), &newhandle,
- 0, FALSE, DUPLICATE_SAME_ACCESS))
- {
- WSASetLastError(GetLastError());
+ if (WSADuplicateSocket(handle, GetCurrentProcessId(), &info))
return INVALID_SOCKET;
- }
- return (SOCKET)newhandle;
+
+ return WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO, &info, 0, 0);
}
#define SOCKETCLOSE closesocket
#else