Skip to content

Commit

Permalink
Fix deadlock between 'podman ps' and 'container inspect' commands
Browse files Browse the repository at this point in the history
Fixes: #16326

[NO NEW TESTS NEEDED]

Signed-off-by: Mikhail Khachayants <[email protected]>
  • Loading branch information
tyler92 committed Oct 28, 2022
1 parent 84d04a2 commit f355900
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 f355900

Please sign in to comment.