From b8e3f6e190809febf80af66415862e7c7e415214 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 24 Jul 2015 15:38:18 -0700 Subject: [PATCH] Log::reopen_log_file: take m_flush_mutex 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 (cherry picked from commit 8778ab3a1ced7fab07662248af0c773df759653d) - modified to drop m_flush_mutex_holder, which isn't present in firefly --- src/log/Log.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/log/Log.cc b/src/log/Log.cc index 37bb4ef6d72f4..392b2c0389974 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -112,6 +112,7 @@ void Log::set_log_file(string fn) 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()) { @@ -119,6 +120,7 @@ void Log::reopen_log_file() } else { m_fd = -1; } + pthread_mutex_unlock(&m_flush_mutex); } void Log::set_syslog_level(int log, int crash) -- 2.39.5