From 482c8fd9a05f9866664806d4975bd6926c85dbd7 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 10 Jan 2019 15:19:53 -0500 Subject: Revert "If you fail to open shm lock then attempt to create it" --- libpod/runtime.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libpod/runtime.go b/libpod/runtime.go index c9471247c..ab8d02a4f 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -692,19 +692,25 @@ func makeRuntime(runtime *Runtime) (err error) { } } + // Set up the lock manager + var manager lock.Manager lockPath := DefaultSHMLockPath if rootless.IsRootless() { lockPath = fmt.Sprintf("%s_%d", DefaultRootlessSHMLockPath, rootless.GetRootlessUID()) } - // Set up the lock manager - manager, err := lock.OpenSHMLockManager(lockPath, runtime.config.NumLocks) - if err != nil { - if os.IsNotExist(errors.Cause(err)) { - manager, err = lock.NewSHMLockManager(lockPath, runtime.config.NumLocks) - if err != nil { - return err - } - } else { + if doRefresh { + // If SHM locks already exist, delete them and reinitialize + if err := os.Remove(filepath.Join("/dev/shm", lockPath)); err != nil && !os.IsNotExist(err) { + return errors.Wrapf(err, "error deleting existing libpod SHM segment %s", lockPath) + } + + manager, err = lock.NewSHMLockManager(lockPath, runtime.config.NumLocks) + if err != nil { + return err + } + } else { + manager, err = lock.OpenSHMLockManager(lockPath, runtime.config.NumLocks) + if err != nil { return err } } -- cgit v1.2.3-54-g00ecf