]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Log::reopen_log_file: take m_flush_mutex 5406/head
authorSamuel Just <sjust@redhat.com>
Fri, 24 Jul 2015 22:38:18 +0000 (15:38 -0700)
committerSage Weil <sage@redhat.com>
Mon, 27 Jul 2015 13:35:48 +0000 (09:35 -0400)
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

src/log/Log.cc

index 37bb4ef6d72f4b1055756068908e1a26f064fae0..392b2c0389974c85d9a1bb43dd15b969d570253e 100644 (file)
@@ -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)