diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2021-09-07 11:18:13 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2021-09-07 12:46:56 +0200 |
commit | 1eaa449590515a0bb6207316fe5fba734ebde335 (patch) | |
tree | 2cac9a937df56a4d8384ed889bae7d34e1beacef /libpod/container_log.go | |
parent | e095667ac8c2ccaf06dea6d4c61f51d93b736968 (diff) | |
download | podman-1eaa449590515a0bb6207316fe5fba734ebde335.tar.gz podman-1eaa449590515a0bb6207316fe5fba734ebde335.tar.bz2 podman-1eaa449590515a0bb6207316fe5fba734ebde335.zip |
logs -f: file: fix dead lock
Fix a dead lock in the file log driver where one goroutine would wait on
the tail to hit EOF but reading is blocked for the function to return.
Fixes: 11461
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/container_log.go')
-rw-r--r-- | libpod/container_log.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go index 3988bb654..89dd5e8b0 100644 --- a/libpod/container_log.go +++ b/libpod/container_log.go @@ -107,16 +107,18 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption // until EOF. state, err := c.State() if err != nil || state != define.ContainerStateRunning { - // Make sure to wait at least for the poll duration - // before stopping the file logger (see #10675). - time.Sleep(watch.POLL_DURATION) - tailError := t.StopAtEOF() - if tailError != nil && fmt.Sprintf("%v", tailError) != "tail: stop at eof" { - logrus.Errorf("Error stopping logger: %v", tailError) - } if err != nil && errors.Cause(err) != define.ErrNoSuchCtr { logrus.Errorf("Error getting container state: %v", err) } + go func() { + // Make sure to wait at least for the poll duration + // before stopping the file logger (see #10675). + time.Sleep(watch.POLL_DURATION) + tailError := t.StopAtEOF() + if tailError != nil && tailError.Error() != "tail: stop at eof" { + logrus.Errorf("Error stopping logger: %v", tailError) + } + }() return nil } |