Skip to content

Commit

Permalink
Merge pull request #16448 from openshift-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-16327-to-v4.3

[v4.3] Fix deadlock between 'podman ps' and 'container inspect' commands
  • Loading branch information
baude authored Nov 8, 2022
2 parents 3266e73 + 560dbcc commit 6b49e1d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions libpod/pod_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,20 +581,15 @@ func (p *Pod) Status() (map[string]define.ContainerStatus, error) {
}

func containerStatusFromContainers(allCtrs []*Container) (map[string]define.ContainerStatus, error) {
// We need to lock all the containers
for _, ctr := range allCtrs {
ctr.lock.Lock()
defer ctr.lock.Unlock()
}

// Now that all containers are locked, get their status
status := make(map[string]define.ContainerStatus, len(allCtrs))
for _, ctr := range allCtrs {
if err := ctr.syncContainer(); err != nil {
state, err := ctr.State()

if err != nil {
return nil, err
}

status[ctr.ID()] = ctr.state.State
status[ctr.ID()] = state
}

return status, nil
Expand Down

0 comments on commit 6b49e1d

Please sign in to comment.