kernel/lock: Reinstate ASSERT_UNLOCKED_RW_LOCK in _rw_lock_read_lock.
This reverts commit 13a5c7f91f,
and adds an inline comment explaining why this actually isn't allowed,
despite "working" in most circumstances.
Doesn't affect anything in default builds (KDEBUG_RW_LOCK_DEBUG
is not enabled under KDEBUG.)
This commit is contained in:
@@ -512,6 +512,7 @@ _rw_lock_read_lock(rw_lock* lock)
|
|||||||
#if KDEBUG_RW_LOCK_DEBUG
|
#if KDEBUG_RW_LOCK_DEBUG
|
||||||
int32 oldCount = atomic_add(&lock->count, 1);
|
int32 oldCount = atomic_add(&lock->count, 1);
|
||||||
if (oldCount < RW_LOCK_WRITER_COUNT_BASE) {
|
if (oldCount < RW_LOCK_WRITER_COUNT_BASE) {
|
||||||
|
ASSERT_UNLOCKED_RW_LOCK(lock);
|
||||||
_rw_lock_set_read_locked(lock);
|
_rw_lock_set_read_locked(lock);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -525,6 +526,10 @@ _rw_lock_read_lock(rw_lock* lock)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we hold a read lock already, but some other thread is waiting
|
||||||
|
// for a write lock, then trying to read-lock again will deadlock.
|
||||||
|
ASSERT_UNLOCKED_RW_LOCK(lock);
|
||||||
|
|
||||||
// The writer that originally had the lock when we called atomic_add() might
|
// The writer that originally had the lock when we called atomic_add() might
|
||||||
// already have gone and another writer could have overtaken us. In this
|
// already have gone and another writer could have overtaken us. In this
|
||||||
// case the original writer set pending_readers, so we know that we don't
|
// case the original writer set pending_readers, so we know that we don't
|
||||||
|
|||||||
Reference in New Issue
Block a user