]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMonitor: cancel timer before resetting it
authorKefu Chai <kchai@redhat.com>
Tue, 16 May 2017 09:16:51 +0000 (17:16 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 16 May 2017 13:50:56 +0000 (21:50 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h

index 1e5f95586893ee731217b18639a704b187477d50..74068dcf130b6975628dff1977c5b1fba245ee38 100644 (file)
@@ -275,7 +275,7 @@ void MgrMonitor::check_sub(Subscription *sub)
  */
 void MgrMonitor::send_digests()
 {
-  digest_event = nullptr;
+  cancel_timer();
 
   const std::string type = "mgrdigest";
   if (mon->session_map.subs.count(type) == 0)
@@ -304,6 +304,14 @@ void MgrMonitor::send_digests()
   mon->timer.add_event_after(g_conf->mon_mgr_digest_period, digest_event);
 }
 
+void MgrMonitor::cancel_timer()
+{
+  if (digest_event) {
+    mon->timer.cancel_event(digest_event);
+    digest_event = nullptr;
+  }
+}
+
 void MgrMonitor::on_active()
 {
   if (mon->is_leader())
@@ -545,7 +553,5 @@ void MgrMonitor::init()
 
 void MgrMonitor::on_shutdown()
 {
-  if (digest_event) {
-    mon->timer.cancel_event(digest_event);
-  }
+  cancel_timer();
 }
index f4e6f9920d707555239c4ac45fd6e45580a55876..280fca5bd1e2eecf6fde3ad67f5bd0a84a8ed221 100644 (file)
@@ -37,6 +37,7 @@ class MgrMonitor : public PaxosService
   void drop_standby(uint64_t gid);
 
   Context *digest_event = nullptr;
+  void cancel_timer();
 
   bool check_caps(MonOpRequestRef op, const uuid_d& fsid);