Fix log manager race condition

The log manager could send two messages if a log message was posted soon
before the log manager was stopped. This caused a debug assertion which
then manifested as a deadlock inside the log manager.
This commit is contained in:
Markus Mäkelä
2018-01-03 16:07:21 +02:00
parent e0a584a626
commit e9fceff8ce
3 changed files with 16 additions and 5 deletions

View File

@ -2321,7 +2321,9 @@ static void* thr_filewriter_fun(void* data)
/** Inform log manager about the state. */
skygw_message_send(fwr->fwr_clientmes);
while (!skygw_thread_must_exit(thr))
bool running = true;
do
{
/**
* Wait until new log arrival message appears.
@ -2347,14 +2349,23 @@ static void* thr_filewriter_fun(void* data)
}
}
bool send_message = false;
if (flushall_done_flag)
{
flushall_done_flag = false;
flushall_logfiles(false);
skygw_message_send(fwr->fwr_clientmes);
send_message = true;
}
} /* while (!skygw_thread_must_exit) */
running = !skygw_thread_must_exit(thr);
if (running && send_message)
{
skygw_message_send(fwr->fwr_clientmes);
}
}
while (running);
ss_debug(skygw_thread_set_state(thr, THR_STOPPED));
/** Inform log manager that file writer thread has stopped. */