From: Martin Willi Date: Mon, 20 Aug 2012 15:58:58 +0000 (+0200) Subject: Don't use POSIX semaphores if a MONOTONIC clock is available X-Git-Tag: 5.0.1~170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88a5abf5e202b4aedae85a7891b759fe15b6198a;p=thirdparty%2Fstrongswan.git Don't use POSIX semaphores if a MONOTONIC clock is available POSIX semaphores use CLOCK_REALTIME, but our semaphore_t abstraction expects CLOCK_MONOTONIC based times. Use the mutex/condvar based fallback if time_monotonic() actuall returns monotonic times. --- diff --git a/src/libstrongswan/threading/semaphore.c b/src/libstrongswan/threading/semaphore.c index c35cf1ea50..b785ff9448 100644 --- a/src/libstrongswan/threading/semaphore.c +++ b/src/libstrongswan/threading/semaphore.c @@ -15,6 +15,14 @@ #include +#if defined(HAVE_CLOCK_GETTIME) && \ + (defined(HAVE_CONDATTR_CLOCK_MONOTONIC) || \ + defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) +/* if we use MONOTONIC times, we can't use POSIX_SEMAPHORES since they use + * times based on CLOCK_REALTIME */ +#undef HAVE_SEM_TIMEDWAIT +#endif /* HAVE_CLOCK_GETTIME && ... */ + #ifdef HAVE_SEM_TIMEDWAIT #include #else /* !HAVE_SEM_TIMEDWAIT */