2
0
mirror of synced 2025-02-23 22:28:11 +00:00

Fix race in sqlite direct storage init

There's a race between starting the blob flusher and assigning the timer to the storage client.
This commit is contained in:
Matt Joiner 2021-08-11 09:43:40 +10:00
parent 88c0a85e44
commit 87294355fb

View File

@ -58,6 +58,9 @@ func NewDirectStorage(opts NewDirectStorageOpts) (_ storage.ClientImplCloser, er
blobs: make(map[string]*sqlite.Blob),
opts: opts,
}
// Avoid race with cl.blobFlusherFunc
cl.l.Lock()
defer cl.l.Unlock()
if opts.BlobFlushInterval != 0 {
cl.blobFlusher = time.AfterFunc(opts.BlobFlushInterval, cl.blobFlusherFunc)
}