From: Kefu Chai Date: Tue, 16 May 2017 09:20:11 +0000 (+0800) Subject: mon/MgrMonitor: use mono clock to avoid potention issue introduced by time skew X-Git-Tag: v12.1.0~10^2~71^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15109%2Fhead;p=ceph.git mon/MgrMonitor: use mono clock to avoid potention issue introduced by time skew Signed-off-by: Kefu Chai --- diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index de3c27a245a1..aa816d4a495a 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -187,7 +187,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) } } - last_beacon[m->get_gid()] = ceph_clock_now(); + last_beacon[m->get_gid()] = ceph::coarse_mono_clock::now(); // Track whether we modified pending_map bool updated = false; @@ -357,9 +357,8 @@ void MgrMonitor::tick() if (!is_active() || !mon->is_leader()) return; - const utime_t now = ceph_clock_now(); - utime_t cutoff = now; - cutoff -= g_conf->mon_mgr_beacon_grace; + const auto now = ceph::coarse_mono_clock::now(); + const auto cutoff = now - std::chrono::seconds(g_conf->mon_mgr_beacon_grace); // Populate any missing beacons (i.e. no beacon since MgrMonitor // instantiation) with the current time, so that they will diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index 280fca5bd1e2..af3c1aeaffc0 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -24,7 +24,7 @@ class MgrMonitor : public PaxosService utime_t first_seen_inactive; - std::map last_beacon; + std::map last_beacon; /** * If a standby is available, make it active, given that