summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2017-04-07 00:11:27 +0000
committerYann Ylavic <ylavic@apache.org>2017-04-07 00:11:27 +0000
commit8b5aec3d6115315f79f88fc3eea2698343b39ed7 (patch)
tree75f58300461a24e6a459683d1e304cab38d0bc96 /locks
parentc93e1021f0bffe93d548b372b10704b8584c58f9 (diff)
downloadapr-8b5aec3d6115315f79f88fc3eea2698343b39ed7.tar.gz
Merge r1790488 from trunk:
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@1790490 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, 117 insertions, 184 deletions
diff --git a/locks/beos/proc_mutex.c b/locks/beos/proc_mutex.c
index 1b468714c..dba07c0a5 100644
--- a/locks/beos/proc_mutex.c
+++ b/locks/beos/proc_mutex.c
@@ -109,33 +109,20 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
int32 stat;
if (atomic_add(&mutex->LockCount, 1) > 0) {
- if (timeout < 0) {
+ if (!timeout) {
+ stat = B_TIMED_OUT;
+ }
+ else if (timeout < 0) {
stat = acquire_sem(mutex->Lock);
}
else {
- 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);
+ stat = acquire_sem_etc(mutex->Lock, 1, B_RELATIVE_TIMEOUT,
+ 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 2fa1bc70b..62e81319e 100644
--- a/locks/beos/thread_mutex.c
+++ b/locks/beos/thread_mutex.c
@@ -132,8 +132,7 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
int32 stat;
thread_id me = find_thread(NULL);
@@ -144,27 +143,15 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
}
if (atomic_add(&mutex->LockCount, 1) > 0) {
- if (timeout < 0) {
+ if (!timeout) {
+ stat = B_TIMED_OUT;
+ }
+ else if (timeout < 0) {
stat = acquire_sem(mutex->Lock);
}
else {
- 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);
+ stat = acquire_sem_etc(mutex->Lock, 1, B_RELATIVE_TIMEOUT,
+ 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 31ee97fff..c619f08c0 100644
--- a/locks/netware/proc_mutex.c
+++ b/locks/netware/proc_mutex.c
@@ -73,11 +73,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,
- int absolute)
+ apr_time_t timeout)
{
if (mutex)
- return apr_thread_mutex_timedlock(mutex->mutex, timeout, absolute);
+ return apr_thread_mutex_timedlock(mutex->mutex, timeout);
return APR_ENOLOCK;
}
diff --git a/locks/netware/thread_mutex.c b/locks/netware/thread_mutex.c
index c634edfac..ecb0112f4 100644
--- a/locks/netware/thread_mutex.c
+++ b/locks/netware/thread_mutex.c
@@ -112,30 +112,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,
- int absolute)
+ apr_time_t timeout)
{
if (mutex->cond) {
apr_status_t rv;
NXLock(mutex->mutex);
if (mutex->locked) {
- mutex->num_waiters++;
- if (timeout < 0) {
- rv = apr_thread_cond_wait(mutex->cond, mutex);
+ if (!timeout) {
+ rv = APR_TIMEUP;
}
else {
- 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_wait(mutex->cond, mutex);
+ }
+ else {
+ rv = apr_thread_cond_timedwait(mutex->cond, mutex,
+ timeout);
}
- rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout);
+ mutex->num_waiters--;
}
- mutex->num_waiters--;
}
else {
mutex->locked = 1;
diff --git a/locks/os2/proc_mutex.c b/locks/os2/proc_mutex.c
index 847f775da..2fe75afa0 100644
--- a/locks/os2/proc_mutex.c
+++ b/locks/os2/proc_mutex.c
@@ -156,35 +156,24 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
mutex->lock_count++;
}
- return APR_FROM_OS_ERROR(rc);
+ return (rc == ERROR_TIMEOUT) ? APR_EBUSY : APR_FROM_OS_ERROR(rc);
}
APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
- apr_time_t timeout,
- int absolute)
+ apr_time_t timeout)
{
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) {
@@ -192,7 +181,7 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
mutex->lock_count++;
}
- return APR_FROM_OS_ERROR(rc);
+ return (rc == ERROR_TIMEOUT) ? APR_TIMEUP : APR_FROM_OS_ERROR(rc);
}
diff --git a/locks/os2/thread_mutex.c b/locks/os2/thread_mutex.c
index 26245839d..6dd1f0b68 100644
--- a/locks/os2/thread_mutex.c
+++ b/locks/os2/thread_mutex.c
@@ -66,37 +66,28 @@ 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 APR_OS2_STATUS(rc);
+
+ return (rc == ERROR_TIMEOUT) ? APR_EBUSY : APR_FROM_OS_ERROR(rc);
}
APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
- apr_time_t timeout,
- int absolute)
+ apr_time_t timeout)
{
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(usec));
- if (rc == ERROR_TIMEOUT) {
- return APR_TIMEUP;
- }
+ rc = DosRequestMutexSem(mutex->hMutex, apr_time_as_msec(timeout));
}
- return APR_FROM_OS_ERROR(rc);
+ return (rc == ERROR_TIMEOUT) ? APR_TIMEUP : APR_FROM_OS_ERROR(rc);
}
diff --git a/locks/unix/global_mutex.c b/locks/unix/global_mutex.c
index b343e23ad..9aa213eb2 100644
--- a/locks/unix/global_mutex.c
+++ b/locks/unix/global_mutex.c
@@ -143,27 +143,30 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
apr_status_t rv;
#if APR_HAS_THREADS
if (mutex->thread_mutex) {
- if (timeout >= 0 && !absolute) {
- timeout += apr_time_now();
- absolute = 1;
+ apr_time_t expiry = 0;
+ if (timeout > 0) {
+ expiry = apr_time_now() + timeout;
}
- rv = apr_thread_mutex_timedlock(mutex->thread_mutex, timeout,
- absolute);
+ rv = apr_thread_mutex_timedlock(mutex->thread_mutex, timeout);
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,
- absolute);
+ rv = apr_proc_mutex_timedlock(mutex->proc_mutex, timeout);
#if APR_HAS_THREADS
if (rv != APR_SUCCESS) {
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index 3508b4f04..bc7b8fad3 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -56,16 +56,9 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
apr_status_t rv;
- if (absolute) {
- timeout -= apr_time_now();
- if (timeout < 0) {
- timeout = 0;
- }
- }
if (timeout < 0) {
rv = apr_proc_mutex_lock(mutex);
}
@@ -235,19 +228,20 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
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;
- if (!absolute) {
- timeout += apr_time_now();
- }
+ timeout += apr_time_now();
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
@@ -392,23 +386,22 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
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);
@@ -523,8 +516,7 @@ typedef struct {
static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
- apr_time_t timeout,
- int absolute);
+ apr_time_t timeout);
static APR_INLINE int proc_pthread_mutex_inc(apr_proc_mutex_t *mutex)
{
@@ -706,21 +698,20 @@ 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, 0);
+ return proc_mutex_pthread_timedacquire(mutex, -1);
}
static apr_status_t proc_mutex_pthread_tryacquire(apr_proc_mutex_t *mutex)
{
- apr_status_t rv = proc_mutex_pthread_timedacquire(mutex, 0, 0);
+ apr_status_t rv = proc_mutex_pthread_timedacquire(mutex, 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,
- int absolute)
+ apr_time_t timeout)
{
#if !APR_USE_PROC_PTHREAD_MUTEX_COND && !defined(HAVE_PTHREAD_MUTEX_TIMEDLOCK)
- return proc_mutex_spinsleep_timedacquire(mutex, timeout, absolute);
+ return proc_mutex_spinsleep_timedacquire(mutex, timeout);
#else
apr_status_t rv;
@@ -760,11 +751,11 @@ static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
}
else {
struct timespec abstime;
- if (!absolute) {
- timeout += apr_time_now();
- }
+
+ 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);
@@ -816,11 +807,11 @@ static apr_status_t proc_mutex_pthread_timedacquire(apr_proc_mutex_t *mutex,
}
else {
struct timespec abstime;
- if (!absolute) {
- timeout += apr_time_now();
- }
+
+ 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
@@ -1570,10 +1561,9 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
- return mutex->meth->timedacquire(mutex, timeout, absolute);
+ return mutex->meth->timedacquire(mutex, timeout);
}
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 fe515b2e6..be2d86586 100644
--- a/locks/unix/thread_mutex.c
+++ b/locks/unix/thread_mutex.c
@@ -190,26 +190,34 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
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;
- if (!absolute) {
- timeout += apr_time_now();
- }
+ timeout += apr_time_now();
abstime.tv_sec = apr_time_sec(timeout);
abstime.tv_nsec = apr_time_usec(timeout) * 1000; /* nanoseconds */
@@ -227,8 +235,6 @@ 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
@@ -238,35 +244,40 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
}
if (mutex->locked) {
- mutex->num_waiters++;
- if (timeout < 0) {
- rv = apr_thread_cond_wait(mutex->cond, mutex);
+ if (!timeout) {
+ rv = APR_TIMEUP;
}
else {
- 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_wait(mutex->cond, mutex);
+ }
+ else {
+ rv = apr_thread_cond_timedwait(mutex->cond, mutex,
+ timeout);
}
- rv = apr_thread_cond_timedwait(mutex->cond, mutex, timeout);
+#ifdef HAVE_ZOS_PTHREADS
+ if (rv) {
+ rv = errno;
+ }
+#endif
+ mutex->num_waiters--;
}
- mutex->num_waiters--;
}
else {
mutex->locked = 1;
}
+ if (rv) {
+ pthread_mutex_unlock(&mutex->mutex);
+ return rv;
+ }
- rv2 = pthread_mutex_unlock(&mutex->mutex);
- if (rv2 && !rv) {
+ rv = pthread_mutex_unlock(&mutex->mutex);
+ if (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 b51f856c0..7c3df23dc 100644
--- a/locks/win32/proc_mutex.c
+++ b/locks/win32/proc_mutex.c
@@ -165,8 +165,7 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
DWORD rv;
@@ -174,15 +173,6 @@ 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 cd0ccf5ba..05dc3d5fb 100644
--- a/locks/win32/thread_mutex.c
+++ b/locks/win32/thread_mutex.c
@@ -115,8 +115,7 @@ 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,
- int absolute)
+ apr_time_t timeout)
{
if (mutex->type != thread_mutex_critical_section) {
DWORD rv, timeout_ms;
@@ -124,15 +123,6 @@ 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);