diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-02 20:41:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 20:41:31 +0200 |
commit | 55e028a12ee003e057c65e376fe4b723d28ae52e (patch) | |
tree | 0b9edad592e217bc0ad549f2c906766520a95613 /libpod/runtime_ctr.go | |
parent | 26d02e97395b2fb5ab5abdc0a35ab6019dccbe18 (diff) | |
parent | fdd98d58b8a03c76f25dfc39d238f7697450d2bd (diff) | |
download | podman-55e028a12ee003e057c65e376fe4b723d28ae52e.tar.gz podman-55e028a12ee003e057c65e376fe4b723d28ae52e.tar.bz2 podman-55e028a12ee003e057c65e376fe4b723d28ae52e.zip |
Merge pull request #3461 from mheon/free_locks_on_fail
Ensure locks are freed when ctr/pod creation fails
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r-- | libpod/runtime_ctr.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 0d0f700a6..9daac161c 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -132,6 +132,14 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container, restore bo ctr.config.LockID = ctr.lock.ID() logrus.Debugf("Allocated lock %d for container %s", ctr.lock.ID(), ctr.ID()) + defer func() { + if err != nil { + if err2 := ctr.lock.Free(); err2 != nil { + logrus.Errorf("Error freeing lock for container after creation failed: %v", err2) + } + } + }() + ctr.valid = true ctr.state.State = config2.ContainerStateConfigured ctr.runtime = r |