From 49f93972172dc5ab807abab6c97718380a0580ee Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 9 Apr 2018 11:15:05 -0400 Subject: [PATCH] Do not lock all containers during pod kill Signed-off-by: Matthew Heon Closes: #600 Approved by: rhatdan --- libpod/pod.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libpod/pod.go b/libpod/pod.go index e6a2ba3dc8..2126e9228c 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -298,26 +298,26 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) { return nil, err } - // We need to lock all the containers - for _, ctr := range allCtrs { - ctr.lock.Lock() - defer ctr.lock.Unlock() - - if err := ctr.syncContainer(); err != nil { - return nil, err - } - } - ctrErrors := make(map[string]error) // Send a signal to all containers for _, ctr := range allCtrs { + ctr.lock.Lock() + + if err := ctr.syncContainer(); err != nil { + ctr.lock.Unlock() + ctrErrors[ctr.ID()] = err + continue + } + // Ignore containers that are not running if ctr.state.State != ContainerStateRunning { + ctr.lock.Unlock() continue } if err := ctr.runtime.ociRuntime.killContainer(ctr, signal); err != nil { + ctr.lock.Unlock() ctrErrors[ctr.ID()] = err continue }