From: W.C.A. Wijngaards Date: Thu, 1 Aug 2019 14:48:41 +0000 (+0200) Subject: - Fix to timeval_add for remaining second in microseconds. X-Git-Tag: release-1.9.3rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df0c844eed5459a20ce5304547cbe7cbd5864002;p=thirdparty%2Funbound.git - Fix to timeval_add for remaining second in microseconds. --- diff --git a/daemon/stats.c b/daemon/stats.c index 504b0efcc..a01fb6d34 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -77,7 +77,7 @@ stats_timeval_add(long long* d_sec, long long* d_usec, long long add_sec, long l #ifndef S_SPLINT_S (*d_sec) += add_sec; (*d_usec) += add_usec; - if((*d_usec) > 1000000) { + if((*d_usec) >= 1000000) { (*d_usec) -= 1000000; (*d_sec)++; } diff --git a/doc/Changelog b/doc/Changelog index e6b0de40d..4348a3d0e 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,7 @@ - Fix #52 #53, fix for example fail program. - Fix to return after failed auth zone http chunk write. - Fix to remove unused test for task_probe existance. + - Fix to timeval_add for remaining second in microseconds. 29 July 2019: Wouter - Add verbose log message when auth zone file is written, at level 4. diff --git a/services/mesh.c b/services/mesh.c index 0d7118af9..27f919401 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -85,7 +85,7 @@ timeval_add(struct timeval* d, const struct timeval* add) #ifndef S_SPLINT_S d->tv_sec += add->tv_sec; d->tv_usec += add->tv_usec; - if(d->tv_usec > 1000000 ) { + if(d->tv_usec >= 1000000 ) { d->tv_usec -= 1000000; d->tv_sec++; } diff --git a/testcode/delayer.c b/testcode/delayer.c index 4abcfc235..655e4a1e7 100644 --- a/testcode/delayer.c +++ b/testcode/delayer.c @@ -174,7 +174,7 @@ dl_tv_add(struct timeval* t1, const struct timeval* t2) #ifndef S_SPLINT_S t1->tv_sec += t2->tv_sec; t1->tv_usec += t2->tv_usec; - while(t1->tv_usec > 1000000) { + while(t1->tv_usec >= 1000000) { t1->tv_usec -= 1000000; t1->tv_sec++; } diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 713e24759..d6e904a4d 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -100,7 +100,7 @@ timeval_add(struct timeval* d, const struct timeval* add) #ifndef S_SPLINT_S d->tv_sec += add->tv_sec; d->tv_usec += add->tv_usec; - if(d->tv_usec > 1000000) { + if(d->tv_usec >= 1000000) { d->tv_usec -= 1000000; d->tv_sec++; } diff --git a/testcode/perf.c b/testcode/perf.c index d6d2b0529..5b170ca57 100644 --- a/testcode/perf.c +++ b/testcode/perf.c @@ -177,7 +177,7 @@ perf_tv_add(struct timeval* t1, struct timeval* t2) #ifndef S_SPLINT_S t1->tv_sec += t2->tv_sec; t1->tv_usec += t2->tv_usec; - while(t1->tv_usec > 1000000) { + while(t1->tv_usec >= 1000000) { t1->tv_usec -= 1000000; t1->tv_sec++; } diff --git a/util/mini_event.c b/util/mini_event.c index faadf1a23..661d88d2e 100644 --- a/util/mini_event.c +++ b/util/mini_event.c @@ -313,7 +313,7 @@ int event_add(struct event* ev, struct timeval* tv) struct timeval *now = ev->ev_base->time_tv; ev->ev_timeout.tv_sec = tv->tv_sec + now->tv_sec; ev->ev_timeout.tv_usec = tv->tv_usec + now->tv_usec; - while(ev->ev_timeout.tv_usec > 1000000) { + while(ev->ev_timeout.tv_usec >= 1000000) { ev->ev_timeout.tv_usec -= 1000000; ev->ev_timeout.tv_sec++; } diff --git a/util/winsock_event.c b/util/winsock_event.c index 63d98796d..de6c28ecb 100644 --- a/util/winsock_event.c +++ b/util/winsock_event.c @@ -558,7 +558,7 @@ int event_add(struct event *ev, struct timeval *tv) struct timeval *now = ev->ev_base->time_tv; ev->ev_timeout.tv_sec = tv->tv_sec + now->tv_sec; ev->ev_timeout.tv_usec = tv->tv_usec + now->tv_usec; - while(ev->ev_timeout.tv_usec > 1000000) { + while(ev->ev_timeout.tv_usec >= 1000000) { ev->ev_timeout.tv_usec -= 1000000; ev->ev_timeout.tv_sec++; }