summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-08-23 15:13:41 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-01-04 09:51:09 -0500
commit3de560053f4b391c8386554160f61a2a086c1564 (patch)
tree0903fde38cc39d0b0041643cb8e04a5f2727902f /libpod/container_internal.go
parenta364b656eaef1be5329abfd02d3fcd2dbcd37d64 (diff)
downloadpodman-3de560053f4b391c8386554160f61a2a086c1564.tar.gz
podman-3de560053f4b391c8386554160f61a2a086c1564.tar.bz2
podman-3de560053f4b391c8386554160f61a2a086c1564.zip
Convert containers to SHM locking
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 6c027f59a..856313b9d 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -401,7 +401,10 @@ func resetState(state *containerState) error {
return nil
}
-// Refresh refreshes the container's state after a restart
+// Refresh refreshes the container's state after a restart.
+// Refresh cannot perform any operations that would lock another container.
+// We cannot guarantee any other container has a valid lock at the time it is
+// running.
func (c *Container) refresh() error {
// Don't need a full sync, but we do need to update from the database to
// pick up potentially-missing container state
@@ -447,6 +450,14 @@ func (c *Container) refresh() error {
c.state.DestinationRunDir = filepath.Join(c.state.UserNSRoot, "rundir")
}
+ // We need to pick up a new lock
+ lock, err := c.runtime.lockManager.AllocateLock()
+ if err != nil {
+ return errors.Wrapf(err, "error acquiring lock for container %s", c.ID())
+ }
+ c.lock = lock
+ c.config.LockID = c.lock.ID()
+
if err := c.save(); err != nil {
return errors.Wrapf(err, "error refreshing state for container %s", c.ID())
}