Otherwise, _flush() might continue to write to m_fd after it's closed.
This might cause log data to go to a data object if the filestore then
reuses the fd during that time.
Fixes: #12465
Backport: firefly, hammer
Signed-off-by: Samuel Just <sjust@redhat.com>
void Log::reopen_log_file()
{
+ pthread_mutex_lock(&m_flush_mutex);
+ m_flush_mutex_holder = pthread_self();
if (m_fd >= 0)
VOID_TEMP_FAILURE_RETRY(::close(m_fd));
if (m_log_file.length()) {
} else {
m_fd = -1;
}
+ m_flush_mutex_holder = 0;
+ pthread_mutex_unlock(&m_flush_mutex);
}
void Log::set_syslog_level(int log, int crash)