]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/HeartbeatMap: no health check if heartbeat_file is empty 25888/head
authorZhi Zhang <willzzhang@tencent.com>
Fri, 11 Jan 2019 04:58:34 +0000 (12:58 +0800)
committerZhi Zhang <willzzhang@tencent.com>
Fri, 11 Jan 2019 04:58:34 +0000 (12:58 +0800)
CephContext service thread will also do health check. But if
heartbeat_file is empty, this health check is useless. So try to check
heartbeat_file first and then do health check.

Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
src/common/HeartbeatMap.cc

index 8c9313ac953fa4dfbc3539962cb20095fd98023b..a211eb1471fd8be417d3beac47ae5c9f453b43c4 100644 (file)
@@ -167,17 +167,15 @@ int HeartbeatMap::get_total_workers() const
 
 void HeartbeatMap::check_touch_file()
 {
-  if (is_healthy()) {
-    string path = m_cct->_conf->heartbeat_file;
-    if (path.length()) {
-      int fd = ::open(path.c_str(), O_WRONLY|O_CREAT|O_CLOEXEC, 0644);
-      if (fd >= 0) {
-       ::utimes(path.c_str(), NULL);
-       ::close(fd);
-      } else {
-       ldout(m_cct, 0) << "unable to touch " << path << ": "
-                       << cpp_strerror(errno) << dendl;
-      }
+  string path = m_cct->_conf->heartbeat_file;
+  if (path.length() && is_healthy()) {
+    int fd = ::open(path.c_str(), O_WRONLY|O_CREAT|O_CLOEXEC, 0644);
+    if (fd >= 0) {
+      ::utimes(path.c_str(), NULL);
+      ::close(fd);
+    } else {
+      ldout(m_cct, 0) << "unable to touch " << path << ": "
+                     << cpp_strerror(errno) << dendl;
     }
   }
 }