Skip to content

Commit de7dd7a

Browse files
authored
Merge pull request moby#3431 from sipsma/defer-close
sshforward: skip conn close on stream CloseSend.
2 parents c0e38e1 + eb9e2c9 commit de7dd7a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

session/sshforward/copy.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ type Stream interface {
1414
}
1515

1616
func Copy(ctx context.Context, conn io.ReadWriteCloser, stream Stream, closeStream func() error) error {
17+
defer conn.Close()
1718
g, ctx := errgroup.WithContext(ctx)
1819

1920
g.Go(func() (retErr error) {
2021
p := &BytesMessage{}
2122
for {
2223
if err := stream.RecvMsg(p); err != nil {
23-
conn.Close()
2424
if err == io.EOF {
25+
// indicates client performed CloseSend, but they may still be
26+
// reading data, so don't close conn yet
2527
return nil
2628
}
29+
conn.Close()
2730
return errors.WithStack(err)
2831
}
2932
select {

0 commit comments

Comments
 (0)