summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-02-18 16:20:02 -0500
committerMatthew Heon <matthew.heon@pm.me>2019-02-21 10:51:42 -0500
commitd2b77f8b3397b3ffbbade6e04e37b291105028aa (patch)
tree40d0e6423be80a66e5ea848a89fe23d4fda90d5e /libpod/runtime.go
parente0a6873d78be969a50a1939f52c81264b9547ac0 (diff)
downloadpodman-d2b77f8b3397b3ffbbade6e04e37b291105028aa.tar.gz
podman-d2b77f8b3397b3ffbbade6e04e37b291105028aa.tar.bz2
podman-d2b77f8b3397b3ffbbade6e04e37b291105028aa.zip
Do not make renumber shut down the runtime
The original intent behind the requirement was to ensure that, if two SHM lock structs were open at the same time, we should not make such a runtime available to the user, and should clean it up instead. It turns out that we don't even need to open a second SHM lock struct - if we get an error mapping the first one due to a lock count mismatch, we can just delete it, and it cleans itself up when it errors. So there's no reason not to return a valid runtime. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 850df4fc9..94dbf37dd 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -95,8 +95,16 @@ type Runtime struct {
lockManager lock.Manager
configuredFrom *runtimeConfiguredFrom
+ // doRenumber indicates that the runtime should perform a lock renumber
+ // during initialization.
+ // Once the runtime has been initialized and returned, this variable is
+ // unused.
doRenumber bool
+ // valid indicates whether the runtime is ready to use.
+ // valid is set to true when a runtime is returned from GetRuntime(),
+ // and remains true until the runtime is shut down (rendering its
+ // storage unusable). When valid is false, the runtime cannot be used.
valid bool
lock sync.RWMutex
}
@@ -784,7 +792,9 @@ func makeRuntime(runtime *Runtime) (err error) {
if err != nil {
return err
}
- } else if err == syscall.ERANGE && runtime.doRenumber {
+ } else if errors.Cause(err) == syscall.ERANGE && runtime.doRenumber {
+ logrus.Debugf("Number of locks does not match - removing old locks")
+
// ERANGE indicates a lock numbering mismatch.
// Since we're renumbering, this is not fatal.
// Remove the earlier set of locks and recreate.
@@ -806,7 +816,9 @@ func makeRuntime(runtime *Runtime) (err error) {
// It breaks out of normal runtime init, and will not return a valid
// runtime.
if runtime.doRenumber {
- return runtime.renumberLocks()
+ if err := runtime.renumberLocks(); err != nil {
+ return err
+ }
}
// If we need to refresh the state, do it now - things are guaranteed to