Skip to content

Commit

Permalink
Log::reopen_log_file: take m_flush_mutex
Browse files Browse the repository at this point in the history
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: ceph#12465
Backport: firefly, hammer
Signed-off-by: Samuel Just <[email protected]>
  • Loading branch information
athanatos committed Jul 24, 2015
1 parent 2746f59 commit 8778ab3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/log/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ 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()) {
m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND, 0644);
} else {
m_fd = -1;
}
m_flush_mutex_holder = 0;
pthread_mutex_unlock(&m_flush_mutex);
}

void Log::set_syslog_level(int log, int crash)
Expand Down

0 comments on commit 8778ab3

Please sign in to comment.