diff options
author | Nick Kew <niq@apache.org> | 2017-04-19 15:25:28 +0000 |
---|---|---|
committer | Nick Kew <niq@apache.org> | 2017-04-19 15:25:28 +0000 |
commit | 9140d74f3f874737afef2fa7a7f31eed6477e03e (patch) | |
tree | de0ecb5c798963369048c3cbc869e4e4131e42b5 | |
parent | 49e7fa4cc5e001617c08f137584d2075363898c1 (diff) | |
download | apr-9140d74f3f874737afef2fa7a7f31eed6477e03e.tar.gz |
Make timedlocks a configuration option.
After first Mac then Solaris biting us, timedlocks look high-risk,
so a config option and a corresponding rlease note offer a workaround
to any users who get bitten.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1791932 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | include/apr.h.in | 1 | ||||
-rw-r--r-- | locks/unix/global_mutex.c | 4 | ||||
-rw-r--r-- | locks/unix/proc_mutex.c | 4 | ||||
-rw-r--r-- | locks/unix/thread_mutex.c | 2 | ||||
-rw-r--r-- | test/testlock.c | 4 | ||||
-rw-r--r-- | test/testprocmutex.c | 2 |
8 files changed, 25 insertions, 0 deletions
@@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes for APR 1.6.1 + *) Locks: add a --disable-timedlocks config option in case users + encounter more platforms where it fails [Nick Kew]. Changes for APR 1.6.0 diff --git a/configure.in b/configure.in index 29fd00d85..4da19c294 100644 --- a/configure.in +++ b/configure.in @@ -2789,6 +2789,12 @@ AC_MSG_RESULT($ipv6_result) AC_SUBST(have_ipv6) +AC_ARG_ENABLE(timedlocks, + [ --disable-timedlocks Disable timed locks ], + [apr_has_timedlocks="0"], [apr_has_timedlocks="1"] +) +AC_SUBST(apr_has_timedlocks) + # hstrerror is only needed if IPv6 is not enabled, # so getaddrinfo/gai_strerror are not used. if test $have_ipv6 = 0; then diff --git a/include/apr.h.in b/include/apr.h.in index 4d188853b..461b178f6 100644 --- a/include/apr.h.in +++ b/include/apr.h.in @@ -280,6 +280,7 @@ extern "C" { #define APR_HAS_LARGE_FILES @aprlfs@ #define APR_HAS_XTHREAD_FILES @apr_has_xthread_files@ #define APR_HAS_OS_UUID @osuuid@ +#define APR_HAS_TIMEDLOCKS @apr_has_timedlocks@ #define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD @apr_procattr_user_set_requires_password@ diff --git a/locks/unix/global_mutex.c b/locks/unix/global_mutex.c index 22592060d..02173513b 100644 --- a/locks/unix/global_mutex.c +++ b/locks/unix/global_mutex.c @@ -145,6 +145,7 @@ 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_interval_time_t timeout) { +#if APR_HAS_TIMEDLOCKS apr_status_t rv; #if APR_HAS_THREADS @@ -177,6 +178,9 @@ APR_DECLARE(apr_status_t) apr_global_mutex_timedlock(apr_global_mutex_t *mutex, #endif /* APR_HAS_THREADS */ return rv; +#else /* APR_HAS_TIMEDLOCKS */ + return APR_ENOTIMPL; +#endif } APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex) diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index 018d9bc71..3708b8eb0 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -1560,7 +1560,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_interval_time_t timeout) { +#if APR_HAS_TIMEDLOCKS return mutex->meth->timedacquire(mutex, timeout); +#else + return APR_ENOTIMPL; +#endif } 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 cf859e6ad..e1b292e46 100644 --- a/locks/unix/thread_mutex.c +++ b/locks/unix/thread_mutex.c @@ -193,6 +193,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex, apr_interval_time_t timeout) { apr_status_t rv = APR_ENOTIMPL; +#if APR_HAS_TIMEDLOCKS #ifdef HAVE_PTHREAD_MUTEX_TIMEDLOCK if (timeout <= 0) { @@ -269,6 +270,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex, #endif /* HAVE_PTHREAD_MUTEX_TIMEDLOCK */ +#endif /* APR_HAS_TIMEDLOCKS */ return rv; } diff --git a/test/testlock.c b/test/testlock.c index 40da791b7..29ee0526e 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -392,12 +392,16 @@ abts_suite *testlock(abts_suite *suite) abts_run_test(suite, threads_not_impl, NULL); #else abts_run_test(suite, test_thread_mutex, NULL); +#if APR_HAS_TIMEDLOCKS abts_run_test(suite, test_thread_timedmutex, NULL); +#endif abts_run_test(suite, test_thread_rwlock, NULL); abts_run_test(suite, test_cond, NULL); abts_run_test(suite, test_timeoutcond, NULL); +#if APR_HAS_TIMEDLOCKS abts_run_test(suite, test_timeoutmutex, NULL); #endif +#endif return suite; } diff --git a/test/testprocmutex.c b/test/testprocmutex.c index 983aa953a..3edb2a9da 100644 --- a/test/testprocmutex.c +++ b/test/testprocmutex.c @@ -184,6 +184,7 @@ static void test_exclusive(abts_case *tc, const char *lockname, *x == MAX_COUNTER); } +#if APR_HAS_TIMEDLOCKS rv = apr_proc_mutex_timedlock(proc_lock, 1); if (rv == APR_ENOTIMPL) { fprintf(stderr, "%s_timedlock() not implemented, ", mech->name); @@ -220,6 +221,7 @@ static void test_exclusive(abts_case *tc, const char *lockname, ABTS_ASSERT(tc, "Locks don't appear to work with timedlock", *x == MAX_COUNTER); } +#endif /* APR_HAS_TIMEDLOCKS */ } static void proc_mutex(abts_case *tc, void *data) |