Repository navigation
Accept unix peers that hang up before accept on macOS - #8766
Conversation
macOS fails LOCAL_PEERCRED with ENOTCONN once the peer has closed, even while the connection still waits in the listen backlog. kj-rs-io turned that into an exception, so acceptAuthenticated() on a unix listener failed when a client such as a health probe connected and hung up before it was accepted. Linux keeps the credentials captured at connect() and was not affected. In this patch a NotConnected error from peer_cred() gives a peer with no pid or uid, and the stream is returned as usual; its next read reports EOF. Other errors still throw. Fixes #8122.
There was a problem hiding this comment.
✅ Approved — This is a small, correct fix: only NotConnected from peer_cred() is treated as "no credentials" and all other errors still propagate. The new regression test covers it, and I found no issues.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
Only ErrorKind::NotConnected from peer_cred() is treated as "no credentials", and every other error still propagates with the same message as before. The pid and uid follow KJ's validity rules, and a missing uid is now reported as 0 with has_uid false. The test drops the client stream before accept, then checks that the stream reads EOF and that the listener goes on accepting connections.
📝 Documentation: ✅ LGTM
The updated doc comment on peer_credentials and the test comment describe how the code behaves now, which is what the repository's comment guidelines ask for.
Reviewed commit: edf28715
On macOS,
LOCAL_PEERCREDfails withENOTCONNonce the peer has closed, even while the connection is still waiting in the listen backlog. kj-rs-io turned that into an exception, soacceptAuthenticated()on a unix listener failed whenever a client, such as a health probe, connected and hung up before it was accepted. Linux keeps the credentials captured atconnect(), so it was not affected.In this patch a
NotConnectederror frompeer_cred()gives a peer with no pid or uid, and the stream is returned as usual. Its next read reports EOF. Other errors still throw. The new test inasync-io-test.c++fails on macOS without the fix.Fixes #8122.