From: Adam C. Emerson Date: Mon, 1 Feb 2016 15:40:54 +0000 (-0500) Subject: time: Have skewing-now call non-skewing now X-Git-Tag: v10.0.4~30^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0fcb3070acc4e07f6e920f7db703e5e90819a1ff;p=ceph.git 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 --- diff --git a/src/common/ceph_time.cc b/src/common/ceph_time.cc index a18a31657f5..886016552c5 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,