diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-11-06 17:14:44 +0100 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-12-10 10:45:50 -0500 |
commit | 1368eaf1ba88b26c612f3fec809584c686cdd596 (patch) | |
tree | 84c48dee0e13911d0bf735a197a7f367d1f1476a /libpod/events | |
parent | 1fc82393323fcdca45d0291babae1df05e7b49ff (diff) | |
download | podman-1368eaf1ba88b26c612f3fec809584c686cdd596.tar.gz podman-1368eaf1ba88b26c612f3fec809584c686cdd596.tar.bz2 podman-1368eaf1ba88b26c612f3fec809584c686cdd596.zip |
events: make sure the write channel is always closed
in case of errors, the channel is not closed, blocking the reader
indefinitely.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1767663
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/events')
-rw-r--r-- | libpod/events/journal_linux.go | 2 | ||||
-rw-r--r-- | libpod/events/logfile.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go index 470c76959..9e6fffc29 100644 --- a/libpod/events/journal_linux.go +++ b/libpod/events/journal_linux.go @@ -54,6 +54,7 @@ func (e EventJournalD) Write(ee Event) error { // Read reads events from the journal and sends qualified events to the event channel func (e EventJournalD) Read(options ReadOptions) error { + defer close(options.EventChannel) eventOptions, err := generateEventOptions(options.Filters, options.Since, options.Until) if err != nil { return errors.Wrapf(err, "failed to generate event options") @@ -87,7 +88,6 @@ func (e EventJournalD) Read(options ReadOptions) error { if err != nil { return err } - defer close(options.EventChannel) for { if _, err := j.Next(); err != nil { return err diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 4b65b0ad0..93e6fa3c9 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -41,6 +41,7 @@ func (e EventLogFile) Write(ee Event) error { // Reads from the log file func (e EventLogFile) Read(options ReadOptions) error { + defer close(options.EventChannel) eventOptions, err := generateEventOptions(options.Filters, options.Since, options.Until) if err != nil { return errors.Wrapf(err, "unable to generate event options") @@ -68,7 +69,6 @@ func (e EventLogFile) Read(options ReadOptions) error { options.EventChannel <- event } } - close(options.EventChannel) return nil } |