summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-11-25 18:39:26 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-11-25 18:39:26 +0100
commitbf596a9abd6dc05b0d15e8401d267696632350a4 (patch)
tree4ad06a26bea1e80ba292f516da3afb34478d5af6 /src/lib
parentaee22e3b33e3e051cbc0f99ca033faf5fac22990 (diff)
downloadouroboros-bf596a9abd6dc05b0d15e8401d267696632350a4.tar.gz
ouroboros-bf596a9abd6dc05b0d15e8401d267696632350a4.zip
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.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/time_utils.c4
1 files changed, 2 insertions, 2 deletions
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);
}