Repository navigation
Close both proxy endpoints to interrupt blocked writes - #513
sylvesterkaczmarek wants to merge 2 commits into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
| case err := <-leftErrCh: | ||
| recordErr(err) | ||
| recordErr(right.Close()) | ||
| recordErr(left.Close()) |
There was a problem hiding this comment.
When SSH peer closes its channel normally, the SSH library acks the close before returning EOF. This additional close then returns io.EOF which would be recorded as proxy failure. This would result in caller logging and error for a normal disconnect. We should make sure we handle this.
There was a problem hiding this comment.
Thanks for catching this, @yzhuang-oai. Fixed in verified commit 2f47880: the fallback proxy now treats EOF from an already-closed SSH channel (including wrapped EOF) as normal shutdown, while preserving unrelated I/O and Close errors. New regressions cover both copy directions and confirm that the earlier code fails. The proxy race test and related command/endpoint tests pass; the TCP half-close path is unchanged.
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
Problem
The fallback connection proxy closes only the remaining copy's source after the first copy ends. That copy can instead be blocked in a destination Write. Closing its source does not interrupt that write, so Connections can wait indefinitely after EOF or an I/O error.
Change
Close both endpoints before waiting for the remaining copy. This preserves the fallback path's close-on-first-completion behavior while interrupting both reads and writes. Keep the separate TCP half-close implementation unchanged.
The net.Conn contract specifies that Close unblocks pending reads and writes on that connection.
Validation
git diff --checkpassed.Validated on macOS arm64. No VM or hardware/runtime integration under
internal/testswas run. No public interface, dependency, retry, or half-close policy changes.Reproduced against
f101ade5d8fdcad5e9c346472698649e7107a715.