diff options
| author | chrislu <chris.lu@gmail.com> | 2023-12-22 14:16:23 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2023-12-22 14:16:23 -0800 |
| commit | 03c4b2e9880765746bd47520d613515336a3f679 (patch) | |
| tree | 24d1622b2d162c9311e238439dd4310950445439 /weed/util/lock_table.go | |
| parent | c4badf73962f70072cdbb3a83756de7bc5da4b1e (diff) | |
| download | seaweedfs-03c4b2e9880765746bd47520d613515336a3f679.tar.xz seaweedfs-03c4b2e9880765746bd47520d613515336a3f679.zip | |
correct lock accounting
possibly fix https://github.com/seaweedfs/seaweedfs/issues/5082
Diffstat (limited to 'weed/util/lock_table.go')
| -rw-r--r-- | weed/util/lock_table.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/util/lock_table.go b/weed/util/lock_table.go index bf3da7c37..efc4114e7 100644 --- a/weed/util/lock_table.go +++ b/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() |
