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 }