Repository navigation
Let listeners on several reactors share a port (SO_REUSEPORT) - #16
Merged
Merged
Conversation
A socket accepted by a listener is registered with that listener's reactor, so a server that wants more than one reactor needs a listening socket per reactor. There was no way to make one: bind set only SO_REUSEADDR, so a second bind on the port failed. endpoint-libs serves on one thread because of it and warns that WS_SHARDS is ignored. Listener::bind_shared and TcpListener::bind_shared set SO_REUSEPORT too. Linux balances connections across the sockets; macOS accepts the binds without balancing. Refused for Unix-domain addresses. Release as 0.1.13.
added 2 commits
September 24, 2026 05:15
The test called raise(SIGHUP) on a helper thread, and raise targets the calling thread. On Linux that helper inherited the block Signal::new takes, so SIGHUP stayed pending on the helper, and signalfd, which reports only its reader's and process-directed signals, never became readable. The waiter blocked forever, holding the test lock, and the job ran into CI's two-minute limit with a_parked_waiter queued behind it. pthread_kill the waiter instead, which is the case the test is named for, and wrap the wait in a five-second timeout so a regression fails in seconds.
The BSDs refuse them at sigaction. Linux does not: signalfd drops an uncatchable signal from its mask without an error, so Signal::new(SIGKILL) succeeded there and returned a waiter that could never fire. The test that says so had never run on Linux, because the cross-thread test hung first. Checked in Claim::acquire now, so both platforms answer EINVAL.
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.
A socket accepted by a nagoya listener is registered with that listener's reactor, so a multi-reactor server needs one listening socket per reactor.
bindset onlySO_REUSEADDR, so a second bind on the port failed. This is why endpoint-libs 3 serves on one thread and warns thatWS_SHARDSis ignored (consumers setWS_SHARDS=1to hide the warning).Listener::bind_shared/TcpListener::bind_shared:bindplusSO_REUSEPORT. Every socket on the port uses it, the first one included.EINVAL).Test:
shared_listeners_on_two_reactors_hold_one_port. Two reactors bind the same port withbind_shared, and a plainbindon that port fails.reactor_nettests (7/7) pass, clippy is clean.The endpoint-libs change that uses this, one reactor thread per shard, follows as its own PR.