fix: harden macimed socket server reliability - #6
Open
tlhc wants to merge 1 commit into
Open
Conversation
tlhc
commented
Jul 22, 2026
- Cache TextInputSources snapshots and refresh after lookup or selection failures
- Serialize daemon command execution for non-thread-safe TextInputSources APIs
- Configure accepted sockets with SO_NOSIGPIPE, SO_RCVTIMEO, and SO_SNDTIMEO
- Retry socket response writes after short writes and EINTR
- Run blocking client I/O on a concurrent DispatchQueue
- Raise the pending-connection backlog from 5 to 64
- Add CI integration tests for source-cache refresh, idle peers, disconnected clients, concurrent requests, and JSON responses
There was a problem hiding this comment.
Pull request overview
This PR hardens the macimed UNIX-domain socket daemon to be more reliable under concurrency, idle/disconnected clients, and transient socket I/O issues, while also improving input-source handling by caching TIS snapshots with refresh-on-failure behavior and adding CI-covered tests.
Changes:
- Introduce an
InputSourceCacheto cacheTISInputSourcesnapshots and refresh on lookup/selection failures. - Improve socket server robustness (socket options, concurrent connection handling, serialized command execution for non-thread-safe TIS/TSM APIs, backlog increase, retry short writes/EINTR).
- Add new unit/integration test targets and run
swift testin CI.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/MacIMEKitTests/IMECacheTests.swift | Adds unit tests validating cache refresh and selection retry behavior. |
| Tests/MacIMEIntegrationTests/IMEDSocketTests.swift | Adds integration tests for idle/disconnected clients, concurrency, and JSON response validity. |
| Sources/MacIMEKit/IMED.swift | Hardens daemon socket handling (socket options, queues, write-retry, backlog increase). |
| Sources/MacIMEKit/IME.swift | Adds InputSourceCache and selection retry/refresh logic for input sources. |
| Package.swift | Registers new test targets for unit + integration tests. |
| .github/workflows/test.yml | Runs swift test in CI (and keeps release build + direct CLI sanity check). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Cache TextInputSources snapshots and refresh after lookup or selection failures - Serialize daemon command execution for non-thread-safe TextInputSources APIs - Configure accepted sockets with SO_NOSIGPIPE, SO_RCVTIMEO, and SO_SNDTIMEO - Retry socket response writes after short writes and EINTR - Run blocking client I/O on a concurrent DispatchQueue - Raise the pending-connection backlog from 5 to 64 - Add CI integration tests for source-cache refresh, idle peers, disconnected clients, concurrent requests, and JSON responses
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.