From 466ec311f2597a569be97c4959842daf6f2756ba Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Sat, 1 Feb 2020 08:42:48 +0100 Subject: [PATCH] Use monotonic clocks --- src/evt_core.c | 4 ++-- src/timer.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evt_core.c b/src/evt_core.c index 3460731..1c9df76 100644 --- a/src/evt_core.c +++ b/src/evt_core.c @@ -215,7 +215,7 @@ void timing_fx_start(struct timing_fx* tfx, ...) { va_end(args); } - if (clock_gettime(CLOCK_REALTIME, &tfx->start) == -1) { + if (clock_gettime(CLOCK_MONOTONIC, &tfx->start) == -1) { perror("clock_gettime"); exit(EXIT_FAILURE); } @@ -228,7 +228,7 @@ double timing_fx_stop(struct timing_fx* tfx, ...) { if (!(tfx->config & TIMING_ACTIVATED)) return 0.; - if (clock_gettime(CLOCK_REALTIME, &stop) == -1) { + if (clock_gettime(CLOCK_MONOTONIC, &stop) == -1) { perror("clock_gettime"); exit(EXIT_FAILURE); } diff --git a/src/timer.c b/src/timer.c index fe5a065..de613f2 100644 --- a/src/timer.c +++ b/src/timer.c @@ -55,7 +55,7 @@ int set_timeout(struct evt_core_ctx* evts, uint64_t milli_sec, void* ctx, timer_ fdinfo.url = url; //printf("Will add a timeout of %ld ms\n", milli_sec); - if (clock_gettime(CLOCK_REALTIME, &now) == -1) { + if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) { perror("clock_gettime"); exit(EXIT_FAILURE); } @@ -66,7 +66,7 @@ int set_timeout(struct evt_core_ctx* evts, uint64_t milli_sec, void* ctx, timer_ timer_config.it_interval.tv_sec = 60; timer_config.it_interval.tv_nsec = 0; - fdinfo.fd = timerfd_create(CLOCK_REALTIME, 0); + fdinfo.fd = timerfd_create(CLOCK_MONOTONIC, 0); if (fdinfo.fd == -1) { perror("Unable to timerfd_create"); exit(EXIT_FAILURE);