From c1f7c0bcd54a6f0e09670e0c090ddef6ce769991 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 21 Mar 2019 22:17:04 +0000 Subject: [PATCH] Polarity of the weak flag was wrong. We want to use the strong variant of atomic_compare_exchange always Former-commit-id: ab9122f2cb910bb5560a9fde16bc3c096ecfb510 --- src/fastlock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 1a8d51165..6dd2893bb 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -113,7 +113,7 @@ extern "C" int fastlock_trylock(struct fastlock *lock) struct ticket ticket_expect { active, active }; struct ticket ticket_setiflocked { active, next }; - if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, true /*strong*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) + if (__atomic_compare_exchange(&lock->m_ticket, &ticket_expect, &ticket_setiflocked, false /*strong*/, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { lock->m_depth = 1; __atomic_store_4(&lock->m_pidOwner, gettid(), __ATOMIC_RELEASE); @@ -147,4 +147,4 @@ extern "C" void fastlock_free(struct fastlock *lock) bool fastlock::fOwnLock() { return gettid() == m_pidOwner; -} \ No newline at end of file +}