Fix ocache closing

This commit is contained in:
mcrakhman 2022-10-25 12:16:04 +02:00 committed by Mikhail Iudin
parent ddae2be2a1
commit 5ecef4d6f5
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

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
}