SocketPool+kQueue: retry kevent on EINTR instead of failing - #229
Merged
swhitty merged 1 commit intoJul 22, 2026
Conversation
kevent(2) can return -1/EINTR when a signal is delivered before any events arrive (e.g. debugger pause/resume). getNotifications treated this as fatal, unwinding SocketPool.run() and cancelling all waiters. Return no events instead so the caller polls again, matching the epoll_wait fix in a196c2e. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
=======================================
Coverage 92.88% 92.89%
=======================================
Files 71 71
Lines 3727 3731 +4
=======================================
+ Hits 3462 3466 +4
Misses 265 265 ☔ View full report in Codecov by Harness. |
swhitty
approved these changes
Jul 22, 2026
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
Applies the same fix as a196c2e (ePoll) to the kQueue backend.
kevent(2)documents: "[EINTR] A signal was delivered before the timeout expired and before any events were placed on the kqueue for return." No events are lost — butgetNotifications()treated-1/EINTRas fatal, unwindingSocketPool.run()whosedefer { cancelAll() }cancels every waiting continuation. A single signal delivery (e.g. Xcode's debugger pausing/resuming the process) tore down the whole pool on Darwin.Now returns no events so the caller polls again, using the same guard shape and comment as the ePoll fix.
The
Pollbackend has the same gap, but a fix there interacts with Windows/WSAPollsemantics — see #228 for details and a proposed direction.Testing
Full suite passes (449 tests, 51 suites). No new test: forcing EINTR requires delivering a signal to the exact thread blocked in
kevent, which isn't deterministically arrangeable under Swift Concurrency (the ePoll fix in a196c2e shipped without a test for the same reason).🤖 Generated with Claude Code