Skip to content
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

wasi: nonblocking pipes on Windows #1570

Merged
merged 1 commit into from
Jul 9, 2023

Conversation

evacchi
Copy link
Contributor

@evacchi evacchi commented Jul 9, 2023

Improve #1500 with a simple observation, i.e. we really need non-blocking I/O only for pipes and sockets.

Now, for sockets we can use WinSock select, as for pipes, select_windows.go already imports PeekNamedPipe.

We combine PeekNamedPipe with a blocking Read only for those cases when PeekNamedPipe returns n > 0, which means a Read of n bytes won't block.

We special case n == 0 to return EAGAIN and
ERROR_BROKEN_PIPE as a non-failure (EOF reached).

We also introduce isNonblock(f) function, specialized on Windows to also check if the file is ModeNamedPipe; otherwise we would default to blocking anyway.

Improve tetratelabs#1500 with a simple observation, i.e. we really
need non-blocking I/O only for pipes and sockets.

Now, for sockets we can use WinSock select, as for pipes,
select_windows.go already imports PeekNamedPipe.

We combine PeekNamedPipe with a blocking Read only for
those cases when PeekNamedPipe returns n > 0, which
means a Read of n bytes won't block.

We special case n == 0 to return EAGAIN and
ERROR_BROKEN_PIPE as a non-failure (EOF reached).

We also introduce `isNonblock(f)` function, specialized
on Windows to also check if the file is ModeNamedPipe;
otherwise we would default to blocking anyway.

Signed-off-by: Edoardo Vacchi <[email protected]>
Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the progress!

@codefromthecrypt codefromthecrypt merged commit d3f09bd into tetratelabs:main Jul 9, 2023
53 checks passed
@evacchi evacchi deleted the nbpipes branch July 10, 2023 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants