]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 84450 via svnmerge from
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>
Fri, 3 Sep 2010 12:42:06 +0000 (12:42 +0000)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>
Fri, 3 Sep 2010 12:42:06 +0000 (12:42 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84450 | daniel.stutzbach | 2010-09-03 07:38:33 -0500 (Fri, 03 Sep 2010) | 1 line

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

Misc/NEWS
Modules/socketmodule.c

index e342ee837d387b219065b6f65c67b2a7e83b57b2..79f37ada8c5bfd332886f5dfc274449e2013d5bc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -105,6 +105,9 @@ C-API
 Library
 -------
 
+- Issue #9753: Fixed socket.dup, which did not always work correctly
+  on Windows.
+
 - Issue #1868: Eliminate subtle timing issues in thread-local objects by
   getting rid of the cached copy of thread-local attribute dictionary.
 
index baa5b9d954d7dcaed36662061557abc537108eaf..652900811f3c97d81f78be7dc2a0edeef1cb5499 100644 (file)
@@ -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