diff --git a/src/common/classes/rwlock.h b/src/common/classes/rwlock.h index 02479020e1..eff0d13a0c 100644 --- a/src/common/classes/rwlock.h +++ b/src/common/classes/rwlock.h @@ -112,13 +112,13 @@ public: { if (lock.value() < 0) return false; - if (++lock > 0) + if (lock.exchangeAdd(1) >= 0) { reason(aReason); return true; } // We stepped on writer's toes. Fix our mistake - if (--lock == 0) + if (lock.exchangeAdd(-1) == 1) unblockWaiting(); return false; }