summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-07-21 10:55:40 -0400
committerGitHub <noreply@github.com>2020-07-21 10:55:40 -0400
commitf8e2a3500e3daadf21137d1647cabf9ef20b2114 (patch)
treea4825917b192332599841cdcc41096af39a4b474 /libpod
parent644b5bc8a35760654824c46cad8618e0d6e634bc (diff)
parentdea93c27d2809cd5a04563d27cf00a8e682884c8 (diff)
downloadpodman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.tar.gz
podman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.tar.bz2
podman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.zip
Merge pull request #6902 from vrothberg/events-endpoint
events endpoint: fix panic and race condition
Diffstat (limited to 'libpod')
-rw-r--r--libpod/events/journal_linux.go7
-rw-r--r--libpod/events/logfile.go8
2 files changed, 15 insertions, 0 deletions
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go
index d341ca7b5..7c2a3e0f2 100644
--- a/libpod/events/journal_linux.go
+++ b/libpod/events/journal_linux.go
@@ -90,6 +90,13 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
return err
}
for {
+ select {
+ case <-ctx.Done():
+ // the consumer has cancelled
+ return nil
+ default:
+ // fallthrough
+ }
if _, err := j.Next(); err != nil {
return err
}
diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go
index 28d0dc07e..b70102450 100644
--- a/libpod/events/logfile.go
+++ b/libpod/events/logfile.go
@@ -63,6 +63,14 @@ func (e EventLogFile) Read(ctx context.Context, options ReadOptions) error {
}
}()
for line := range t.Lines {
+ select {
+ case <-ctx.Done():
+ // the consumer has cancelled
+ return nil
+ default:
+ // fallthrough
+ }
+
event, err := newEventFromJSONString(line.Text)
if err != nil {
return err