Skip to content

Commit

Permalink
time: Have skewing-now call non-skewing now
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
adamemerson committed Feb 1, 2016
1 parent 64fbda8 commit 5477424
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/common/ceph_time.cc
Expand Up @@ -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);
now += seconds(cct->_conf->clock_offset);
return t;
}

void real_clock::to_ceph_timespec(const time_point& t,
Expand All @@ -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);
now += += seconds(cct->_conf->clock_offset);
return t;
}

void coarse_real_clock::to_ceph_timespec(const time_point& t,
Expand Down

0 comments on commit 5477424

Please sign in to comment.