Skip to content

Commit

Permalink
Propagate sshforward send side connection close
Browse files Browse the repository at this point in the history
PR #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]>
(cherry picked from commit 8c978cf)
  • Loading branch information
aaronlehmann authored and tonistiigi committed Jan 17, 2023
1 parent 3e30eaa commit 0282ebe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion session/sshforward/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream Stream, closeStre
if err := stream.RecvMsg(p); err != nil {
if err == io.EOF {
// indicates client performed CloseSend, but they may still be
// reading data, so don't close conn yet
// reading data
if conn, ok := conn.(interface {
CloseWrite() error
}); ok {
conn.CloseWrite()
}
return nil
}
conn.Close()
Expand Down

0 comments on commit 0282ebe

Please sign in to comment.