summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2018-04-12 12:18:02 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-13 16:36:09 +0000
commit4b25039cf4d9f38bbe7e8ed4a2fb3d87cf87e53e (patch)
tree6b38e44fd4c2b247bbdcbde355697f7607d9aeb6 /libpod/container_api.go
parentec90d6f4ccb369f6c50b73626c65d7575e9e503a (diff)
downloadpodman-4b25039cf4d9f38bbe7e8ed4a2fb3d87cf87e53e.tar.gz
podman-4b25039cf4d9f38bbe7e8ed4a2fb3d87cf87e53e.tar.bz2
podman-4b25039cf4d9f38bbe7e8ed4a2fb3d87cf87e53e.zip
Fix locking interaction in batched Exec() on container
Signed-off-by: Matthew Heon <mheon@redhat.com> Closes: #610 Approved by: giuseppe
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 5ebb7b091..bfe20b184 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -376,14 +376,18 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
logrus.Debugf("Successfully started exec session %s in container %s", sessionID, c.ID())
// Unlock so other processes can use the container
- c.lock.Unlock()
- locked = false
+ if !c.locked {
+ c.lock.Unlock()
+ locked = false
+ }
waitErr := execCmd.Wait()
// Lock again
- locked = true
- c.lock.Lock()
+ if !c.locked {
+ locked = true
+ c.lock.Lock()
+ }
// Sync the container again to pick up changes in state
if err := c.syncContainer(); err != nil {