-
Notifications
You must be signed in to change notification settings - Fork 18k
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
internal/poll: cancel pending I/O in FD.Close() on Windows #28477
Comments
This sounds like a bug fix, not a proposal, so I've adjusted the labels. |
@crvv if it is a bug fix, I need to see description of a bug. Otherwise I do not know what your change fixes. Please answer these questions so I can understand what your bug is. Thank you. What version of Go are you using (
|
I think I have wrote what the change fix.
I don't think this issue is a bug fix. It is not a bug for |
I don't understand the issue here. Someone is going to have to send a change that includes a test case. @crvv: Do you want to do that? Thanks. |
I think I should add more details to this issue. It is about this behavior of
This is the current situation. The issue is going to cancel pending I/O operations for all files on Windows. Why this change can fix #25835?#25835 is that What operating system and processor architecture are you using (go env)?Windows, AMD64 What did you do?https://play.golang.org/p/Avsxc4QYDhd What did you expect to see?
What did you see instead?
and hangs forever. #25835 is just a complex example of this. |
The change adds TestCloseWithBlockingRead to the os package. But TestCloseWithBlockingRead (along with all others in pipe_test.go source file) does not run on Windows. I think, first step here - we should make TestCloseWithBlockingRead and all other tests in pipe_test.go run on Windows. And then we will decide what to do next. I will try to do that when I have time. Thank you. Alex |
@alexbrainman I think I'm running into this bug when trying to run this Kubernetes test program on Windows. In this specific test it runs this program, connects via TCP, then disconnects. When run on Windows, the program gets stuck in the Read call forever. On Linux, it exits when the connection is closed. This behavior is also exercised by the TestCloseWithBlockingReadByFd that you mentioned earlier and TestFdReadRace in the same file. TestCloseWithBlockingReadByFd fails on windows due to getting stuck in Read and Close. TestFdReadRace hangs forever (unless go test is invoked with |
@astrieanna thank you for your comment here.
I did not have a chance to investigate what the problem is yet. So I would not know, if proposed solution is good. Like I said earlier, I will try to debug this when I have time. If you want to fix this yourself, feel free to do so. Here https://golang.org/doc/contribute.html is how to contribute to Go project. Alex |
@alexbrainman I'd be happy to fix this. My main concern is that I'm not sure when not to run the |
@astrieanna I guess there are not side effects if |
This issue only affects pipes. I would try and avoid changing code that affects other file types. Maybe you could use GetFileType Windows API to determine if file is pipe. CancelIoEx sounds OK to me, if it fixes the tests. I think the biggest problem here is to make all tests in pipe_test.go (nearly all) pass before we commit to a solution. Alex |
When closing a pipe, use CancelIoEx to cancel pending I/O. This makes concurrent Read and Write calls to return os.ErrClosed. This change also enables pipe_test on Windows. Fixes golang#28477, golang#25835 Change-Id: If52bb7d80895763488a61632e4682a78336e8420
When closing a pipe, use CancelIoEx to cancel pending I/O. This makes concurrent Read and Write calls to return os.ErrClosed. This change also enables some pipe tests on Windows. Fixes golang#28477, golang#25835 Change-Id: If52bb7d80895763488a61632e4682a78336e8420
Change https://golang.org/cl/164721 mentions this issue: |
I propose this, roughly
And the result is
(*os.File).Close()
cancels pending I/O operations for all files. I think this is a good feature.Other notes:
CancelIoEx
requires Windows vista or later.https://docs.microsoft.com/en-us/windows/desktop/fileio/cancelioex-func
The text was updated successfully, but these errors were encountered: