mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
Merge pull request #3053 from chengzhichao-xydt/codex/store-lock-type-assert
fix(evolution): add ok check for LoadOrStore type assertion in lockStoreFile
This commit is contained in:
+14
-4
@@ -558,10 +558,20 @@ func isInvalidJSON(err error) bool {
|
||||
}
|
||||
|
||||
func lockStoreFile(path string) func() {
|
||||
actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{})
|
||||
mu := actual.(*sync.Mutex)
|
||||
mu.Lock()
|
||||
return mu.Unlock
|
||||
for {
|
||||
actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{})
|
||||
mu, ok := actual.(*sync.Mutex)
|
||||
if !ok || mu == nil {
|
||||
// Corrupted entry (wrong type or nil *sync.Mutex).
|
||||
// Atomically swap in a fresh mutex via CompareAndSwap.
|
||||
// If CAS fails, another goroutine already replaced it —
|
||||
// just retry the loop to pick up the valid entry.
|
||||
storeFileLocks.CompareAndSwap(path, actual, &sync.Mutex{})
|
||||
continue
|
||||
}
|
||||
mu.Lock()
|
||||
return mu.Unlock
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Store) profilePath(workspaceID, skillName string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user