summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2017-05-23 17:41:17 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2017-05-23 17:41:17 +0000
commitae6abf7fc156cafbc831eddd221aaacad7ba62cf (patch)
tree9fa812b8b77d0050bee430821992777169a1e8fb /locks
parent4716014f7aa3bde54df8e76a111dfe7883a41eab (diff)
downloadapr-ae6abf7fc156cafbc831eddd221aaacad7ba62cf.tar.gz
Revert 1790490 (r1790488 from trunk), was;
locks: follow up to r1667900. Axe the 'absolute' argument of apr_{thread,proc,global}_mutex_timedlock() which was confusing, hence 'timeout' is always relative now. It still makes sense (to me) to handle a negative timeout as INFINITE, a nul one as IMMEDIATE, and a positive one as an upper bound timeout (like most if not all of the underlying system calls...). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1795940 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r--locks/beos/proc_mutex.c27
-rw-r--r--locks/beos/thread_mutex.c27
-rw-r--r--locks/netware/proc_mutex.c5
-rw-r--r--locks/netware/thread_mutex.c26
-rw-r--r--locks/os2/proc_mutex.c23
-rw-r--r--locks/os2/thread_mutex.c25
-rw-r--r--locks/unix/global_mutex.c21
-rw-r--r--locks/unix/proc_mutex.c64
-rw-r--r--locks/unix/thread_mutex.c59
-rw-r--r--locks/win32/proc_mutex.c12
-rw-r--r--locks/win32/thread_mutex.c12
11 files changed, 184 insertions, 117 deletions
diff --git a/locks/beos/proc_mutex.c b/locks/beos/proc_mutex.c
index dba07c0a5..1b468714c 100644
--- a/locks/beos/proc_mutex.c
+++ b/locks/beos/proc_mutex.c
@@ -109,20 +109,33 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
int32 stat;
if (atomic_add(&mutex->LockCount, 1) > 0) {
- if (!timeout) {
- stat = B_TIMED_OUT;
- }
- else if (timeout < 0) {
+ if (timeout < 0) {
stat = acquire_sem(mutex->Lock);
}
else {
- stat = acquire_sem_etc(mutex->Lock, 1, B_RELATIVE_TIMEOUT,
- timeout);
+ int flag = 0;
+ if (timeout > 0) {
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ flag = B_ABSOLUTE_TIMEOUT;
+ }
+ else {
+ flag = B_RELATIVE_TIMEOUT;
+ }
+ }
+ stat = acquire_sem_etc(mutex->Lock, 1, flag, timeout);
}
if (stat < B_NO_ERROR) {
atomic_add(&mutex->LockCount, -1);
diff --git a/locks/beos/thread_mutex.c b/locks/beos/thread_mutex.c
index 62e81319e..2fa1bc70b 100644
--- a/locks/beos/thread_mutex.c
+++ b/locks/beos/thread_mutex.c
@@ -132,7 +132,8 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
int32 stat;
thread_id me = find_thread(NULL);
@@ -143,15 +144,27 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
}
if (atomic_add(&mutex->LockCount, 1) > 0) {
- if (!timeout) {
- stat = B_TIMED_OUT;
- }
- else if (timeout < 0) {
+ if (timeout < 0) {
stat = acquire_sem(mutex->Lock);
}
else {
- stat = acquire_sem_etc(mutex->Lock, 1, B_RELATIVE_TIMEOUT,
- timeout);
+ int flag = 0;
+ if (timeout > 0) {
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ flag = B_ABSOLUTE_TIMEOUT;
+ }
+ else {
+ flag = B_RELATIVE_TIMEOUT;
+ }
+ }
+ stat = acquire_sem_etc(mutex->Lock, 1, flag, timeout);
}
if (stat < B_NO_ERROR) {
atomic_add(&mutex->LockCount, -1);
diff --git a/locks/netware/proc_mutex.c b/locks/netware/proc_mutex.c
index c619f08c0..31ee97fff 100644
--- a/locks/netware/proc_mutex.c
+++ b/locks/netware/proc_mutex.c
@@ -73,10 +73,11 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
if (mutex)
- return apr_thread_mutex_timedlock(mutex->mutex, timeout);
+ return apr_thread_mutex_timedlock(mutex->mutex, timeout, absolute);
return APR_ENOLOCK;
}
diff --git a/locks/netware/thread_mutex.c b/locks/netware/thread_mutex.c
index ecb0112f4..c634edfac 100644
--- a/locks/netware/thread_mutex.c
+++ b/locks/netware/thread_mutex.c
@@ -112,26 +112,30 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
if (mutex->cond) {
apr_status_t rv;
NXLock(mutex->mutex);
if (mutex->locked) {
- if (!timeout) {
- rv = APR_TIMEUP;
+ mutex->num_waiters++;
+ if (timeout < 0) {
+ rv = apr_thread_cond_wait(mutex->cond, mutex);
}
else {
- mutex->num_waiters++;
- if (timeout < 0) {
- rv = apr_thread_cond_wait(mutex->cond, mutex);
- }
- else {
- rv = apr_thread_cond_timedwait(mutex->cond, mutex,
- timeout);
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
}
- mutex->num_waiters--;
+ rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout);
}
+ mutex->num_waiters--;
}
else {
mutex->locked = 1;
diff --git a/locks/os2/proc_mutex.c b/locks/os2/proc_mutex.c
index 2fe75afa0..847f775da 100644
--- a/locks/os2/proc_mutex.c
+++ b/locks/os2/proc_mutex.c
@@ -156,24 +156,35 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
mutex->lock_count++;
}
- return (rc == ERROR_TIMEOUT) ? APR_EBUSY : APR_FROM_OS_ERROR(rc);
+ return APR_FROM_OS_ERROR(rc);
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
ULONG rc;
if (timeout < 0) {
rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT);
}
- else if (!timeout) {
- rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN);
- }
else {
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ }
+
rc = DosRequestMutexSem(mutex->hMutex, apr_time_as_msec(timeout));
+ if (rc == ERROR_TIMEOUT) {
+ return APR_TIMEUP;
+ }
}
if (rc == 0) {
@@ -181,7 +192,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
mutex->lock_count++;
}
- return (rc == ERROR_TIMEOUT) ? APR_TIMEUP : APR_FROM_OS_ERROR(rc);
+ return APR_FROM_OS_ERROR(rc);
}
diff --git a/locks/os2/thread_mutex.c b/locks/os2/thread_mutex.c
index 6dd1f0b68..26245839d 100644
--- a/locks/os2/thread_mutex.c
+++ b/locks/os2/thread_mutex.c
@@ -66,28 +66,37 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
{
ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN);
-
- return (rc == ERROR_TIMEOUT) ? APR_EBUSY : APR_FROM_OS_ERROR(rc);
+ return APR_OS2_STATUS(rc);
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
ULONG rc;
if (timeout < 0) {
rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT);
}
- else if (!timeout) {
- rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN);
- }
else {
- rc = DosRequestMutexSem(mutex->hMutex, apr_time_as_msec(timeout));
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ }
+ rc = DosRequestMutexSem(mutex->hMutex, apr_time_as_msec(usec));
+ if (rc == ERROR_TIMEOUT) {
+ return APR_TIMEUP;
+ }
}
- return (rc == ERROR_TIMEOUT) ? APR_TIMEUP : APR_FROM_OS_ERROR(rc);
+ return APR_FROM_OS_ERROR(rc);
}
diff --git a/locks/unix/global_mutex.c b/locks/unix/global_mutex.c
index 9aa213eb2..b343e23ad 100644
--- a/locks/unix/global_mutex.c
+++ b/locks/unix/global_mutex.c
@@ -143,30 +143,27 @@ APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_global_mutex_timedlock(apr_global_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
apr_status_t rv;
#if APR_HAS_THREADS
if (mutex->thread_mutex) {
- apr_time_t expiry = 0;
- if (timeout > 0) {
- expiry = apr_time_now() + timeout;
+ if (timeout >= 0 && !absolute) {
+ timeout += apr_time_now();
+ absolute = 1;
}
- rv = apr_thread_mutex_timedlock(mutex->thread_mutex, timeout);
+ rv = apr_thread_mutex_timedlock(mutex->thread_mutex, timeout,
+ absolute);
if (rv != APR_SUCCESS) {
return rv;
}
- if (expiry) {
- timeout = expiry - apr_time_now();
- if (timeout < 0) {
- timeout = 0;
- }
- }
}
#endif /* APR_HAS_THREADS */
- rv = apr_proc_mutex_timedlock(mutex->proc_mutex, timeout);
+ rv = apr_proc_mutex_timedlock(mutex->proc_mutex, timeout,
+ absolute);
#if APR_HAS_THREADS
if (rv != APR_SUCCESS) {
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index 25ae89c9d..70051d5a9 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -56,9 +56,16 @@ static apr_status_t proc_mutex_no_perms_set(apr_proc_mutex_t *mutex,
&& !defined(HAVE_PTHREAD_MUTEX_TIMEDLOCK) \
&& !defined(HAVE_PTHREAD_CONDATTR_SETPSHARED))
static apr_status_t proc_mutex_spinsleep_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
apr_status_t rv;
+ if (absolute) {
+ timeout -= apr_time_now();
+ if (timeout < 0) {
+ timeout = 0;
+ }
+ }
if (timeout < 0) {
rv = apr_proc_mutex_lock(mutex);
}
@@ -228,20 +235,19 @@ static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex)
#if defined(HAVE_SEM_TIMEDWAIT)
static apr_status_t proc_mutex_posix_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
if (timeout < 0) {
return proc_mutex_posix_acquire(mutex);
}
- else if (!timeout) {
- apr_status_t rv = proc_mutex_posix_tryacquire(mutex);
- return (rv == APR_EBUSY) ? APR_TIMEUP : rv;
- }
else {
int rc;
struct timespec abstime;
- timeout += apr_time_now();
+ if (!absolute) {
+ timeout += apr_time_now();
+ }
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
@@ -386,22 +392,23 @@ static apr_status_t proc_mutex_sysv_tryacquire(apr_proc_mutex_t *mutex)
#if defined(HAVE_SEMTIMEDOP)
static apr_status_t proc_mutex_sysv_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
if (timeout < 0) {
return proc_mutex_sysv_acquire(mutex);
}
- else if (!timeout) {
- apr_status_t rv = proc_mutex_sysv_tryacquire(mutex);
- return (rv == APR_EBUSY) ? APR_TIMEUP : rv;
- }
else {
int rc;
struct timespec reltime;
-
+ if (absolute) {
+ timeout -= apr_time_now();
+ if (timeout < 0) {
+ return proc_mutex_sysv_tryacquire(mutex);
+ }
+ }
reltime.tv_sec = apr_time_sec(timeout);
reltime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
-
do {
rc = semtimedop(mutex->os.crossproc, &proc_mutex_op_on, 1,
&reltime);
@@ -516,7 +523,8 @@ typedef struct {
static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout);
+ apr_time_t timeout,
+ int absolute);
static APR_INLINE int proc_pthread_mutex_inc(apr_proc_mutex_t *mutex)
{
@@ -700,20 +708,21 @@ static apr_status_t proc_mutex_pthread_child_init(apr_proc_mutex_t **mutex,
static apr_status_t proc_mutex_pthread_acquire(apr_proc_mutex_t *mutex)
{
- return proc_mutex_pthread_timedacquire(mutex, -1);
+ return proc_mutex_pthread_timedacquire(mutex, -1, 0);
}
static apr_status_t proc_mutex_pthread_tryacquire(apr_proc_mutex_t *mutex)
{
- apr_status_t rv = proc_mutex_pthread_timedacquire(mutex, 0);
+ apr_status_t rv = proc_mutex_pthread_timedacquire(mutex, 0, 0);
return (rv == APR_TIMEUP) ? APR_EBUSY : rv;
}
static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
#if !APR_USE_PROC_PTHREAD_MUTEX_COND && !defined(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
- return proc_mutex_spinsleep_timedacquire(mutex, timeout);
+ return proc_mutex_spinsleep_timedacquire(mutex, timeout, absolute);
#else
apr_status_t rv;
@@ -754,11 +763,11 @@ static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
}
else {
struct timespec abstime;
-
- timeout += apr_time_now();
+ if (!absolute) {
+ timeout += apr_time_now();
+ }
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
-
rv = pthread_cond_timedwait(&proc_pthread_mutex_cond(mutex),
&proc_pthread_mutex(mutex),
&abstime);
@@ -810,11 +819,11 @@ static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
}
else {
struct timespec abstime;
-
- timeout += apr_time_now();
+ if (!absolute) {
+ timeout += apr_time_now();
+ }
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
-
rv = pthread_mutex_timedlock(&proc_pthread_mutex(mutex), &abstime);
if (rv) {
#ifdef HAVE_ZOS_PTHREADS
@@ -1565,9 +1574,10 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
- return mutex->meth->timedacquire(mutex, timeout);
+ return mutex->meth->timedacquire(mutex, timeout, absolute);
}
APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex)
diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c
index be2d86586..fe515b2e6 100644
--- a/locks/unix/thread_mutex.c
+++ b/locks/unix/thread_mutex.c
@@ -190,34 +190,26 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
apr_status_t rv = APR_ENOTIMPL;
#ifdef HAVE_PTHREAD_MUTEX_TIMEDLOCK
if (timeout < 0) {
rv = pthread_mutex_lock(&mutex->mutex);
-#ifdef HAVE_ZOS_PTHREADS
- if (rv) {
- rv = errno;
- }
-#endif
- }
- else if (!timeout) {
- rv = pthread_mutex_trylock(&mutex->mutex);
if (rv) {
#ifdef HAVE_ZOS_PTHREADS
rv = errno;
#endif
- if (rv == EBUSY) {
- rv = APR_TIMEUP;
- }
}
}
else {
struct timespec abstime;
- timeout += apr_time_now();
+ if (!absolute) {
+ timeout += apr_time_now();
+ }
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
@@ -235,6 +227,8 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
#else /* HAVE_PTHREAD_MUTEX_TIMEDLOCK */
if (mutex->cond) {
+ apr_status_t rv2;
+
rv = pthread_mutex_lock(&mutex->mutex);
if (rv) {
#ifdef HAVE_ZOS_PTHREADS
@@ -244,40 +238,35 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
}
if (mutex->locked) {
- if (!timeout) {
- rv = APR_TIMEUP;
+ mutex->num_waiters++;
+ if (timeout < 0) {
+ rv = apr_thread_cond_wait(mutex->cond, mutex);
}
else {
- mutex->num_waiters++;
- if (timeout < 0) {
- rv = apr_thread_cond_wait(mutex->cond, mutex);
- }
- else {
- rv = apr_thread_cond_timedwait(mutex->cond, mutex,
- timeout);
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
}
-#ifdef HAVE_ZOS_PTHREADS
- if (rv) {
- rv = errno;
- }
-#endif
- mutex->num_waiters--;
+ rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout);
}
+ mutex->num_waiters--;
}
else {
mutex->locked = 1;
}
- if (rv) {
- pthread_mutex_unlock(&mutex->mutex);
- return rv;
- }
- rv = pthread_mutex_unlock(&mutex->mutex);
- if (rv) {
+ rv2 = pthread_mutex_unlock(&mutex->mutex);
+ if (rv2 && !rv) {
#ifdef HAVE_ZOS_PTHREADS
rv = errno;
+#else
+ rv = rv2;
#endif
- return rv;
}
}
diff --git a/locks/win32/proc_mutex.c b/locks/win32/proc_mutex.c
index 7c3df23dc..b51f856c0 100644
--- a/locks/win32/proc_mutex.c
+++ b/locks/win32/proc_mutex.c
@@ -165,7 +165,8 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
DWORD rv;
@@ -173,6 +174,15 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
rv = WaitForSingleObject(mutex->handle, INFINITE);
}
else {
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ }
rv = WaitForSingleObject(mutex->handle, apr_time_as_msec(timeout));
if (rv == WAIT_TIMEOUT) {
return APR_TIMEUP;
diff --git a/locks/win32/thread_mutex.c b/locks/win32/thread_mutex.c
index 05dc3d5fb..cd0ccf5ba 100644
--- a/locks/win32/thread_mutex.c
+++ b/locks/win32/thread_mutex.c
@@ -115,7 +115,8 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout)
+ apr_time_t timeout,
+ int absolute)
{
if (mutex->type != thread_mutex_critical_section) {
DWORD rv, timeout_ms;
@@ -123,6 +124,15 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
timeout_ms = INFINITE;
}
else {
+ if (absolute) {
+ apr_time_t now = apr_time_now();
+ if (timeout > now) {
+ timeout -= now;
+ }
+ else {
+ timeout = 0;
+ }
+ }
timeout_ms = apr_time_as_msec(timeout);
}
rv = WaitForSingleObject(mutex->handle, timeout_ms);