mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 16:47:41 +00:00
LibPthread: Correct nonsensical loop exit condition in RWLock unlock
The loop should terminate after the exchange happens, we shouldn't repeat the operation until the count hits zero. Fixes #10241.
This commit is contained in:
parent
b63ea3bad1
commit
72a45a472a
1 changed files with 3 additions and 2 deletions
|
@ -781,8 +781,9 @@ int pthread_rwlock_unlock(pthread_rwlock_t* lockval_p)
|
||||||
--count;
|
--count;
|
||||||
auto desired = (current & 0xffff0000u) | count;
|
auto desired = (current & 0xffff0000u) | count;
|
||||||
auto did_exchange = AK::atomic_compare_exchange_strong(lockp, current, desired, AK::MemoryOrder::memory_order_release);
|
auto did_exchange = AK::atomic_compare_exchange_strong(lockp, current, desired, AK::MemoryOrder::memory_order_release);
|
||||||
if (!did_exchange)
|
if (did_exchange)
|
||||||
continue; // tough luck, try again.
|
break;
|
||||||
|
// tough luck, try again.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, unlocked at last!
|
// Finally, unlocked at last!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue