diff options
author | Joe Orton <jorton@apache.org> | 2021-07-05 08:12:51 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2021-07-05 08:12:51 +0000 |
commit | a1bead46357c9d235b30602e6c9c22f4a5b95513 (patch) | |
tree | fb5d6c9164a5aeb0f19178b2a886f9eb9e169dde | |
parent | e0be630b681fac7b8b5e2f2e402a8e18a147f966 (diff) | |
download | apr-a1bead46357c9d235b30602e6c9c22f4a5b95513.tar.gz |
Merge r1891204 from trunk:
* locks/unix/thread_mutex.c,
include/arch/unix/apr_arch_thread_mutex.h: Completely drop the code
required imitate the mutex via a condition variable if
HAVE_PTHREAD_MUTEX_TIMEDLOCK is defined.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891269 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | include/arch/unix/apr_arch_thread_mutex.h | 2 | ||||
-rw-r--r-- | locks/unix/thread_mutex.c | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/arch/unix/apr_arch_thread_mutex.h b/include/arch/unix/apr_arch_thread_mutex.h index 4fe46c3b4..0844bedb1 100644 --- a/include/arch/unix/apr_arch_thread_mutex.h +++ b/include/arch/unix/apr_arch_thread_mutex.h @@ -33,8 +33,10 @@ struct apr_thread_mutex_t { apr_pool_t *pool; pthread_mutex_t mutex; +#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK apr_thread_cond_t *cond; int locked, num_waiters; +#endif }; #endif diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c index f7cae5145..5ba191488 100644 --- a/locks/unix/thread_mutex.c +++ b/locks/unix/thread_mutex.c @@ -102,6 +102,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) { apr_status_t rv; +#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK if (mutex->cond) { apr_status_t rv2; @@ -133,6 +134,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex) return rv; } +#endif rv = pthread_mutex_lock(&mutex->mutex); #ifdef HAVE_ZOS_PTHREADS @@ -148,6 +150,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) { apr_status_t rv; +#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK if (mutex->cond) { apr_status_t rv2; @@ -177,6 +180,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex) return rv; } +#endif rv = pthread_mutex_trylock(&mutex->mutex); if (rv) { @@ -281,6 +285,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) { apr_status_t status; +#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK if (mutex->cond) { status = pthread_mutex_lock(&mutex->mutex); if (status) { @@ -303,6 +308,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex) mutex->locked = 0; } +#endif status = pthread_mutex_unlock(&mutex->mutex); #ifdef HAVE_ZOS_PTHREADS @@ -318,9 +324,12 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex) { apr_status_t rv, rv2 = APR_SUCCESS; +#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK if (mutex->cond) { rv2 = apr_thread_cond_destroy(mutex->cond); } +#endif + rv = apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup); if (rv == APR_SUCCESS) { rv = rv2; |