diff options
Diffstat (limited to 'locks/unix/thread_cond.c')
-rw-r--r-- | locks/unix/thread_cond.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/locks/unix/thread_cond.c b/locks/unix/thread_cond.c index db7dd4f0d973..3c8e3170a0dc 100644 --- a/locks/unix/thread_cond.c +++ b/locks/unix/thread_cond.c @@ -79,21 +79,31 @@ APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, apr_interval_time_t timeout) { apr_status_t rv; - apr_time_t then; - struct timespec abstime; + if (timeout < 0) { + rv = pthread_cond_wait(&cond->cond, &mutex->mutex); +#ifdef HAVE_ZOS_PTHREADS + if (rv) { + rv = errno; + } +#endif + } + else { + apr_time_t then; + struct timespec abstime; - then = apr_time_now() + timeout; - abstime.tv_sec = apr_time_sec(then); - abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */ + then = apr_time_now() + timeout; + abstime.tv_sec = apr_time_sec(then); + abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */ - rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime); + rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime); #ifdef HAVE_ZOS_PTHREADS - if (rv) { - rv = errno; - } + if (rv) { + rv = errno; + } #endif - if (ETIMEDOUT == rv) { - return APR_TIMEUP; + if (ETIMEDOUT == rv) { + return APR_TIMEUP; + } } return rv; } |