summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-11-28 13:06:32 -0500
committerMatthew Heon <mheon@redhat.com>2018-12-06 09:10:45 -0500
commitb945d9128a0988ee006a8c743127cf1edc9cb47b (patch)
tree15032732e911b98697a5592c4071249b770d1366
parent28bead8be8eb541cf0c78e6ee3a3963adc8d1d3a (diff)
downloadpodman-b945d9128a0988ee006a8c743127cf1edc9cb47b.tar.gz
podman-b945d9128a0988ee006a8c743127cf1edc9cb47b.tar.bz2
podman-b945d9128a0988ee006a8c743127cf1edc9cb47b.zip
Add locking to Sync() on containers
Previously not needed as it only worked inside of Batch(), but now that it can be called anywhere we need to add mutual exclusion on its config changes. Signed-off-by: Matthew Heon <mheon@redhat.com>
-rw-r--r--libpod/container_api.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index ee060ad6a..09bc46905 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -685,6 +685,11 @@ func (c *Container) Batch(batchFunc func(*Container) error) error {
// Running a manual Sync() ensures that container state will be correct in
// such situations.
func (c *Container) Sync() error {
+ if !c.batched {
+ c.lock.Lock()
+ defer c.lock.Unlock()
+ }
+
// If runtime knows about the container, update its status in runtime
// And then save back to disk
if (c.state.State != ContainerStateUnknown) &&