Repository navigation
fix(http): rebind the listener during TIME_WAIT (SO_REUSEADDR on POSIX) - #46
Merged
Merged
Conversation
A beacon container sharing its proxy's network namespace crash-looped on http_bind_failed for ~55 s after a rebuild: the previous instance's closed connections held TIME_WAIT on the port. serve-http and serve --transport http now create the listener via _new_listener(), setting SO_REUSEADDR on POSIX only (never Windows, where it allows port stealing); a port another socket listens on is still refused. POSIX tests reproduce TIME_WAIT. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JNe816x81LFW6db8T7vtsE
…s SO_REUSEADDR) On Linux a rebind through TIME_WAIT needs SO_REUSEADDR on both the new listener and the listener that accepted the TIME_WAIT connection. The rebind test now replaces a fixed server with a fixed one; the plain-socket test keeps reproducing the pre-fix failure. CHANGELOG notes the first rollout may still wait out one TIME_WAIT. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JNe816x81LFW6db8T7vtsE
Contributor
Author
|
Linux CI caught a real subtlety: a rebind through TIME_WAIT needs |
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.
Fixes the 2026-09-27
menhir.archolith.dev502. After a rebuild, yawn'sbeacon-menhir(in Caddy's shared network namespace) crash-looped onhttp_bind_failedfor about 55 seconds, because the old instance's closed connections held TIME_WAIT on127.0.0.1:3366._new_listener()setsSO_REUSEADDRon POSIX only, used byserve-httpandserve --transport http. It's never set on Windows, where the flag would allow port stealing. A port another socket is listening on is still refused.tests/test_listener_rebind.py(Linux and macOS CI): it creates a real server-side TIME_WAIT, checks that a plain socket getsEADDRINUSE(so the test reproduces the bug), that the new listener rebinds, and that a live listener still getsEADDRINUSE.After merge: rerun yawn's
beacon-demotarget.beacon-menhirbuilds from master, so no image release is needed; it should come back with 0 restarts.beacon.archolith.devisn't affected (its own namespace) and picks this up at the next release.🤖 Generated with Claude Code
https://claude.ai/code/session_01JNe816x81LFW6db8T7vtsE