From 3ca6d2e5a260b3b3f62d9cfe53b14c397eaa17f7 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 18 Sep 2008 07:55:01 +0000 Subject: [PATCH] Fixup error in time calculation. git-svn-id: file:///svn/unbound/trunk@1247 be551aaa-1e26-0410-a405-d3ace91eadb9 --- contrib/unbound_munin_ | 2 -- daemon/remote.c | 12 +++++++----- daemon/stats.c | 2 +- doc/Changelog | 3 +++ services/mesh.c | 13 +++++++------ testcode/fake_event.c | 2 +- util/timehist.c | 2 +- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contrib/unbound_munin_ b/contrib/unbound_munin_ index c30df4780..8ea7a7646 100755 --- a/contrib/unbound_munin_ +++ b/contrib/unbound_munin_ @@ -125,8 +125,6 @@ get_state ( ) { if test $now -lt `expr $value + $lee`; then return fi - #@@@ DEBUG - return fi $ctrl -c $conf stats > $state if test $? -ne 0; then diff --git a/daemon/remote.c b/daemon/remote.c index adde3fec2..3c9ac1f19 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -91,21 +91,23 @@ log_crypto_err(const char* str) /** subtract timers and the values do not overflow or become negative */ static void -timeval_subtract(struct timeval* d, struct timeval* end, struct timeval* start) +timeval_subtract(struct timeval* d, const struct timeval* end, + const struct timeval* start) { #ifndef S_SPLINT_S + time_t end_usec = end->tv_usec;; d->tv_sec = end->tv_sec - start->tv_sec; - while(end->tv_usec < start->tv_usec) { - end->tv_usec += 1000000; + while(end_usec < start->tv_usec) { + end_usec += 1000000; d->tv_sec--; } - d->tv_usec = end->tv_usec - start->tv_usec; + d->tv_usec = end_usec - start->tv_usec; #endif } /** divide sum of timers to get average */ static void -timeval_divide(struct timeval* avg, struct timeval* sum, size_t d) +timeval_divide(struct timeval* avg, const struct timeval* sum, size_t d) { #ifndef S_SPLINT_S size_t leftover; diff --git a/daemon/stats.c b/daemon/stats.c index 89f9e5fd8..247621299 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -53,7 +53,7 @@ /** add timers and the values do not overflow or become negative */ static void -timeval_add(struct timeval* d, struct timeval* add) +timeval_add(struct timeval* d, const struct timeval* add) { #ifndef S_SPLINT_S d->tv_sec += add->tv_sec; diff --git a/doc/Changelog b/doc/Changelog index 6f665d4a8..1357ef70b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +18 September 2008: Wouter + - fixup error in time calculation. + 17 September 2008: Wouter - locking for threadsafe bogus rrset counter. - ldns trunk no longer exports b32 functions, provide compat. diff --git a/services/mesh.c b/services/mesh.c index c50bae7fe..1ec60cfd7 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -58,21 +58,22 @@ /** subtract timers and the values do not overflow or become negative */ static void -timeval_subtract(struct timeval* d, struct timeval* end, struct timeval* start) +timeval_subtract(struct timeval* d, const struct timeval* end, const struct timeval* start) { #ifndef S_SPLINT_S + time_t end_usec = end->tv_usec;; d->tv_sec = end->tv_sec - start->tv_sec; - while(end->tv_usec < start->tv_usec) { - end->tv_usec += 1000000; + while(end_usec < start->tv_usec) { + end_usec += 1000000; d->tv_sec--; } - d->tv_usec = end->tv_usec - start->tv_usec; + d->tv_usec = end_usec - start->tv_usec; #endif } /** add timers and the values do not overflow or become negative */ static void -timeval_add(struct timeval* d, struct timeval* add) +timeval_add(struct timeval* d, const struct timeval* add) { #ifndef S_SPLINT_S d->tv_sec += add->tv_sec; @@ -86,7 +87,7 @@ timeval_add(struct timeval* d, struct timeval* add) /** divide sum of timers to get average */ static void -timeval_divide(struct timeval* avg, struct timeval* sum, size_t d) +timeval_divide(struct timeval* avg, const struct timeval* sum, size_t d) { #ifndef S_SPLINT_S size_t leftover; diff --git a/testcode/fake_event.c b/testcode/fake_event.c index d6afae9d5..9518c0662 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -63,7 +63,7 @@ static struct replay_scenario* saved_scenario = NULL; /** add timers and the values do not overflow or become negative */ static void -timeval_add(struct timeval* d, struct timeval* add) +timeval_add(struct timeval* d, const struct timeval* add) { #ifndef S_SPLINT_S d->tv_sec += add->tv_sec; diff --git a/util/timehist.c b/util/timehist.c index 047f72e02..6cdaf05ed 100644 --- a/util/timehist.c +++ b/util/timehist.c @@ -111,7 +111,7 @@ void timehist_clear(struct timehist* hist) /** histogram compare of time values */ static int -timeval_smaller(struct timeval* x, struct timeval* y) +timeval_smaller(const struct timeval* x, const struct timeval* y) { #ifndef S_SPLINT_S if(x->tv_sec < y->tv_sec)