]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Log::reopen_log_file: take m_flush_mutex 5348/head
authorSamuel Just <sjust@redhat.com>
Fri, 24 Jul 2015 22:38:18 +0000 (15:38 -0700)
committerSamuel Just <sjust@redhat.com>
Fri, 24 Jul 2015 22:38:20 +0000 (15:38 -0700)
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>
src/log/Log.cc

index a450953e71d6b4e6fd2307776f6d4ec8f607fb0a..3dc6c631061a5385d7b85f5dc1b46f01b0e30da4 100644 (file)
@@ -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)