]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/Timer: use mono_clock for clock_t
authorKefu Chai <kchai@redhat.com>
Wed, 3 Feb 2021 17:34:44 +0000 (01:34 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 4 Feb 2021 11:26:52 +0000 (19:26 +0800)
commit1972bd9a06c1e59bd823a597bd4bcc7790008a55
tree1e26bdf6e892b4ab01fa6d6942830da45d294ff3
parent50ec7c3a53b3cfe83b5ac8fc42cc28127e113dda
common/Timer: use mono_clock for clock_t

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>
src/common/Timer.h