Skip to content

Commit

Permalink
fix tcp half-closed connection unreliability in WSL
Browse files Browse the repository at this point in the history
Signed-off-by: Seongbin Hong <[email protected]>
  • Loading branch information
VertexToEdge committed Sep 22, 2023
1 parent f74f884 commit 6af01b1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cli/command/container/hijack.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ func (h *hijackedIOStreamer) stream(ctx context.Context) error {
outputDone := h.beginOutputStream(restoreInput)
inputDone, detached := h.beginInputStream(restoreInput)

defer func() {
// Close the pipe after the outputStream had done.
if err := h.resp.CloseWrite(); err != nil {
logrus.Debugf("Couldn't send EOF: %s", err)
}
}()

select {
case err := <-outputDone:
return err
Expand Down Expand Up @@ -167,11 +174,6 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
logrus.Debugf("Error sendStdin: %s", err)
}
}

if err := h.resp.CloseWrite(); err != nil {
logrus.Debugf("Couldn't send EOF: %s", err)
}

close(inputDone)
}()

Expand Down

0 comments on commit 6af01b1

Please sign in to comment.