db: start the processing thread after all fields are initialized

Initializing `zmDbQueue::mThread` with initializer list makes the thread
start in the middle of object initialization. This means `zmDbQueue::
process()` could start and reach mCondition.wait(lock); before `std::
wait_condition`'s constructor, which causes deadlock.

To make sure thread won't start before object initialize, move
`mThread`'s initialization to constructor's body.

This _at last_ solves the random zmu deadlock issue that has plagued my
setup for almost a year.
pull/3588/head
Ratchanan Srirattanamet 2022-08-08 03:13:08 +07:00 committed by Isaac Connor
parent 494077eee7
commit 27808888a6
1 changed files with 3 additions and 2 deletions

View File

@ -227,9 +227,10 @@ zmDbRow::~zmDbRow() {
}
zmDbQueue::zmDbQueue() :
mThread(&zmDbQueue::process, this),
mTerminate(false)
{ }
{
mThread = std::thread(&zmDbQueue::process, this);
}
zmDbQueue::~zmDbQueue() {
stop();