From 0fcb3070acc4e07f6e920f7db703e5e90819a1ff Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Mon, 1 Feb 2016 10:40:54 -0500 Subject: [PATCH] time: Have skewing-now call non-skewing now For the real-time clocks, Ceph's testing infrastructure likes to be able to inject a skew. To avoid pulling CephContext into ceph_time.h these are moved to ceph_time.cc. The original way this was done called clock_gettime in both places. This is an unnecessary duplication and apparently error-prone. So only call clock_gettime from one place. Signed-off-by: Adam C. Emerson --- src/common/ceph_time.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/common/ceph_time.cc b/src/common/ceph_time.cc index a18a31657f58..886016552c5a 100644 --- a/src/common/ceph_time.cc +++ b/src/common/ceph_time.cc @@ -22,13 +22,10 @@ namespace ceph { namespace time_detail { real_clock::time_point real_clock::now(const CephContext* cct) noexcept { - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - // TODO: After we get the time-literal configuration patch in, - // just add the configured duration. + auto t = now(); if (cct) - ts.tv_sec += cct->_conf->clock_offset; - return from_timespec(ts); + t += make_timespan(cct->_conf->clock_offset); + return t; } void real_clock::to_ceph_timespec(const time_point& t, @@ -48,13 +45,10 @@ namespace ceph { coarse_real_clock::time_point coarse_real_clock::now( const CephContext* cct) noexcept { - struct timespec ts; - clock_gettime(CLOCK_REALTIME_COARSE, &ts); - // TODO: After we get the time-literal configuration patch in, - // just add the configured duration. + auto t = now(); if (cct) - ts.tv_sec += cct->_conf->clock_offset; - return from_timespec(ts); + t += make_timespan(cct->_conf->clock_offset); + return t; } void coarse_real_clock::to_ceph_timespec(const time_point& t, -- 2.47.3