Skip to content

Commit 8c978cf

Browse files
committed
Propagate sshforward send side connection close
PR moby#3431 caused connections closed on the remote side of a sshforward session to not always result in the local side reading an EOF from the connection. This change restores that behavior by closing the write side of the forwarded connection after reading an EOF from the stream. Since only the write side is being closed, it doesn't prevent the remote side from continuing to read from the connection. Signed-off-by: Aaron Lehmann <[email protected]>
1 parent 7bd7285 commit 8c978cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

session/sshforward/copy.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream Stream, closeStre
2323
if err := stream.RecvMsg(p); err != nil {
2424
if err == io.EOF {
2525
// indicates client performed CloseSend, but they may still be
26-
// reading data, so don't close conn yet
26+
// reading data
27+
if conn, ok := conn.(interface {
28+
CloseWrite() error
29+
}); ok {
30+
conn.CloseWrite()
31+
}
2732
return nil
2833
}
2934
conn.Close()

0 commit comments

Comments
 (0)