From 7bc1f986e8864d9bdcec2fd997f47e6baafb2faf Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 22 Mar 2022 09:37:01 -0700 Subject: [PATCH] Do not wait for results when canceled (#14607) When canceled nobody may be listening for the results. Prevents memory buildup from cancelled requests. --- cmd/metacache-set.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/metacache-set.go b/cmd/metacache-set.go index eb96c44a2..7b0473f48 100644 --- a/cmd/metacache-set.go +++ b/cmd/metacache-set.go @@ -189,7 +189,11 @@ func (o *listPathOptions) gatherResults(ctx context.Context, in <-chan metaCache } if resCh != nil { resErr = io.EOF - resCh <- results + select { + case <-ctx.Done(): + // Nobody wants it. + case resCh <- results: + } } }() return func() (metaCacheEntriesSorted, error) {