mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Directly use return value of atomic_compare_exchange_strong_explicit insteaf of comparing expected value
This commit is contained in:
@@ -308,13 +308,13 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int_fast32_t cntflag2 = 0;
|
int_fast32_t zero = 0;
|
||||||
atomic_compare_exchange_strong_explicit
|
if (atomic_compare_exchange_strong_explicit
|
||||||
(&rwl->cnt_and_flag, &cntflag2, WRITER_ACTIVE,
|
(&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
|
||||||
memory_order_relaxed, memory_order_relaxed);
|
memory_order_relaxed, memory_order_relaxed))
|
||||||
|
{
|
||||||
if (cntflag2 == 0)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Another active reader or writer is working. */
|
/* Another active reader or writer is working. */
|
||||||
LOCK(&rwl->lock);
|
LOCK(&rwl->lock);
|
||||||
@@ -409,7 +409,9 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||||||
if (!atomic_compare_exchange_strong_explicit
|
if (!atomic_compare_exchange_strong_explicit
|
||||||
(&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
|
(&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
|
||||||
memory_order_relaxed, memory_order_relaxed))
|
memory_order_relaxed, memory_order_relaxed))
|
||||||
|
{
|
||||||
return (ISC_R_LOCKBUSY);
|
return (ISC_R_LOCKBUSY);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXXJT: jump into the queue, possibly breaking the writer
|
* XXXJT: jump into the queue, possibly breaking the writer
|
||||||
|
Reference in New Issue
Block a user