From 3a6cd4f73d765feef4b3226cafe047db303375f0 Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Fri, 17 Feb 2023 17:42:43 +0800 Subject: [PATCH] fix: sync.pool won't Put reader back (#16638) --- cmd/metacache-set.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/metacache-set.go b/cmd/metacache-set.go index 2d804f82e..bc98f0d3f 100644 --- a/cmd/metacache-set.go +++ b/cmd/metacache-set.go @@ -523,6 +523,7 @@ func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOpt }() tmp := newMetacacheReader(pr) + defer tmp.Close() e, err := tmp.filter(o) pr.CloseWithError(err) entries.o = append(entries.o, e.o...) @@ -892,6 +893,11 @@ func listPathRaw(ctx context.Context, opts listPathRawOptions) (err error) { } askDisks := len(disks) readers := make([]*metacacheReader, askDisks) + defer func() { + for _, r := range readers { + r.Close() + } + }() for i := range disks { r, w := io.Pipe() // Make sure we close the pipe so blocked writes doesn't stay around.