diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-03-20 09:16:56 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-03-20 09:16:56 +0000 |
commit | 33e3250ea2f0ce82fbbc5d4fa389bfef1e9e238c (patch) | |
tree | 028abc1c6ee07d940fcc83ba3726511c5195595b /locks/netware | |
parent | 3e167334c486f5384a2b21f2d8c04adf7d4263a5 (diff) | |
download | libapr-33e3250ea2f0ce82fbbc5d4fa389bfef1e9e238c.tar.gz |
Follow up to r1667900: handle negative (infinite) timeout in mutex/cond timedlock/timedwait.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1667962 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks/netware')
-rw-r--r-- | locks/netware/thread_cond.c | 19 | ||||
-rw-r--r-- | locks/netware/thread_mutex.c | 23 |
2 files changed, 29 insertions, 13 deletions
diff --git a/locks/netware/thread_cond.c b/locks/netware/thread_cond.c index dcb21edc9..da1162bc2 100644 --- a/locks/netware/thread_cond.c +++ b/locks/netware/thread_cond.c @@ -66,10 +66,21 @@ APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex, - apr_interval_time_t timeout){ - if (NXCondTimedWait(cond->cond, mutex->mutex, - (timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) { - return APR_TIMEUP; + apr_interval_time_t timeout) +{ + int rc; + if (timeout < 0) { + rc = NXCondWait(cond->cond, mutex->mutex); + } + else { + timeout = timeout * 1000 / XGetSystemTick(); + rc = NXCondTimedWait(cond->cond, mutex->mutex, timeout); + if (rc == NX_ETIMEDOUT) { + return APR_TIMEUP; + } + } + if (rc != 0) { + return APR_EINTR; } return APR_SUCCESS; } diff --git a/locks/netware/thread_mutex.c b/locks/netware/thread_mutex.c index a43215dce..a11ad8345 100644 --- a/locks/netware/thread_mutex.c +++ b/locks/netware/thread_mutex.c @@ -119,17 +119,22 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex, apr_status_t rv; NXLock(mutex->mutex); if (mutex->locked) { - if (absolute) { - apr_time_t now = apr_time_now(); - if (timeout > now) { - timeout -= now; - } - else { - timeout = 0; + mutex->num_waiters++; + if (timeout < 0) { + rv = apr_thread_cond_dwait(mutex->cond, mutex); + } + else { + if (absolute) { + apr_time_t now = apr_time_now(); + if (timeout > now) { + timeout -= now; + } + else { + timeout = 0; + } } + rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout); } - mutex->num_waiters++; - rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout); mutex->num_waiters--; } else { |