]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
time: Have skewing-now call non-skewing now
authorAdam C. Emerson <aemerson@redhat.com>
Mon, 1 Feb 2016 15:40:54 +0000 (10:40 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Fri, 5 Feb 2016 16:21:41 +0000 (11:21 -0500)
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 <aemerson@redhat.com>
src/common/ceph_time.cc

index a18a31657f585a80932b611ac3812dd7c600c066..886016552c5a59dda998cbee208715d01538759e 100644 (file)
 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,