Skip to content

Commit

Permalink
runtime: unlock the alive lock only once
Browse files Browse the repository at this point in the history
Unlock the alive lock only once in the deferred func call.

Fixes: containers#3207
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
  • Loading branch information
vrothberg committed May 28, 2019
1 parent 25f8c21 commit 238fe6f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,12 +877,9 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
// TODO: we can't close the FD in this lock, so we should keep it around
// and use it to lock important operations
aliveLock.Lock()
locked := true
doRefresh := false
defer func() {
if locked {
aliveLock.Unlock()
}
aliveLock.Unlock()
}()

_, err = os.Stat(runtimeAliveFile)
Expand All @@ -891,7 +888,6 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
// no containers running. Create immediately a namespace, as
// we will need to access the storage.
if os.Geteuid() != 0 {
aliveLock.Unlock()
pausePid, err := util.GetRootlessPauseProcessPidPath()
if err != nil {
return errors.Wrapf(err, "could not get pause process pid file path")
Expand Down

0 comments on commit 238fe6f

Please sign in to comment.