From 7e30531f20b8c367aad81454abda8505a0d9962a Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 18 Jan 2022 16:27:33 +0100 Subject: compat attach: fix write on closed channel Waiting on an initialized sync.WaitGroup returns immediately. Hence, move the goroutine to wait and close *after* reading the logs. Fixes: #12904 Signed-off-by: Valentin Rothberg --- libpod/oci_conmon_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libpod') diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 3fa43aed9..268a301fb 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -660,13 +660,13 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. } errChan <- err }() + if err := ctr.ReadLog(context.Background(), logOpts, logChan); err != nil { + return err + } go func() { logOpts.WaitGroup.Wait() close(logChan) }() - if err := ctr.ReadLog(context.Background(), logOpts, logChan); err != nil { - return err - } logrus.Debugf("Done reading logs for container %s, %d bytes", ctr.ID(), logSize) if err := <-errChan; err != nil { return err -- cgit v1.2.3-54-g00ecf