From a9813336b184def70cac44932e15e092b56e520c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 28 Jul 2011 09:50:53 -0700 Subject: [PATCH] ceph_context: only wake up periodically if heartbeat_interval is set Signed-off-by: Sage Weil --- src/common/ceph_context.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 4b3b0685c4341..1581d06f8768d 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -46,11 +46,14 @@ public: void *entry() { while (1) { - struct timespec timeout; - clock_gettime(CLOCK_REALTIME, &timeout); - timeout.tv_sec += _cct->_conf->heartbeat_interval; - - sem_timedwait(&_sem, &timeout); + if (_cct->_conf->heartbeat_interval) { + struct timespec timeout; + clock_gettime(CLOCK_REALTIME, &timeout); + timeout.tv_sec += _cct->_conf->heartbeat_interval; + sem_timedwait(&_sem, &timeout); + } else { + sem_wait(&_sem); + } if (_exit_thread) { break; } -- 2.39.5