[Python-checkins] r84451 - in python/branches/release31-maint: Misc/NEWS Modules/socketmodule.c

daniel.stutzbach python-checkins at python.org
Fri Sep 3 14:42:06 CEST 2010


Author: daniel.stutzbach
Date: Fri Sep  3 14:42:06 2010
New Revision: 84451

Log:
Merged revisions 84450 via svnmerge from 
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
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/Modules/socketmodule.c

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Fri Sep  3 14:42:06 2010
@@ -105,6 +105,9 @@
 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.
 

Modified: python/branches/release31-maint/Modules/socketmodule.c
==============================================================================
--- python/branches/release31-maint/Modules/socketmodule.c	(original)
+++ python/branches/release31-maint/Modules/socketmodule.c	Fri Sep  3 14:42:06 2010
@@ -351,16 +351,13 @@
 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


More information about the Python-checkins mailing list