mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
752. [func] Correct bad tv_usec elements returned by gettimeofday().
This commit is contained in:
2
CHANGES
2
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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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 }
|
||||
};
|
||||
|
||||
|
@@ -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 <config.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <sys/time.h> /* Required for struct timeval on some platforms. */
|
||||
|
||||
#include <isc/log.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
@@ -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.
|
||||
|
Reference in New Issue
Block a user