kernel/lock: Adjust KDEBUG_RW_LOCK_DEBUG logic in _rw_lock_read_unlock.
We need to always decrement the count by 1 even if we own the lock. Seems to fix some intermittent hangs with KDEBUG_RW_LOCK_DEBUG.
This commit is contained in:
@@ -669,22 +669,26 @@ _rw_lock_read_lock_with_timeout(rw_lock* lock, uint32 timeoutFlags,
|
|||||||
void
|
void
|
||||||
_rw_lock_read_unlock(rw_lock* lock)
|
_rw_lock_read_unlock(rw_lock* lock)
|
||||||
{
|
{
|
||||||
|
#if KDEBUG_RW_LOCK_DEBUG
|
||||||
|
int32 oldCount = atomic_add(&lock->count, -1);
|
||||||
|
if (oldCount < RW_LOCK_WRITER_COUNT_BASE) {
|
||||||
|
_rw_lock_unset_read_locked(lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
InterruptsSpinLocker locker(lock->lock);
|
InterruptsSpinLocker locker(lock->lock);
|
||||||
|
|
||||||
// If we're still holding the write lock or if there are other readers,
|
// If we're still holding the write lock or if there are other readers,
|
||||||
// no-one can be woken up.
|
// no-one can be woken up.
|
||||||
if (lock->holder == thread_get_current_thread_id()) {
|
if (lock->holder == thread_get_current_thread_id()) {
|
||||||
ASSERT(lock->owner_count % RW_LOCK_WRITER_COUNT_BASE > 0);
|
ASSERT((lock->owner_count % RW_LOCK_WRITER_COUNT_BASE) > 0);
|
||||||
lock->owner_count--;
|
lock->owner_count--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if KDEBUG_RW_LOCK_DEBUG
|
#if KDEBUG_RW_LOCK_DEBUG
|
||||||
_rw_lock_unset_read_locked(lock);
|
_rw_lock_unset_read_locked(lock);
|
||||||
|
|
||||||
int32 oldCount = atomic_add(&lock->count, -1);
|
|
||||||
if (oldCount < RW_LOCK_WRITER_COUNT_BASE)
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (--lock->active_readers > 0)
|
if (--lock->active_readers > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user