mon/MgrMonitor: cancel timer before resetting it

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-05-16 17:16:51 +08:00
parent 33494b27f7
commit a80ff0128a
2 changed files with 11 additions and 4 deletions

View 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();
}

View 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);