diff options
author | Martin Willi <martin@strongswan.org> | 2009-08-31 15:13:48 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-08-31 15:13:48 +0200 |
commit | 3d5818ec38c464b24f382d88c70b10df6c04b160 (patch) | |
tree | 58b41fa9794a8677757d642c10bc33e50bb9c438 /src/libstrongswan/utils.c | |
parent | 3f310c0d1f664f5811327c5a89b5d6c2f3e42bdc (diff) | |
download | strongswan-3d5818ec38c464b24f382d88c70b10df6c04b160.tar.bz2 strongswan-3d5818ec38c464b24f382d88c70b10df6c04b160.tar.xz |
use monotonic time source in convar->timed_wait, and in the scheduler using it
Diffstat (limited to 'src/libstrongswan/utils.c')
-rw-r--r-- | src/libstrongswan/utils.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstrongswan/utils.c b/src/libstrongswan/utils.c index 91242da2e..2d5ff3d79 100644 --- a/src/libstrongswan/utils.c +++ b/src/libstrongswan/utils.c @@ -167,7 +167,9 @@ bool mkdir_p(const char *path, mode_t mode) */ time_t time_monotonic(timeval_t *tv) { -#if defined(HAVE_CLOCK_GETTIME) +#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CONDATTR_CLOCK_MONOTONIC) + /* as we use time_monotonic() for condvar operations, we use the + * monotonic time source only if it is also supported by pthread. */ timespec_t ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) @@ -179,11 +181,12 @@ time_t time_monotonic(timeval_t *tv) } return ts.tv_sec; } -#endif /* HAVE_CLOCK_MONOTONIC */ +#endif /* HAVE_CLOCK_MONOTONIC && HAVE_CONDATTR_CLOCK_MONOTONIC */ /* Fallback to non-monotonic timestamps: * On MAC OS X, creating monotonic timestamps is rather difficult. We * could use mach_absolute_time() and catch sleep/wakeup notifications. - * We stick to the simpler (non-monotonic) gettimeofday() for now. */ + * We stick to the simpler (non-monotonic) gettimeofday() for now. + * But keep in mind: we need the same time source here as in condvar! */ if (!tv) { return time(NULL); |