mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #16327 from tyler92/fix-deadlock-pod-ps-inspect
Fix deadlock between 'podman ps' and 'container inspect' commands
This commit is contained in:
@ -581,20 +581,15 @@ func (p *Pod) Status() (map[string]define.ContainerStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func containerStatusFromContainers(allCtrs []*Container) (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))
|
status := make(map[string]define.ContainerStatus, len(allCtrs))
|
||||||
for _, ctr := range allCtrs {
|
for _, ctr := range allCtrs {
|
||||||
if err := ctr.syncContainer(); err != nil {
|
state, err := ctr.State()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
status[ctr.ID()] = ctr.state.State
|
status[ctr.ID()] = state
|
||||||
}
|
}
|
||||||
|
|
||||||
return status, nil
|
return status, nil
|
||||||
|
Reference in New Issue
Block a user