mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
correct lock accounting
possibly fix https://github.com/seaweedfs/seaweedfs/issues/5082
This commit is contained in:
parent
c4badf7396
commit
03c4b2e988
|
@ -132,6 +132,12 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lock.lockType == ExclusiveLock {
|
||||||
|
entry.activeExclusiveLockOwnerCount--
|
||||||
|
} else {
|
||||||
|
entry.activeSharedLockOwnerCount--
|
||||||
|
}
|
||||||
|
|
||||||
// If there are no waiters, release the lock
|
// If there are no waiters, release the lock
|
||||||
if len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 {
|
if len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 {
|
||||||
delete(lt.locks, key)
|
delete(lt.locks, key)
|
||||||
|
@ -146,11 +152,6 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lock.lockType == ExclusiveLock {
|
|
||||||
entry.activeExclusiveLockOwnerCount--
|
|
||||||
} else {
|
|
||||||
entry.activeSharedLockOwnerCount--
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the next waiter
|
// Notify the next waiter
|
||||||
entry.cond.Broadcast()
|
entry.cond.Broadcast()
|
||||||
|
|
Loading…
Reference in a new issue