}
while (1) {
- int_fast32_t cntflag2 = 0;
- atomic_compare_exchange_strong_explicit
- (&rwl->cnt_and_flag, &cntflag2, WRITER_ACTIVE,
- memory_order_relaxed, memory_order_relaxed);
-
- if (cntflag2 == 0)
+ int_fast32_t zero = 0;
+ if (atomic_compare_exchange_strong_explicit
+ (&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
+ memory_order_relaxed, memory_order_relaxed))
+ {
break;
+ }
/* Another active reader or writer is working. */
LOCK(&rwl->lock);
if (!atomic_compare_exchange_strong_explicit
(&rwl->cnt_and_flag, &zero, WRITER_ACTIVE,
memory_order_relaxed, memory_order_relaxed))
+ {
return (ISC_R_LOCKBUSY);
+ }
/*
* XXXJT: jump into the queue, possibly breaking the writer