Use monotonic clocks

This commit is contained in:
Quentin 2020-02-01 08:42:48 +01:00
parent bd44330177
commit 466ec311f2
2 changed files with 4 additions and 4 deletions

View file

@ -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);
}

View file

@ -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);