Increase to 20 before warning about db queue size. Put lock in it's own scope so that we unlock before notifying
This commit is contained in:
parent
67556430c6
commit
77d3109152
|
@ -251,11 +251,11 @@ void zmDbQueue::process() {
|
||||||
mCondition.wait(lock);
|
mCondition.wait(lock);
|
||||||
}
|
}
|
||||||
while (!mQueue.empty()) {
|
while (!mQueue.empty()) {
|
||||||
if (mQueue.size() > 10) {
|
if (mQueue.size() > 20) {
|
||||||
Logger *log = Logger::fetch();
|
Logger *log = Logger::fetch();
|
||||||
Logger::Level db_level = log->databaseLevel();
|
Logger::Level db_level = log->databaseLevel();
|
||||||
log->databaseLevel(Logger::NOLOG);
|
log->databaseLevel(Logger::NOLOG);
|
||||||
Warning("db queue size has grown larger %zu than 10 entries", mQueue.size());
|
Warning("db queue size has grown larger %zu than 20 entries", mQueue.size());
|
||||||
log->databaseLevel(db_level);
|
log->databaseLevel(db_level);
|
||||||
}
|
}
|
||||||
std::string sql = mQueue.front();
|
std::string sql = mQueue.front();
|
||||||
|
@ -271,8 +271,10 @@ void zmDbQueue::process() {
|
||||||
|
|
||||||
void zmDbQueue::push(std::string &&sql) {
|
void zmDbQueue::push(std::string &&sql) {
|
||||||
if (mTerminate) return;
|
if (mTerminate) return;
|
||||||
|
{
|
||||||
std::unique_lock<std::mutex> lock(mMutex);
|
std::unique_lock<std::mutex> lock(mMutex);
|
||||||
mQueue.push(std::move(sql));
|
mQueue.push(std::move(sql));
|
||||||
|
}
|
||||||
mCondition.notify_all();
|
mCondition.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue