From 2f4af09c01dc9580c6ea9533776d5ecf754c8125 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 28 Feb 2021 20:09:23 -0800 Subject: [PATCH] fix: alow changes to readAllData to decrement activeCount() --- cmd/xl-storage.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 8ad38818a..a0f9ce6be 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -1190,7 +1190,16 @@ func (s *xlStorage) readAllData(volumeDir string, filePath string, requireDirect } atomic.AddInt32(&s.activeIOCount, 1) - rd := &odirectReader{f, nil, nil, true, true, s, nil} + or := &odirectReader{f, nil, nil, true, true, s, nil} + rd := struct { + io.Reader + io.Closer + }{Reader: or, Closer: closeWrapper(func() error { + defer func() { + atomic.AddInt32(&s.activeIOCount, -1) + }() + return or.Close() + })} defer rd.Close() // activeIOCount is decremented in Close() buf, err = ioutil.ReadAll(rd)