From e72c1e7e465822fc9b5067b2dd3cf047f6132214 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 29 Aug 2008 03:57:38 +0000 Subject: [PATCH] 2430. [bug] win32: isc_interval_set() could round down to zero if the input was less than NS_INTERVAL nanoseconds. Round up instead. [RT #18549] --- CHANGES | 4 ++++ lib/isc/win32/time.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 38fa2414ec..eafe6370a5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +2430. [bug] win32: isc_interval_set() could round down to + zero if the input was less than NS_INTERVAL + nanoseconds. Round up instead. [RT #18549] + 2429. [doc] nsupdate should be in section 1 of the man pages. [RT #18283] diff --git a/lib/isc/win32/time.c b/lib/isc/win32/time.c index d2ef982b69..2522954f06 100644 --- a/lib/isc/win32/time.c +++ b/lib/isc/win32/time.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.43 2007/06/19 23:47:19 tbox Exp $ */ +/* $Id: time.c,v 1.44 2008/08/29 03:57:38 marka Exp $ */ #include @@ -64,8 +64,11 @@ isc_interval_set(isc_interval_t *i, unsigned int seconds, REQUIRE(i != NULL); REQUIRE(nanoseconds < NS_PER_S); + /* + * This rounds nanoseconds up not down. + */ i->interval = (LONGLONG)seconds * INTERVALS_PER_S - + nanoseconds / NS_INTERVAL; + + (nanoseconds + NS_INTERVAL - 1) / NS_INTERVAL; } isc_boolean_t