From bf596a9abd6dc05b0d15e8401d267696632350a4 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 25 Nov 2016 18:39:26 +0100 Subject: ipcpd, lib: Fix timerwheel issues / time_utils Timerwheel would skip some additions due to a missed wakeup signal. Addition of timespecs and timevals in the time utilities would overflow tv_nsec/tv_usec if the sum is an integer number of seconds. --- src/lib/time_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/time_utils.c b/src/lib/time_utils.c index b34e4763..4da935c4 100644 --- a/src/lib/time_utils.c +++ b/src/lib/time_utils.c @@ -39,7 +39,7 @@ int ts_add(const struct timespec * t, nanos = t->tv_nsec + intv->tv_nsec; res->tv_sec = t->tv_sec + intv->tv_sec; - while (nanos > BILLION) { + while (nanos >= BILLION) { nanos -= BILLION; ++(res->tv_sec); } @@ -85,7 +85,7 @@ int tv_add(const struct timeval * t, micros = t->tv_usec + intv->tv_usec; res->tv_sec = t->tv_sec + intv->tv_sec; - while (micros > MILLION) { + while (micros >= MILLION) { micros -= MILLION; --(res->tv_sec); } -- cgit v1.2.3