diff options
author | Darren Tucker <dtucker@zip.com.au> | 2013-08-08 03:52:37 +0200 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2013-08-08 03:52:37 +0200 |
commit | 94396b7f06f512a0acb230640d7f703fb802a9ee (patch) | |
tree | 1b4dd673bcbfe9acd5d08e4e1ae44e06ff86e379 /misc.c | |
parent | - (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt (diff) | |
download | openssh-94396b7f06f512a0acb230640d7f703fb802a9ee.tar.xz openssh-94396b7f06f512a0acb230640d7f703fb802a9ee.zip |
- (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.
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -854,19 +854,24 @@ ms_to_timeval(struct timeval *tv, int ms) tv->tv_usec = (ms % 1000) * 1000; } +#define clock_gettime(a,b) -1 + time_t monotime(void) { #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) struct timespec ts; + static int gettime_failed = 0; - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) - fatal("clock_gettime: %s", strerror(errno)); + if (!gettime_failed) { + if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) + return (ts.tv_sec); + debug3("clock_gettime: %s", strerror(errno)); + gettime_failed = 1; + } +#endif - return (ts.tv_sec); -#else return time(NULL); -#endif } void |