Use std::atomic for Rdb::m_isDumping

This commit is contained in:
Ai Lin Chia
2017-05-03 10:14:24 +02:00
parent 5ff827ac26
commit 52191466a0
2 changed files with 6 additions and 15 deletions

17
Rdb.cpp

@ -744,14 +744,10 @@ void Rdb::submitRdbDumpJob(bool forceDump) {
}
// bail if already dumping
{
ScopedLock sl(m_isDumpingMtx);
if (m_isDumping) {
logTrace(g_conf.m_logTraceRdb, "END. %s: Already dumping. Returning", m_dbname);
return;
}
m_isDumping = true;
bool isDumping =m_isDumping.exchange(true);
if (isDumping) {
logTrace(g_conf.m_logTraceRdb, "END. %s: Already dumping. Returning", m_dbname);
return;
}
s_rdbDumpThreadQueue.addItem(this);
@ -994,10 +990,7 @@ void Rdb::doneDumping ( ) {
// . we have to set this here otherwise RdbMem's memory ring buffer
// will think the dumping is no longer going on and use the primary
// memory for allocating new titleRecs and such and that is not good!
{
ScopedLock sl(m_isDumpingMtx);
m_isDumping = false;
}
m_isDumping = false;
// try merge for all, first one that needs it will do it, preventing
// the rest from doing it

4
Rdb.h

@ -225,8 +225,6 @@ public:
// rebuilt files, pointed to by rdb2.
bool updateToRebuildFiles ( Rdb *rdb2 , char *coll ) ;
GbMutex m_isDumpingMtx;
private:
bool addRdbBase2 ( collnum_t collnum );
void addBase(collnum_t collnum, RdbBase *base);
@ -311,7 +309,7 @@ private:
// set to true when dumping tree so RdbMem does not use the memory
// being dumped to hold newly added records
bool m_isDumping;
std::atomic<bool> m_isDumping;
rdbid_t m_rdbId;