Conversation
…leaks (partial #32) Set SO_LINGER=0 on the daemon's listening socket before `listen(2)` so that accepted client sockets inherit a zero linger and force an immediate RST on close instead of going through FIN / CLOSE_WAIT / TIME_WAIT. After a hard-kill of the daemon, this prevents the kernel from leaking dangling CLOSE_WAIT state on client sockets that outlives the daemon itself and would otherwise block a fresh instance from re-binding the port. SO_LINGER is inherited from the listener by accept(2) on Linux, macOS, and Windows (AFD.sys), so setting it once on the listener covers every accepted connection without needing to hook axum 0.7's internal accept loop (axum 0.7 hands accept off to hyper-util inside `serve` with no per-connection extension point). Verified with the pre-existing regression test at crates/fbuild-daemon/tests/port_recovery.rs (run with `--ignored`), which hard-kills a daemon holding an open TCP connection and asserts a second daemon can re-bind the port cleanly. Remaining on #32: process containment via the `running-process` crate (Windows Job Object + POSIX process group parent-death). The SetConsoleCtrlHandler piece landed earlier in PR #61. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 13 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
SO_LINGER=0on the daemon's listening socket beforelisten(2)so accepted client sockets inherit a zero linger and force an immediateRSTon close instead of going throughFIN / CLOSE_WAIT / TIME_WAIT.CLOSE_WAITstate on client sockets that outlives the daemon itself and would otherwise block a fresh instance from re-binding the port.bind_listener_with_retrypath.Why listener-inheritance (and not a custom accept loop)
axum::servein axum 0.7 owns the accept loop inside itsIntoFutureimpl and hands each acceptedTcpStreamstraight tohyper-utilwith no per-connection hook. Replacing that loop means reimplementing graceful shutdown +serve_connection_with_upgradesplumbing.SO_LINGERis inherited byaccept(2)from the listening socket on all three target platforms (Linuxsock_copy, macOS/BSDsonewconn, Windows AFD.sys). Setting it once on the listener covers every accepted connection and keeps the change surgical. Axum 0.8'sListenertrait would allow a cleaner per-connection hook; we can revisit when we upgrade.Test plan
uv run cargo test -p fbuild-daemon --test port_recovery -- --ignoredpasses (hard-kills a daemon holding an open TCP connection, then asserts a second daemon re-binds the port cleanly).uv run cargo check --workspace --all-targetsclean.uv run cargo clippy --workspace --all-targets -- -D warningsclean.uv run cargo fmt --all -- --checkclean.Remaining on #32
running-processcrate (Windows Job Object kill-on-close + POSIX process group / Linux parent-death). Still open; intentionally deferred to a separate PR since it touches every subprocess spawn site.SetConsoleCtrlHandlerfor Windows CTRL_CLOSE / LOGOFF / SHUTDOWN (already merged in PR feat(daemon): Windows console ctrl handler for graceful shutdown (#18) #61)Closes: no (partial progress only). Tracking stays on #32 until process containment lands.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code