Browse Source

correct lock accounting

possibly fix https://github.com/seaweedfs/seaweedfs/issues/5082
pull/5132/head
chrislu 1 year ago
parent
commit
03c4b2e988
  1. 11
      weed/util/lock_table.go

11
weed/util/lock_table.go

@ -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 len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 {
delete(lt.locks, key)
@ -146,11 +152,6 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
fmt.Printf("\n")
}
}
if lock.lockType == ExclusiveLock {
entry.activeExclusiveLockOwnerCount--
} else {
entry.activeSharedLockOwnerCount--
}
// Notify the next waiter
entry.cond.Broadcast()

Loading…
Cancel
Save