You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If 1 thread is doing a blocking read from a net.Stream when another thread closes the connection, the read blocks. On Linux and MacOS ,the read will unblock and return error.NotOpenForReading.
I believe this should work in Windows, but I'm having a hard time navigating the windows documentation (zig seems to use some deprecated functions, e.g. NtClose) to figure out if this behavior should be supported.
As far as I can tell, shutdown on windows does not interrupt any running blocking calls, it only prevents new calls and waits for all calls to finish. To be fair, the POSIX definition of shutdown makes no claims about interrupting existing calls either.
Perhaps the thread-to-be-interrupted could use the SO_RCVTIMEO sockopt to occasionally time out and give it a chance to realize it has been shut down.
It would basically be spinlocking at that point and would introduce delay on application exit, surely there's a better way? On linux, you can select() on the socket and another pipe that can send a kill command.
Zig Version
0.14.0-dev.1573+4d81e8ee9
Steps to Reproduce and Observed Behavior
If 1 thread is doing a blocking read from a
net.Stream
when another thread closes the connection, the read blocks. On Linux and MacOS ,the read will unblock and returnerror.NotOpenForReading
.I believe this should work in Windows, but I'm having a hard time navigating the windows documentation (zig seems to use some deprecated functions, e.g.
NtClose
) to figure out if this behavior should be supported.The issue was reported against websocket.zig
This code (cliend and server included), reproduces the issue:
/cc @pfgithub
Expected Behavior
Expect read to unblock when socket is shutdown and/or closed.
The text was updated successfully, but these errors were encountered: