summaryrefslogtreecommitdiff
path: root/libpod/events/logfile.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-04-25 16:23:09 -0400
committerMatthew Heon <mheon@redhat.com>2019-04-25 16:23:09 -0400
commit04d6ff058270006b98961e0f973ff6ee4c3ba8e8 (patch)
treea929615470ee8c220f95512f194054d145656be7 /libpod/events/logfile.go
parenta01c62fcbde1afdc77aa05b71c3c84ddacf7fc55 (diff)
downloadpodman-04d6ff058270006b98961e0f973ff6ee4c3ba8e8.tar.gz
podman-04d6ff058270006b98961e0f973ff6ee4c3ba8e8.tar.bz2
podman-04d6ff058270006b98961e0f973ff6ee4c3ba8e8.zip
Add System event type and renumber, refresh events
Also, re-add locking to file eventer Write() to protect against concurrent events. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/events/logfile.go')
-rw-r--r--libpod/events/logfile.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go
index 3232b86d0..e5efc09bb 100644
--- a/libpod/events/logfile.go
+++ b/libpod/events/logfile.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ "github.com/containers/storage"
"github.com/pkg/errors"
)
@@ -15,6 +16,13 @@ type EventLogFile struct {
// Writes to the log file
func (e EventLogFile) Write(ee Event) error {
+ // We need to lock events file
+ lock, err := storage.GetLockfile(e.options.LogFilePath + ".lock")
+ if err != nil {
+ return err
+ }
+ lock.Lock()
+ defer lock.Unlock()
f, err := os.OpenFile(e.options.LogFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0700)
if err != nil {
return err