wasip3: Implement read/write timeouts#762
Open
alexcrichton wants to merge 2 commits intoWebAssembly:mainfrom
Open
wasip3: Implement read/write timeouts#762alexcrichton wants to merge 2 commits intoWebAssembly:mainfrom
alexcrichton wants to merge 2 commits intoWebAssembly:mainfrom
Conversation
6dee222 to
e63f1f2
Compare
dicej
approved these changes
Mar 5, 2026
2cae64f to
bdef648
Compare
alexcrichton
added a commit
to alexcrichton/wasi-libc
that referenced
this pull request
Mar 6, 2026
In WebAssembly#762 I'm seeing an error related to `EADDRINUSE` which I can't reproduce locally. Tests currently all use the same port which means that they are required to be run serially and additionally may run into this risk if the port happens to already be taken. I don't really know what's going on in CI, but I wanted to nevertheless refactor these tests. This commit rearchitects, rewrites, and fixes sockets-related tests. Changes here are: * Servers now print the port they're listening to. Clients read this port and then connect to that port. This orchestration happens through some specially crafted bash and CMake, similar to before. All tests now bind to port 0 to get an OS-assigned port instead of picking a port. * All tests are now ungated, notably enabling some nonblocking I/O tests that were previously gated. * A number of tests are refactored or updated to be less flaky. Many tests were failing nondeterministically locally due to how the test was constructed and assuming certain things were ready when they may not be. Some tests were entirely rewritten, such as `sockets-nonblocking-multiple.c`, while others were only lightly refactored to `poll` in a few more places. * All tests are updated to pass in less than 100ms. Some tests before hung for awhile as timeouts were reached for example, but this wasn't a necessary part of the test. Other tests for nonblocking I/O had many calls to `poll` with a number of them reaching the timeout. These are rewritten to use a single call to `poll` with no timeout which enables the test to progress much faster as timeouts are never reached. Overall the intent is that the sockets-related tests are more comprehensive now, more robust and/or less flaky, and work in more environments.
alexcrichton
added a commit
to alexcrichton/wasi-libc
that referenced
this pull request
Mar 6, 2026
In WebAssembly#762 I'm seeing an error related to `EADDRINUSE` which I can't reproduce locally. Tests currently all use the same port which means that they are required to be run serially and additionally may run into this risk if the port happens to already be taken. I don't really know what's going on in CI, but I wanted to nevertheless refactor these tests. This commit rearchitects, rewrites, and fixes sockets-related tests. Changes here are: * Servers now print the port they're listening to. Clients read this port and then connect to that port. This orchestration happens through some specially crafted bash and CMake, similar to before. All tests now bind to port 0 to get an OS-assigned port instead of picking a port. * All tests are now ungated, notably enabling some nonblocking I/O tests that were previously gated. * A number of tests are refactored or updated to be less flaky. Many tests were failing nondeterministically locally due to how the test was constructed and assuming certain things were ready when they may not be. Some tests were entirely rewritten, such as `sockets-nonblocking-multiple.c`, while others were only lightly refactored to `poll` in a few more places. * All tests are updated to pass in less than 100ms. Some tests before hung for awhile as timeouts were reached for example, but this wasn't a necessary part of the test. Other tests for nonblocking I/O had many calls to `poll` with a number of them reaching the timeout. These are rewritten to use a single call to `poll` with no timeout which enables the test to progress much faster as timeouts are never reached. Overall the intent is that the sockets-related tests are more comprehensive now, more robust and/or less flaky, and work in more environments.
alexcrichton
added a commit
to alexcrichton/wasi-libc
that referenced
this pull request
Mar 6, 2026
In WebAssembly#762 I'm seeing an error related to `EADDRINUSE` which I can't reproduce locally. Tests currently all use the same port which means that they are required to be run serially and additionally may run into this risk if the port happens to already be taken. I don't really know what's going on in CI, but I wanted to nevertheless refactor these tests. This commit rearchitects, rewrites, and fixes sockets-related tests. Changes here are: * Servers now print the port they're listening to. Clients read this port and then connect to that port. This orchestration happens through some specially crafted bash and CMake, similar to before. All tests now bind to port 0 to get an OS-assigned port instead of picking a port. * All tests are now ungated, notably enabling some nonblocking I/O tests that were previously gated. * A number of tests are refactored or updated to be less flaky. Many tests were failing nondeterministically locally due to how the test was constructed and assuming certain things were ready when they may not be. Some tests were entirely rewritten, such as `sockets-nonblocking-multiple.c`, while others were only lightly refactored to `poll` in a few more places. * All tests are updated to pass in less than 100ms. Some tests before hung for awhile as timeouts were reached for example, but this wasn't a necessary part of the test. Other tests for nonblocking I/O had many calls to `poll` with a number of them reaching the timeout. These are rewritten to use a single call to `poll` with no timeout which enables the test to progress much faster as timeouts are never reached. Overall the intent is that the sockets-related tests are more comprehensive now, more robust and/or less flaky, and work in more environments.
In WebAssembly#762 I'm seeing an error related to `EADDRINUSE` which I can't reproduce locally. Tests currently all use the same port which means that they are required to be run serially and additionally may run into this risk if the port happens to already be taken. I don't really know what's going on in CI, but I wanted to nevertheless refactor these tests. This commit rearchitects, rewrites, and fixes sockets-related tests. Changes here are: * Servers now print the port they're listening to. Clients read this port and then connect to that port. This orchestration happens through some specially crafted bash and CMake, similar to before. All tests now bind to port 0 to get an OS-assigned port instead of picking a port. * All tests are now ungated, notably enabling some nonblocking I/O tests that were previously gated. * A number of tests are refactored or updated to be less flaky. Many tests were failing nondeterministically locally due to how the test was constructed and assuming certain things were ready when they may not be. Some tests were entirely rewritten, such as `sockets-nonblocking-multiple.c`, while others were only lightly refactored to `poll` in a few more places. * All tests are updated to pass in less than 100ms. Some tests before hung for awhile as timeouts were reached for example, but this wasn't a necessary part of the test. Other tests for nonblocking I/O had many calls to `poll` with a number of them reaching the timeout. These are rewritten to use a single call to `poll` with no timeout which enables the test to progress much faster as timeouts are never reached. Overall the intent is that the sockets-related tests are more comprehensive now, more robust and/or less flaky, and work in more environments.
a57d7d1 to
5f6a559
Compare
This is needed for socket options with TCP/UDP to implement timed-out reads/writes. This plumbs the relevant timeout to the waitable-set.wait invocation and handles the timeout outwards from there. This is a bit tricky since timeouts/cancellation can all race with actual completion of the operation, which is handled throughout and along the way, too.
5f6a559 to
cce2e7b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is needed for socket options with TCP/UDP to implement timed-out reads/writes. This plumbs the relevant timeout to the waitable-set.wait invocation and handles the timeout outwards from there. This is a bit tricky since timeouts/cancellation can all race with actual completion of the operation, which is handled throughout and along the way, too.