Let a host connect to its own listener - #26
Merged
Merged
Conversation
The stream registry keyed each end by (conn, host), so the two ends of a self-connection shared a key and the client overwrote the server: the connect never completed and the run deadlocked. Ends are now keyed by their own port as well, data packets address the peer's port, and the accept and refusal answer to the connector's port rather than the listener's — on one machine, port is the only thing telling the two directions apart. A connect whose drawn ephemeral port would equal the target port on the same host takes the next number instead. Packets between distinct hosts keep their keys, order and trace events, so recorded hashes stay where they were.
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.
A host that opened a stream connection to a listener on itself deadlocked: the stream registry keyed each connection end by (conn, host), so both ends of a self-connection collapsed onto one key and the client transport overwrote the server's. The reply could never find its way back.
The fix keys each end by its own port as well. Data packets now address the peer end's port, and the accept — and the refusal — answer to the connector's port rather than the listener's, which matters twice on one machine: it is the only thing telling the two directions apart, and a refusal addressed to the listener's port would land on the in-order queue the syn already advanced and wait there forever, turning connect-to-closed-port into a hang instead of ConnectionRefusedError. A connect whose drawn ephemeral port would equal the target port on the same host takes the next number instead, so the two ends can never share a key.
Nothing changes for connections between distinct hosts: keys gain a field but keep their meaning, no packet, draw, or trace event is added or reordered, and the three pinned replay digests for the reference network workload are byte-identical before and after. Two tests cover the new ground: a loopback echo through asyncio.start_server / open_connection on a single host, and a loopback connect to a closed port raising ConnectionRefusedError.
Full suite (493), the slow replay-stability suite, and strict mypy are green.