1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

cancel context for app.close

This commit is contained in:
Sergey Cherepanov 2022-07-20 13:40:52 +03:00
parent c697059179
commit 90a7e2da1f
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C

View file

@ -78,6 +78,7 @@ type entry struct {
load chan struct{}
loadErr error
value Object
cancel func()
}
type OCache interface {
@ -142,6 +143,7 @@ func (c *oCache) Get(ctx context.Context, id string) (value Object, err error) {
id: id,
load: make(chan struct{}),
}
ctx, e.cancel = context.WithCancel(ctx)
c.data[id] = e
}
e.lastUsage = c.timeNow()
@ -358,6 +360,9 @@ func (c *oCache) Close() (err error) {
}
c.mu.Unlock()
for _, e := range toClose {
if e.cancel != nil {
e.cancel()
}
<-e.load
if e.value != nil {
if clErr := e.value.Close(); clErr != nil {