From: Zhi Zhang Date: Fri, 11 Jan 2019 04:58:34 +0000 (+0800) Subject: common/HeartbeatMap: no health check if heartbeat_file is empty X-Git-Tag: v14.1.0~396^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F25888%2Fhead;p=ceph.git common/HeartbeatMap: no health check if heartbeat_file is empty 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 --- diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc index 8c9313ac953f..a211eb1471fd 100644 --- a/src/common/HeartbeatMap.cc +++ b/src/common/HeartbeatMap.cc @@ -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; } } }