Repository navigation
Allow TCP listeners to restart on Unix - #545
Merged
Merged
Conversation
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.
Summary
Set
SO_REUSEADDRbefore binding Unix TCP listeners so a restarted server can bind while connections from the previous run are still inTIME_WAIT. KeepSO_EXCLUSIVEADDRUSEon Windows.The regression test drives a loopback connection through a server-initiated close, then immediately binds the same address and port again. The existing test verifies that a second live listener still returns
AddrInUse.Closes #544.
Verification
AddrInUsebefore the fix and passed after it.cargo fmt --all -- --checkcargo clippy --locked --all-targets -- -D warningscargo test --locked --all-targetspassed all 200 tests on Linux.ROC=/path/to/nightly-2026-11-06-34f137a/roc python3 scripts/test.pypassed the full native Linux suite.TIME_WAITvia/proc/net/tcp, then immediately rebound the same port and served another connection.