summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-03 12:42:06 (GMT)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>2010-09-03 12:42:06 (GMT)
commitee541e0d81a3f0a314aa9f59f324fa817bd6d27a (patch)
treefb00755567a3b49d9c8d7863f463d05ee5c12f3a
parentb82d5e1525f5bcad8c3ff23f2cfe679227643a65 (diff)
downloadcpython-ee541e0d81a3f0a314aa9f59f324fa817bd6d27a.zip
cpython-ee541e0d81a3f0a314aa9f59f324fa817bd6d27a.tar.gz
cpython-ee541e0d81a3f0a314aa9f59f324fa817bd6d27a.tar.bz2
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 ........
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/socketmodule.c13
2 files changed, 8 insertions, 8 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index e342ee8..79f37ad 100644
--- 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.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index baa5b9d..6529008 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