diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-03-02 16:06:30 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-03-02 16:06:30 (GMT) |
commit | 4e02f8f4aec46ffba087e525188a6429a155b8f9 (patch) | |
tree | 693c9bd36280fdb394c0471eba150341a9574493 /Lib/multiprocessing | |
parent | 3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2 (diff) | |
parent | 3f9e381030a93651a27ed4c12708fcfee1a48605 (diff) | |
download | cpython-4e02f8f4aec46ffba087e525188a6429a155b8f9.zip cpython-4e02f8f4aec46ffba087e525188a6429a155b8f9.tar.gz cpython-4e02f8f4aec46ffba087e525188a6429a155b8f9.tar.bz2 |
Issue #18382: Zero-length messages are consumed by ReadFile on Windows 8 and later
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/connection.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 9a8ae29..07d19de 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -829,7 +829,7 @@ if sys.platform == 'win32': try: ov, err = _winapi.ReadFile(fileno(), 0, True) except OSError as e: - err = e.winerror + ov, err = None, e.winerror if err not in _ready_errors: raise if err == _winapi.ERROR_IO_PENDING: @@ -838,7 +838,16 @@ if sys.platform == 'win32': else: # If o.fileno() is an overlapped pipe handle and # 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) timeout = 0 |