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>
(cherry picked from commit
8778ab3a1ced7fab07662248af0c773df759653d)
- modified to drop m_flush_mutex_holder, which isn't present in firefly
void Log::reopen_log_file()
{
+ pthread_mutex_lock(&m_flush_mutex);
if (m_fd >= 0)
VOID_TEMP_FAILURE_RETRY(::close(m_fd));
if (m_log_file.length()) {
} else {
m_fd = -1;
}
+ pthread_mutex_unlock(&m_flush_mutex);
}
void Log::set_syslog_level(int log, int crash)