-
-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix early pipe shutdown with Windows ProcessMonitor #3726
Conversation
@kulibali here's the PR for testing. |
@@ -172,14 +178,17 @@ class _Pipe | |||
bytes_to_read, addressof bytes_read, USize(0)) | |||
let winerr = @GetLastError[I32]() | |||
if not ok then | |||
if (winerr == _ERRORBROKENPIPE()) or (winerr == _ERRORNODATA()) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ERRORNODATA should be impossible to get here based on doing non blocking and us having previously peeked to know there is data to read.
3ee2d26
to
be44d0d
Compare
This commit fixes a fun bug that results from multiple bits coming together. First, the ProcessMonitor when running on Windows doesn't using ASIO. Instead of having events pushed to it, we poll periodically to see if there's anything to read or if we can write any pending writes. Because of the polling, it is possible that we will attempt to read when there's no data in the pipe. When using non-blocking IO with pipes, a read that would return 0 bytes returns an error and sets the error code to a no data error code. We were interpreting the no data code as it should be when using blocking io. When using non-blocking io, there error communicates "no data right now, try again later" which wasn't what we were doing. The same incorrect handling of the no data error code is also present in the write code for Windows and is fixed by this commit. Fixes #3674
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SeanTAllen! I have run the corrall test suite a couple of dozen times in a row without failures. Previously they woud fail quite often.
This commit fixes a fun bug that results from multiple bits coming together.
First, the ProcessMonitor when running on Windows doesn't using ASIO. Instead
of having events pushed to it, we poll periodically to see if there's anything
to read or if we can write any pending writes.
Because of the polling, it is possible that we will attempt to read when there's
no data in the pipe. When using non-blocking IO with pipes, a read that would return
0 bytes returns an error and sets the error code to a no data error code.
We were interpreting the no data code as it should be when using blocking io. When
using non-blocking io, there error communicates "no data right now, try again later"
which wasn't what we were doing.
The same incorrect handling of the "no data" error code was present in the write code
path as well. That has also been fixed.
Fixes #3674