Skip to content

Commit

Permalink
log: invalidate m_fd on close
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
  • Loading branch information
batrick committed Oct 25, 2022
1 parent 8d50bfa commit fbdb2cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/log/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ Log::~Log()
}

ceph_assert(!is_started());
if (m_fd >= 0)
if (m_fd >= 0) {
VOID_TEMP_FAILURE_RETRY(::close(m_fd));
m_fd = -1;
}
}


Expand Down Expand Up @@ -116,8 +118,10 @@ void Log::reopen_log_file()
return;
}
m_flush_mutex_holder = pthread_self();
if (m_fd >= 0)
if (m_fd >= 0) {
VOID_TEMP_FAILURE_RETRY(::close(m_fd));
m_fd = -1;
}
if (m_log_file.length()) {
m_fd = ::open(m_log_file.c_str(), O_CREAT|O_WRONLY|O_APPEND|O_CLOEXEC, 0644);
if (m_fd >= 0 && (m_uid || m_gid)) {
Expand All @@ -127,8 +131,6 @@ void Log::reopen_log_file()
<< std::endl;
}
}
} else {
m_fd = -1;
}
m_flush_mutex_holder = 0;
}
Expand Down

0 comments on commit fbdb2cf

Please sign in to comment.