Skip to content

Commit 2e01d90

Browse files
VertexToEdgethaJeztah
authored andcommitted
fix tcp half-closed connection unreliability in WSL
Signed-off-by: Seongbin Hong <vertex@g.cnu.ac.kr>
1 parent 5777c1b commit 2e01d90

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cli/command/container/hijack.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ func (h *hijackedIOStreamer) stream(ctx context.Context) error {
4848
outputDone := h.beginOutputStream(restoreInput)
4949
inputDone, detached := h.beginInputStream(restoreInput)
5050

51+
defer func() {
52+
// Close the pipe after the outputStream had done.
53+
if err := h.resp.CloseWrite(); err != nil {
54+
logrus.Debugf("Couldn't send EOF: %s", err)
55+
}
56+
}()
57+
5158
select {
5259
case err := <-outputDone:
5360
return err
@@ -167,11 +174,6 @@ func (h *hijackedIOStreamer) beginInputStream(restoreInput func()) (doneC <-chan
167174
logrus.Debugf("Error sendStdin: %s", err)
168175
}
169176
}
170-
171-
if err := h.resp.CloseWrite(); err != nil {
172-
logrus.Debugf("Couldn't send EOF: %s", err)
173-
}
174-
175177
close(inputDone)
176178
}()
177179

0 commit comments

Comments
 (0)