Skip to content

Commit

Permalink
chunked: close reader pipe before waiting for errors
Browse files Browse the repository at this point in the history
close the pipe immediately when the file is closed to avoid a possible
deadlock if the other end is waiting for EOF on the writer side.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Dec 13, 2023
1 parent 6d05a39 commit b0986eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/chunked/compressor/compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,12 @@ type zstdChunkedWriter struct {
}

func (w zstdChunkedWriter) Close() error {
err := <-w.tarSplitErr
if err != nil {
w.tarSplitOut.Close()
errClose := w.tarSplitOut.Close()

if err := <-w.tarSplitErr; err != nil && err != io.EOF {
return err
}
return w.tarSplitOut.Close()
return errClose
}

func (w zstdChunkedWriter) Write(p []byte) (int, error) {
Expand Down

0 comments on commit b0986eb

Please sign in to comment.