1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Merge pull request #516 from mariadb-corporation/MCOL-1037

MCOL-1037 Fix race condition in FIFO buffer
This commit is contained in:
Roman Nozdrin
2018-07-18 12:03:00 +03:00
committed by GitHub
2 changed files with 11 additions and 2 deletions

View File

@@ -345,17 +345,27 @@ void FIFO<element_t>::signalPs()
template<typename element_t>
inline bool FIFO<element_t>::next(uint64_t id, element_t *out)
{
base::mutex.lock();
fConsumptionStarted = true;
if (cpos[id] >= fMaxElements)
{
base::mutex.unlock();
if (!waitForSwap(id))
return false;
base::mutex.lock();
}
*out = cBuffer[cpos[id]++];
#ifndef ONE_CS
if (cpos[id] == fMaxElements)
{
base::mutex.unlock();
signalPs();
return true;
}
#endif
base::mutex.unlock();
return true;
}