there is chance that the system clock is adjust by chrony or ntpd, so that
a timer scheduled at epoch time 12:34 would never get scheduled if
the system clock is changed to 12:35 when the system clock is still
12:33.
if we have event which schedules itself when it is fired, there is
chance that this event could be put in a black hole if the system clock
is adjusted in the way explained above. this could be a serious issue
if we rely on the timer to do critical things.
but we *might* suffer from this issue even if we use mono_clock for
clock_t in Timer, because in older libstdc++ and libc++,
condition_variable::wait_until() and condition_variable::wait_for() were
still using pthread_cond_timedwait(). this is fixed after glibc
introduced pthread_cond_clockwait() in v2.3.0. for more details, see
https://reviews.llvm.org/D65339 and
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg00190.html
Signed-off-by: Kefu Chai <kchai@redhat.com>
void timer_thread();
void _shutdown();
- using clock_t = ceph::real_clock;
+ using clock_t = ceph::mono_clock;
using scheduled_map_t = std::multimap<clock_t::time_point, Context*>;
scheduled_map_t schedule;
using event_lookup_map_t = std::map<Context*, scheduled_map_t::iterator>;