From 3cef598fc2b2d75ceb02ea8546327b03bc927b55 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 27 May 2020 13:51:48 +0200 Subject: container stats: fix --no-stream race Fix a race in `podman container stats` by waiting for the client to consume the data in the channel. This requires a `sync.WaitGroup` (or semaphore) in the client and to also close the channel the backend. Fixes: #6405 Signed-off-by: Valentin Rothberg --- pkg/domain/infra/abi/containers.go | 1 + 1 file changed, 1 insertion(+) (limited to 'pkg/domain') diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index b4e38ca23..e982c7c11 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -1087,6 +1087,7 @@ func (ic *ContainerEngine) Shutdown(_ context.Context) { } func (ic *ContainerEngine) ContainerStats(ctx context.Context, namesOrIds []string, options entities.ContainerStatsOptions) error { + defer close(options.StatChan) containerFunc := ic.Libpod.GetRunningContainers switch { case len(namesOrIds) > 0: -- cgit v1.2.3-54-g00ecf