Fix ocache closing

This commit is contained in:
mcrakhman authored and Mikhail Iudin committed 2022-10-25 12:16:04 +02:00
1 parent ddae2be2a1
commit 5ecef4d6f5
1 file changed
+9 -2
+9 -2
View File
@@ -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
}