Compare commits

...

2 Commits

Author SHA1 Message Date
Seongbin Hong 8e858ed2c7
Merge 2e01d90774 into 8a7c5ae68f 2024-10-19 15:54:52 +02:00
Seongbin Hong 2e01d90774
fix tcp half-closed connection unreliability in WSL
Signed-off-by: Seongbin Hong <vertex@g.cnu.ac.kr>
2023-12-20 23:38:56 +01:00
1 changed files with 7 additions and 5 deletions

View File

@ -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
@ -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)
}()