Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock between 'podman ps' and 'container inspect' commands #16327

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, I saw this comment and my assumption is this is not correct now. Please let me know if I am wrong.

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