You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-11-19 22:02:09 +03:00
fix(correctness): replace volatiles with atomics
This commit is contained in:
committed by
Leonid Fedorov
parent
c5e3b847ab
commit
2f0f5a79b6
@@ -173,9 +173,8 @@ bool isWESConfigured(config::Config* config, const std::string& fOtherEnd)
|
||||
|
||||
namespace WriteEngine
|
||||
{
|
||||
WEClients::WEClients(int PrgmID) : fPrgmID(PrgmID), pmCount(0)
|
||||
WEClients::WEClients(int PrgmID) : fPrgmID(PrgmID), closingConnection{0}, pmCount(0)
|
||||
{
|
||||
closingConnection = 0;
|
||||
Setup();
|
||||
}
|
||||
|
||||
@@ -317,7 +316,7 @@ bool WEClients::isConnectionReadonly(uint32_t connection)
|
||||
int WEClients::Close()
|
||||
{
|
||||
makeBusy(false);
|
||||
closingConnection = 1;
|
||||
closingConnection.store(1, std::memory_order_relaxed);
|
||||
ByteStream bs;
|
||||
bs << (ByteStream::byte)WE_SVR_CLOSE_CONNECTION;
|
||||
write_to_all(bs);
|
||||
@@ -356,7 +355,7 @@ void WEClients::Listen(boost::shared_ptr<MessageQueueClient> client, uint32_t co
|
||||
}
|
||||
else // got zero bytes on read, nothing more will come
|
||||
{
|
||||
if (closingConnection > 0)
|
||||
if (closingConnection.load() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -390,7 +389,7 @@ Error:
|
||||
for (map_tok = fSessionMessages.begin(); map_tok != fSessionMessages.end(); ++map_tok)
|
||||
{
|
||||
map_tok->second->queue.clear();
|
||||
(void)atomicops::atomicInc(&map_tok->second->unackedWork[0]);
|
||||
map_tok->second->unackedWork[0].fetch_add(1, std::memory_order_relaxed);
|
||||
map_tok->second->queue.push(sbs);
|
||||
}
|
||||
|
||||
@@ -425,9 +424,7 @@ void WEClients::addQueue(uint32_t key)
|
||||
|
||||
boost::mutex* lock = new boost::mutex();
|
||||
condition* cond = new condition();
|
||||
boost::shared_ptr<MQE> mqe(new MQE(pmCount));
|
||||
|
||||
mqe->queue = WESMsgQueue(lock, cond);
|
||||
boost::shared_ptr<MQE> mqe(new MQE(pmCount, lock, cond));
|
||||
|
||||
boost::mutex::scoped_lock lk(fMlock);
|
||||
b = fSessionMessages.insert(pair<uint32_t, boost::shared_ptr<MQE> >(key, mqe)).second;
|
||||
@@ -562,7 +559,7 @@ void WEClients::addDataToOutput(SBS sbs, uint32_t connIndex)
|
||||
|
||||
if (pmCount > 0)
|
||||
{
|
||||
atomicops::atomicInc(&mqe->unackedWork[connIndex % pmCount]);
|
||||
mqe->unackedWork[connIndex % pmCount].fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
(void)mqe->queue.push(sbs);
|
||||
|
||||
Reference in New Issue
Block a user