fix: resilient worker accept loop — survive client disconnects#80
Open
cjchanh wants to merge 1 commit intoevilsocket:mainfrom
Open
fix: resilient worker accept loop — survive client disconnects#80cjchanh wants to merge 1 commit intoevilsocket:mainfrom
cjchanh wants to merge 1 commit intoevilsocket:mainfrom
Conversation
The worker accept loop (`Worker::run`) previously used `while let Ok(...) = self.listener.accept()` which silently exited on any accept error, permanently killing the TCP listener. This caused a "one connection works, then dead worker" failure mode, particularly severe on iOS where the first master disconnect left the worker unreachable until a full app restart. Changes: - Hold TcpListener in Option for in-place rebinding - Classify transient errors (ECONNABORTED, EINTR, TimedOut, WouldBlock) and retry immediately instead of exiting - On fatal accept errors, drop and rebind the listener on the same port without reloading model weights - Log listener fd and local address before each accept cycle for diagnostics - Add describe_listener() helper for cross-platform fd reporting Tested: 20 sequential inference requests over 6 minutes on an iOS worker (iPad M3) with zero drops or reconnections needed. Fixes evilsocket#79
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
The worker accept loop (
Worker::run) silently exits on anyaccept()error, permanently killing the TCP listener. This causes a "one connection works, then dead worker" failure mode.On iOS this is particularly severe: the first master disconnect (broken pipe, network hiccup, master restart) leaves the worker completely unreachable until the app is force-killed and relaunched.
Changes
TcpListenerinOptionfor in-place rebindingECONNABORTED,EINTR,TimedOut,WouldBlock) and retry immediatelydescribe_listener()helper for cross-platform fd reportingTesting
cargo test -p cake-core --lib— 589 passed, 0 failedDiagnostic log lines (after fix)
Recovery path (fatal accept error):
Fixes #79