Skip to content

wasip3: Finish nonblocking I/O implementation for TCP#782

Merged
alexcrichton merged 6 commits intoWebAssembly:mainfrom
alexcrichton:tcp-nonblocking
Apr 13, 2026
Merged

wasip3: Finish nonblocking I/O implementation for TCP#782
alexcrichton merged 6 commits intoWebAssembly:mainfrom
alexcrichton:tcp-nonblocking

Conversation

@alexcrichton
Copy link
Copy Markdown
Collaborator

This commit fills out the final bits of nonblocking I/O for TCP sockets. This necessitates an implementation of nonblocking I/O for stream<u8> on both the reading and the writing side of things. Additionally things like TCP accepts now work, too. All tests are now passing on the WASIp3 target and the FAILP3 directive is now removed since it's no longer necessary.

The internals of the implementation here are pretty gnarly. This is due to the need to bridge the readiness-based-model of poll with the completion-based model of the component model. This implementation contains optimizations for 0-length reads/writes to use those to signal readiness if the host supports that, but this falls back to internally-buffered reads/writes if that is not supported.

This should resolve all remaining TODOs for WASIp3 that I know of at least in wasi-libc, so after this it'd be switching to bug-finding mode and handling bug reports as projects are compiled with wasip3.

This commit fills out the final bits of nonblocking I/O for TCP sockets.
This necessitates an implementation of nonblocking I/O for `stream<u8>`
on both the reading and the writing side of things. Additionally things
like TCP accepts now work, too. All tests are now passing on the WASIp3
target and the `FAILP3` directive is now removed since it's no longer
necessary.

The internals of the implementation here are pretty gnarly. This is due
to the need to bridge the readiness-based-model of `poll` with the
completion-based model of the component model. This implementation
contains optimizations for 0-length reads/writes to use those to signal
readiness if the host supports that, but this falls back to
internally-buffered reads/writes if that is not supported.

This should resolve all remaining TODOs for WASIp3 that I know of at
least in wasi-libc, so after this it'd be switching to bug-finding mode
and handling bug reports as projects are compiled with wasip3.
@alexcrichton
Copy link
Copy Markdown
Collaborator Author

cc @badeend, would you be willing to take a look at this? I realize that you may not be the most familiar with this code so it's totally fine if you'd rather not, too.

@alexcrichton alexcrichton requested a review from dicej April 9, 2026 01:13
Copy link
Copy Markdown
Collaborator

@dicej dicej left a comment

Choose a reason for hiding this comment

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

🎉

Comment thread libc-bottom-half/sources/file_utils.c Outdated
Comment thread libc-bottom-half/sources/file_utils.c Outdated
Co-authored-by: Joel Dice <joel.dice@akamai.com>
@alexcrichton alexcrichton merged commit 5885dd9 into WebAssembly:main Apr 13, 2026
32 checks passed
@alexcrichton alexcrichton deleted the tcp-nonblocking branch April 13, 2026 20:14
@alexcrichton
Copy link
Copy Markdown
Collaborator Author

I'm going to go ahead and merge this @badeend but I'd still value your input if you get a chance in the future to take a look, happy to have follow-ups!

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.

2 participants