Fix for Issue 14725 for 3.3 branch.
This commit is contained in:
parent
7a919e9930
commit
fdb8dcf675
|
@ -621,16 +621,24 @@ if sys.platform == 'win32':
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self._handle_queue.append(self._new_handle())
|
self._handle_queue.append(self._new_handle())
|
||||||
handle = self._handle_queue.pop(0)
|
handle = self._handle_queue.pop(0)
|
||||||
ov = _winapi.ConnectNamedPipe(handle, overlapped=True)
|
|
||||||
try:
|
try:
|
||||||
res = _winapi.WaitForMultipleObjects([ov.event], False, INFINITE)
|
ov = _winapi.ConnectNamedPipe(handle, overlapped=True)
|
||||||
except:
|
except OSError as e:
|
||||||
ov.cancel()
|
if e.winerror != _winapi.ERROR_NO_DATA:
|
||||||
_winapi.CloseHandle(handle)
|
raise
|
||||||
raise
|
# ERROR_NO_DATA can occur if a client has already connected,
|
||||||
finally:
|
# written data and then disconnected -- see Issue 14725.
|
||||||
_, err = ov.GetOverlappedResult(True)
|
else:
|
||||||
assert err == 0
|
try:
|
||||||
|
res = _winapi.WaitForMultipleObjects(
|
||||||
|
[ov.event], False, INFINITE)
|
||||||
|
except:
|
||||||
|
ov.cancel()
|
||||||
|
_winapi.CloseHandle(handle)
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
_, err = ov.GetOverlappedResult(True)
|
||||||
|
assert err == 0
|
||||||
return PipeConnection(handle)
|
return PipeConnection(handle)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1878,6 +1878,22 @@ class _TestListenerClient(BaseTestCase):
|
||||||
p.join()
|
p.join()
|
||||||
l.close()
|
l.close()
|
||||||
|
|
||||||
|
def test_issue14725(self):
|
||||||
|
l = self.connection.Listener()
|
||||||
|
p = self.Process(target=self._test, args=(l.address,))
|
||||||
|
p.daemon = True
|
||||||
|
p.start()
|
||||||
|
time.sleep(1)
|
||||||
|
# On Windows the client process should by now have connected,
|
||||||
|
# written data and closed the pipe handle by now. This causes
|
||||||
|
# ConnectNamdedPipe() to fail with ERROR_NO_DATA. See Issue
|
||||||
|
# 14725.
|
||||||
|
conn = l.accept()
|
||||||
|
self.assertEqual(conn.recv(), 'hello')
|
||||||
|
conn.close()
|
||||||
|
p.join()
|
||||||
|
l.close()
|
||||||
|
|
||||||
class _TestPoll(unittest.TestCase):
|
class _TestPoll(unittest.TestCase):
|
||||||
|
|
||||||
ALLOWED_TYPES = ('processes', 'threads')
|
ALLOWED_TYPES = ('processes', 'threads')
|
||||||
|
|
|
@ -1287,11 +1287,9 @@ PyInit__winapi(void)
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_MORE_DATA);
|
WINAPI_CONSTANT(F_DWORD, ERROR_MORE_DATA);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED);
|
WINAPI_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NO_SYSTEM_RESOURCES);
|
WINAPI_CONSTANT(F_DWORD, ERROR_NO_SYSTEM_RESOURCES);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED);
|
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_IO_PENDING);
|
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_MORE_DATA);
|
WINAPI_CONSTANT(F_DWORD, ERROR_MORE_DATA);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED);
|
WINAPI_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED);
|
||||||
|
WINAPI_CONSTANT(F_DWORD, ERROR_NO_DATA);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_NO_SYSTEM_RESOURCES);
|
WINAPI_CONSTANT(F_DWORD, ERROR_NO_SYSTEM_RESOURCES);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_OPERATION_ABORTED);
|
WINAPI_CONSTANT(F_DWORD, ERROR_OPERATION_ABORTED);
|
||||||
WINAPI_CONSTANT(F_DWORD, ERROR_PIPE_BUSY);
|
WINAPI_CONSTANT(F_DWORD, ERROR_PIPE_BUSY);
|
||||||
|
|
Loading…
Reference in New Issue