fix(evolution): add ok check for LoadOrStore type assertion in lockStoreFile
This commit is contained in:
parent
b9a8fad6fa
commit
f5add27d39
1 changed files with 10 additions and 1 deletions
|
|
@ -555,7 +555,16 @@ func isInvalidJSON(err error) bool {
|
|||
|
||||
func lockStoreFile(path string) func() {
|
||||
actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{})
|
||||
mu := actual.(*sync.Mutex)
|
||||
mu, ok := actual.(*sync.Mutex)
|
||||
if !ok {
|
||||
// Delete the corrupted entry so that the next LoadOrStore
|
||||
// atomically creates a fresh mutex. Multiple goroutines may
|
||||
// race to Delete, but LoadOrStore ensures they all converge
|
||||
// on the same mutex before entering the critical section.
|
||||
storeFileLocks.Delete(path)
|
||||
actual, _ = storeFileLocks.LoadOrStore(path, &sync.Mutex{})
|
||||
mu = actual.(*sync.Mutex)
|
||||
}
|
||||
mu.Lock()
|
||||
return mu.Unlock
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue