From 5ecef4d6f55f50e0287569025949c1e48facffd4 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 25 Oct 2022 12:16:04 +0200 Subject: [PATCH] Fix ocache closing --- common/pkg/ocache/ocache.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/pkg/ocache/ocache.go b/common/pkg/ocache/ocache.go index 41555e42..629a5864 100644 --- a/common/pkg/ocache/ocache.go +++ b/common/pkg/ocache/ocache.go @@ -409,9 +409,13 @@ func (c *oCache) Close() (err error) { } c.closed = true close(c.closeCh) - var toClose []*entry + var toClose, alreadyClosing []*entry for _, e := range c.data { - toClose = append(toClose, e) + if e.isClosing { + alreadyClosing = append(alreadyClosing, e) + } else { + toClose = append(toClose, e) + } } c.mu.Unlock() for _, e := range toClose { @@ -422,5 +426,8 @@ func (c *oCache) Close() (err error) { } } } + for _, e := range alreadyClosing { + <-e.close + } return nil }