From: Samuel Just Date: Fri, 24 Jul 2015 22:38:18 +0000 (-0700) Subject: Log::reopen_log_file: take m_flush_mutex X-Git-Tag: v9.1.0~473^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5348%2Fhead;p=ceph.git 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 --- diff --git a/src/log/Log.cc b/src/log/Log.cc index a450953e71d6..3dc6c631061a 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -120,6 +120,8 @@ void Log::set_log_file(string fn) 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()) { @@ -127,6 +129,8 @@ void Log::reopen_log_file() } else { m_fd = -1; } + m_flush_mutex_holder = 0; + pthread_mutex_unlock(&m_flush_mutex); } void Log::set_syslog_level(int log, int crash)