backport: discard disconnected accepted sockets for 0.6 - #1
Merged
kentbull merged 3 commits intoAug 24, 2026
Merged
Conversation
A peer may disconnect after accept() but before serviceAxes() inspects the socket addresses. getpeername() or getsockname() then raises an OSError that escapes the server loop and terminates the process. Close and discard the disconnected socket while allowing the listener to continue. Add regression coverage for both plaintext and TLS servers that also verifies a subsequent healthy connection is accepted.
Bring the merged UDP loopback test correction into this branch so CI evaluates the TCP socket-disconnect backport against the current 0.6.20 release base.
Backport the final regression test from ioflo/hio PR 166. Mock the platform-dependent getpeername failure while retaining real accepted sockets so Windows verifies the serviceAxes recovery path instead of relying on RST timing. This changes test code only; the accepted-socket production fix is unchanged.
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.
Ports the accepted-socket recovery fix from ioflo/hio#166 to the GLEIF Python 3.12-compatible 0.6 maintenance line.
A peer may disconnect after
accept()but beforeserviceAxes()inspects its addresses. Close and discard an unusable accepted socket without terminating the listener, and continue servicing later healthy connections.The regression coverage matches the final upstream test: it retains real accepted sockets but mocks the platform-dependent
getpeername()failure, avoiding reliance on operating-system-specific TCP RST timing.Base:
release/v0.6.20, including the merged UDP loopback test correction.Focused validation: Python 3.13 TCP module, 14 passed.