mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #18382: Zero-length messages are consumed by ReadFile on Windows 8 and later
This commit is contained in:
parent
bdf525b77c
commit
3f9e381030
1 changed files with 11 additions and 2 deletions
|
@ -844,7 +844,7 @@ if sys.platform == 'win32':
|
||||||
try:
|
try:
|
||||||
ov, err = _winapi.ReadFile(fileno(), 0, True)
|
ov, err = _winapi.ReadFile(fileno(), 0, True)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
err = e.winerror
|
ov, err = None, e.winerror
|
||||||
if err not in _ready_errors:
|
if err not in _ready_errors:
|
||||||
raise
|
raise
|
||||||
if err == _winapi.ERROR_IO_PENDING:
|
if err == _winapi.ERROR_IO_PENDING:
|
||||||
|
@ -853,7 +853,16 @@ if sys.platform == 'win32':
|
||||||
else:
|
else:
|
||||||
# If o.fileno() is an overlapped pipe handle and
|
# If o.fileno() is an overlapped pipe handle and
|
||||||
# err == 0 then there is a zero length message
|
# err == 0 then there is a zero length message
|
||||||
# in the pipe, but it HAS NOT been consumed.
|
# in the pipe, but it HAS NOT been consumed...
|
||||||
|
if ov and sys.getwindowsversion()[:2] >= (6, 2):
|
||||||
|
# ... except on Windows 8 and later, where
|
||||||
|
# the message HAS been consumed.
|
||||||
|
try:
|
||||||
|
_, err = ov.GetOverlappedResult(False)
|
||||||
|
except OSError as e:
|
||||||
|
err = e.winerror
|
||||||
|
if not err and hasattr(o, '_got_empty_message'):
|
||||||
|
o._got_empty_message = True
|
||||||
ready_objects.add(o)
|
ready_objects.add(o)
|
||||||
timeout = 0
|
timeout = 0
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue