From a58186c82a0650f2fe7b3c804b97a6962cab93f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 19 Jul 2022 10:04:59 +0200 Subject: [PATCH] Use the right memory ordering in SafeNumeric operations (cherry picked from commit 02a584d8e68fad988fbbe43e05f8437284c00733) --- core/safe_refcount.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/safe_refcount.h b/core/safe_refcount.h index a1c753a52..e787452f2 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -112,7 +112,7 @@ public: if (tmp >= p_value) { return tmp; // already greater, or equal } - if (value.compare_exchange_weak(tmp, p_value, std::memory_order_release)) { + if (value.compare_exchange_weak(tmp, p_value, std::memory_order_acq_rel)) { return p_value; } } @@ -124,7 +124,7 @@ public: if (c == 0) { return 0; } - if (value.compare_exchange_weak(c, c + 1, std::memory_order_release)) { + if (value.compare_exchange_weak(c, c + 1, std::memory_order_acq_rel)) { return c + 1; } }