diff --git a/CHANGES b/CHANGES index 9a7c0e1cf1..98a91693c8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 752. [func] Correct bad tv_usec elements returned by gettimeofday(). + 751. [func] Log successful zone loads / transfers. 750. [bug] A query should not match a DNAME whose trust level diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index f5054dcb10..11a4b515c1 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.h,v 1.36 2001/01/09 21:57:09 bwelling Exp $ */ +/* $Id: log.h,v 1.37 2001/02/23 23:12:27 marka Exp $ */ #ifndef ISC_LOG_H #define ISC_LOG_H 1 @@ -138,6 +138,7 @@ extern isc_logmodule_t isc_modules[]; #define ISC_LOGCATEGORY_GENERAL (&isc_categories[1]) #define ISC_LOGMODULE_SOCKET (&isc_modules[0]) +#define ISC_LOGMODULE_TIME (&isc_modules[1]) ISC_LANG_BEGINDECLS diff --git a/lib/isc/log.c b/lib/isc/log.c index 5b020a60ab..3666579ed6 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.56 2001/01/09 21:56:13 bwelling Exp $ */ +/* $Id: log.c,v 1.57 2001/02/23 23:12:25 marka Exp $ */ /* Principal Authors: DCL */ @@ -192,6 +192,7 @@ isc_logcategory_t isc_categories[] = { */ isc_logmodule_t isc_modules[] = { { "socket", 0 }, + { "time", 0 }, { NULL, 0 } }; diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 9d9395d0d9..d2e7ffd666 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.30 2001/01/09 21:58:33 bwelling Exp $ */ +/* $Id: time.c,v 1.31 2001/02/23 23:12:28 marka Exp $ */ #include @@ -25,6 +25,7 @@ #include /* Required for struct timeval on some platforms. */ +#include #include #include #include @@ -40,6 +41,10 @@ * need an initialized type. */ +#ifndef ISC_FIX_TV_USEC +#define ISC_FIX_TV_USEC 1 +#endif + /*** *** Intervals ***/ @@ -130,9 +135,13 @@ isc_time_isepoch(isc_time_t *t) { return (ISC_FALSE); } + isc_result_t isc_time_now(isc_time_t *t) { struct timeval tv; +#if ISC_FIX_TV_USEC + isc_boolean_t fixed = ISC_FALSE; +#endif /* * Set *t to the current absolute time. @@ -152,8 +161,29 @@ isc_time_now(isc_time_t *t) { * happening are pretty much zero, but since the libisc library ensures * certain things to be true ... */ +#if ISC_FIX_TV_USEC + if (tv.tv_sec < 0) { + fixed = ISC_TRUE; + do { + tv.tv_sec -= 1; + tv.tv_usec += US_PER_S; + } while (tv.tv_usec < 0); + } else if (tv.tv_sec >= US_PER_S) { + fixed = ISC_TRUE; + do { + tv.tv_sec += 1; + tv.tv_usec -= US_PER_S; + } while (tv.tv_usec >=US_PER_S); + } else if (tv.tv_sec < 0) + return (ISC_R_UNEXPECTED); + if (fixed) + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_TIME, ISC_LOG_INFO, + "gettimeofday returned bad tv_usec: corrected"); +#else if (tv.tv_sec < 0 || tv.tv_usec < 0 || tv.tv_usec >= US_PER_S) return (ISC_R_UNEXPECTED); +#endif /* * Ensure the tv_sec value fits in t->seconds.