- (dtucker) [misc.c] Fall back to time(2) at runtime if clock_gettime(

CLOCK_MONOTONIC...) fails.  Some older versions of RHEL have the
   CLOCK_MONOTONIC define but don't actually support it.  Found and tested
   by Kevin Brott, ok djm.
This commit is contained in:
Darren Tucker 2013-08-08 11:52:37 +10:00
parent a5a3cbfa0f
commit 94396b7f06
2 changed files with 15 additions and 6 deletions

View File

@ -2,6 +2,10 @@
- (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt - (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt
since some platforms (eg really old FreeBSD) don't have it. Instead, since some platforms (eg really old FreeBSD) don't have it. Instead,
run "make clean" before a complete regress run. ok djm. run "make clean" before a complete regress run. ok djm.
- (dtucker) [misc.c] Fall back to time(2) at runtime if clock_gettime(
CLOCK_MONOTONIC...) fails. Some older versions of RHEL have the
CLOCK_MONOTONIC define but don't actually support it. Found and tested
by Kevin Brott, ok djm.
20130804 20130804
- (dtucker) [auth-krb5.c configure.ac openbsd-compat/bsd-misc.h] Add support - (dtucker) [auth-krb5.c configure.ac openbsd-compat/bsd-misc.h] Add support

17
misc.c
View File

@ -854,19 +854,24 @@ ms_to_timeval(struct timeval *tv, int ms)
tv->tv_usec = (ms % 1000) * 1000; tv->tv_usec = (ms % 1000) * 1000;
} }
#define clock_gettime(a,b) -1
time_t time_t
monotime(void) monotime(void)
{ {
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
struct timespec ts; struct timespec ts;
static int gettime_failed = 0;
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) if (!gettime_failed) {
fatal("clock_gettime: %s", strerror(errno)); if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
return (ts.tv_sec);
return (ts.tv_sec); debug3("clock_gettime: %s", strerror(errno));
#else gettime_failed = 1;
return time(NULL); }
#endif #endif
return time(NULL);
} }
void void