]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
log: invalidate m_fd on close
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 25 Oct 2022 14:26:36 +0000 (10:26 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 27 Oct 2022 15:09:42 +0000 (11:09 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/log/Log.cc

index da645ce8b404c6bf669bee9ed4745a93db0d671a..78bedf03cfa4e62a1ad4941dc143215a73bd9364 100644 (file)
@@ -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;
+  }
 }
 
 
@@ -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)) {
@@ -127,8 +131,6 @@ void Log::reopen_log_file()
             << std::endl;
       }
     }
-  } else {
-    m_fd = -1;
   }
   m_flush_mutex_holder = 0;
 }