Keep relaying after a connection the host end cannot serve - #868
Open
MayCXC wants to merge 1 commit into
Open
Conversation
A guest connection is served by opening one to the socket the relay was given, and that open fails whenever nothing accepts there any more: the process holding it exited, the socket was replaced, or the path names something that is no longer listening. The failure left the accept loop, so the listener stopped and the relay served nothing further. The socket stayed where it was, so every later caller found it, connected, and waited on a relay that had gone. A caller met neither the service nor the refusal that would have sent it to whatever it does without one. Fail the connection instead of the relay, and close the connection so the caller is told. A connect that never reaches the relay closes its own socket on the way out rather than leaving the descriptor behind.
MayCXC
force-pushed
the
socket-relay-per-connection
branch
from
August 27, 2026 20:47
846eea8 to
96f94a2
Compare
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
A guest connection is served by opening one to the socket the relay was given, and that open fails whenever nothing accepts there any more: the process holding it exited, the socket was replaced, or the path names something that is no longer listening. The failure left the accept loop, so the listener stopped and the relay served nothing further. The socket stayed where it was, so every later caller found it, connected, and waited on a relay that had gone. A caller met neither the service nor the refusal that would have sent it to whatever it does without one.
Fail the connection instead of the relay, and close the connection so the caller is told. A connect that never reaches the relay closes its own socket on the way out rather than leaving the descriptor behind.
Closes #867.
Motivation and Context
The lifetime of the thing being relayed to is not the lifetime of the relay. A host service that restarts is ordinary, and the relay is meant to outlive it, but one failed open ended the listener permanently. The symptom is bad in a particular way: a hang rather than a refusal, so the caller waits instead of falling back.
Related
#841 touches this file too, for a different fault: when outbound relays start relative to the container's mount namespace, and resolving guest paths through
/proc/<pid>/root. The two changes are independent and will want a trivial textual merge if both land.Testing
swift buildandmake checkclean.swift test: 603 tests in 83 suites passed.Type of Change