Skip to content

Commit

Permalink
Merge pull request containers#2115 from rhatdan/shm
Browse files Browse the repository at this point in the history
If you fail to open shm lock then attempt to create it
  • Loading branch information
openshift-merge-robot authored Jan 9, 2019
2 parents c37f731 + 8c25a64 commit a60090c
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,25 +692,19 @@ 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())
}
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 {
// 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 {
return err
}
}
Expand Down

0 comments on commit a60090c

Please sign in to comment.