fix: sync.pool won't Put reader back (#16638)

This commit is contained in:
jiuker 2023-02-17 17:42:43 +08:00 committed by GitHub
parent 6ea150fd68
commit 3a6cd4f73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -523,6 +523,7 @@ func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOpt
}() }()
tmp := newMetacacheReader(pr) tmp := newMetacacheReader(pr)
defer tmp.Close()
e, err := tmp.filter(o) e, err := tmp.filter(o)
pr.CloseWithError(err) pr.CloseWithError(err)
entries.o = append(entries.o, e.o...) entries.o = append(entries.o, e.o...)
@ -892,6 +893,11 @@ func listPathRaw(ctx context.Context, opts listPathRawOptions) (err error) {
} }
askDisks := len(disks) askDisks := len(disks)
readers := make([]*metacacheReader, askDisks) readers := make([]*metacacheReader, askDisks)
defer func() {
for _, r := range readers {
r.Close()
}
}()
for i := range disks { for i := range disks {
r, w := io.Pipe() r, w := io.Pipe()
// Make sure we close the pipe so blocked writes doesn't stay around. // Make sure we close the pipe so blocked writes doesn't stay around.