From 058647f9c23babf9a1ad38a0738695cf65825273 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 28 Jul 2011 09:10:17 -0700 Subject: [PATCH] heartbeatmap: simplify api reset_timeout(), clear_timeout() makes more sense than "touch". Signed-off-by: Sage Weil --- src/common/HeartbeatMap.cc | 10 ++++++++-- src/common/HeartbeatMap.h | 4 +++- src/common/WorkQueue.cc | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc index 8e47b590c4631..3f15b3829cfc3 100644 --- a/src/common/HeartbeatMap.cc +++ b/src/common/HeartbeatMap.cc @@ -53,12 +53,18 @@ void HeartbeatMap::remove_worker(heartbeat_handle_d *h) delete h; } -void HeartbeatMap::touch_worker(heartbeat_handle_d *h, time_t grace) +void HeartbeatMap::reset_timeout(heartbeat_handle_d *h, time_t grace) { - ldout(m_cct, 20) << "touch_worker " << h->thread << " grace " << grace << dendl; + ldout(m_cct, 20) << "reset_timeout " << h->thread << " grace " << grace << dendl; h->timeout = time(NULL) + grace; } +void HeartbeatMap::clear_timeout(heartbeat_handle_d *h) +{ + ldout(m_cct, 20) << "clear_timeout " << h->thread << dendl; + h->timeout = 0; +} + bool HeartbeatMap::is_healthy() { m_rwlock.get_read(); diff --git a/src/common/HeartbeatMap.h b/src/common/HeartbeatMap.h index 5299e36f0ea17..fe0b932b55682 100644 --- a/src/common/HeartbeatMap.h +++ b/src/common/HeartbeatMap.h @@ -40,7 +40,9 @@ class HeartbeatMap { public: heartbeat_handle_d *add_worker(pthread_t thread, std::string name); void remove_worker(heartbeat_handle_d *h); - void touch_worker(heartbeat_handle_d *h, time_t grace); + + void reset_timeout(heartbeat_handle_d *h, time_t grace); + void clear_timeout(heartbeat_handle_d *h); bool is_healthy(); diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 2d4f3a930fd6e..b7d7e14b78a13 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -50,7 +50,7 @@ void ThreadPool::worker() processing++; ldout(cct,12) << "worker wq " << wq->name << " start processing " << item << dendl; _lock.Unlock(); - cct->get_heartbeat_map()->touch_worker(hb, wq->timeout_interval); + cct->get_heartbeat_map()->reset_timeout(hb, wq->timeout_interval); wq->_void_process(item); _lock.Lock(); wq->_void_process_finish(item); @@ -67,7 +67,7 @@ void ThreadPool::worker() } ldout(cct,15) << "worker waiting" << dendl; - cct->get_heartbeat_map()->touch_worker(hb, 4); + cct->get_heartbeat_map()->reset_timeout(hb, 4); _cond.WaitInterval(cct, _lock, utime_t(2, 0)); } ldout(cct,0) << "worker finish" << dendl; -- 2.39.5