From 99e63f761a50158ba1913d8f814010895db826a7 Mon Sep 17 00:00:00 2001 From: Zhi Zhang Date: Fri, 11 Jan 2019 12:58:34 +0800 Subject: [PATCH] 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 --- src/common/HeartbeatMap.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc index 8c9313ac953fa..a211eb1471fd8 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; } } } -- 2.39.5