From 827ac0859f9649a971c6d4092fcd26158afa5478 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 27 Jun 2019 12:56:29 +0200 Subject: lock: new lock type "file" it is a wrapper around containers/storage file locking. Signed-off-by: Giuseppe Scrivano --- libpod/runtime.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libpod/runtime.go') diff --git a/libpod/runtime.go b/libpod/runtime.go index e8442f4a1..ca10f9243 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -318,6 +318,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { NumLocks: 2048, EventsLogger: events.DefaultEventerType.String(), DetachKeys: DefaultDetachKeys, + LockType: "shm", }, nil } @@ -664,6 +665,20 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) { var manager lock.Manager switch runtime.config.LockType { + case "file": + lockPath := filepath.Join(runtime.config.TmpDir, "locks") + manager, err = lock.OpenFileLockManager(lockPath) + if err != nil { + if os.IsNotExist(errors.Cause(err)) { + manager, err = lock.NewFileLockManager(lockPath) + if err != nil { + return nil, errors.Wrapf(err, "failed to get new file lock manager") + } + } else { + return nil, err + } + } + case "", "shm": lockPath := DefaultSHMLockPath if rootless.IsRootless() { -- cgit v1.2.3-54-g00ecf