1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-21 09:20:51 +03:00

fix(correctness): replace volatiles with atomics

This commit is contained in:
Leonid Fedorov
2025-10-27 15:40:05 +00:00
committed by Leonid Fedorov
parent c5e3b847ab
commit 2f0f5a79b6
36 changed files with 233 additions and 181 deletions

View File

@@ -54,7 +54,7 @@ namespace
boost::mutex CacheOpsMutex;
// This global is updated only w/ atomic ops
volatile uint32_t MultiReturnCode;
std::atomic<uint32_t> MultiReturnCode;
int32_t extractRespCode(const ByteStream& bs)
{
@@ -95,7 +95,10 @@ class CacheOpThread
}
if (rc != 0)
atomicops::atomicCAS<uint32_t>(&MultiReturnCode, 0, 1);
{
uint32_t expected = 0;
MultiReturnCode.compare_exchange_strong(expected, 1, std::memory_order_relaxed);
}
}
private:
@@ -123,7 +126,7 @@ int sendToAll(const ByteStream& outBs)
thread_group tg;
int rc = 0;
MultiReturnCode = 0;
MultiReturnCode.store(0, std::memory_order_relaxed);
for (int i = 0; i < cnt; i++)
{
@@ -134,7 +137,7 @@ int sendToAll(const ByteStream& outBs)
tg.join_all();
if (MultiReturnCode != 0)
if (MultiReturnCode.load(std::memory_order_relaxed) != 0)
rc = -1;
return rc;