Skip to content

Commit

Permalink
close journald when reading
Browse files Browse the repository at this point in the history
when reading from journald, we need to close the journal handler for
events and logging.

Fixes: #8864

Signed-off-by: baude <[email protected]>
  • Loading branch information
baude committed Jan 4, 2021
1 parent f261bfc commit 002d0d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libpod/events/journal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
if err != nil {
return err
}

defer func() {
if err := j.Close(); err != nil {
logrus.Errorf("Unable to close journal :%v", err)
}
}()
// match only podman journal entries
podmanJournal := sdjournal.Match{Field: "SYSLOG_IDENTIFIER", Value: "podman"}
if err := j.AddMatch(podmanJournal.String()); err != nil {
Expand Down Expand Up @@ -112,7 +116,6 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
if err != nil {
return errors.Wrap(err, "failed to get journal cursor")
}

for {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 002d0d6

Please sign in to comment.