From 16a5cbfac580c875dfde95ce29ac90f150b0b6f7 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 3 Jan 2019 10:43:19 -0500 Subject: When refreshing libpod, if SHM locks exist, remove them This will hopefully help cases where libpod is initialized multiple times on the same system (as on our CI tests). We still run into potential issues where multiple Podmans with multiple tmp paths try to run on the same system - we could end up thrashing the locks. I think we need a file locks driver for situations like that. We can also see about storing paths in the SHM segment, to make sure multiple libpod instances aren't using the same one. Signed-off-by: Matthew Heon --- libpod/runtime.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libpod/runtime.go b/libpod/runtime.go index ae4b77bd4..59264d0f5 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -540,6 +540,11 @@ func makeRuntime(runtime *Runtime) (err error) { lockPath = DefaultRootlessSHMLockPath } 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 errors.Wrapf(err, "error creating SHM locks for libpod") -- cgit v1.2.3-54-g00ecf