summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2006-03-01 14:29:43 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2006-03-01 14:29:43 +0000
commit14dcd992ed48135bfa8437c6f6f920f01de6080a (patch)
tree399e1bbfb27d348df319c5748a39d464caa32755
parent4798ac76528cbb9fc53c754d75d1b9ec5a8f2a06 (diff)
downloadlibapr-14dcd992ed48135bfa8437c6f6f920f01de6080a.tar.gz
Usse a future-proof configure check for the robust mutex support:
* configure.in: Use APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX instead of just checking for pthread_mutexattr_setrobust_np. * build/apr_threads.m4 (APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX): Add macro. * unix/proc_mutex.c (proc_mutex_proc_pthread_create): Use HAVE_PTHREAD_MUTEX_ROBUST instead of the heuristic test. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@382030 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--build/apr_threads.m438
-rw-r--r--configure.in2
-rw-r--r--locks/unix/proc_mutex.c12
3 files changed, 41 insertions, 11 deletions
diff --git a/build/apr_threads.m4 b/build/apr_threads.m4
index 7ce2f49dc..01d032d52 100644
--- a/build/apr_threads.m4
+++ b/build/apr_threads.m4
@@ -242,3 +242,41 @@ if test "$apr_cv_mutex_recursive" = "yes"; then
[Define if recursive pthread mutexes are available])
fi
])
+
+dnl Check for robust process-shared mutex support
+AC_DEFUN([APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX], [
+AC_CACHE_CHECK([for robust cross-process mutex support],
+[apr_cv_mutex_robust_shared],
+[AC_TRY_RUN([
+#include <sys/types.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+ pthread_mutex_t mutex;
+ pthread_mutexattr_t attr;
+
+ if (pthread_mutexattr_init(&attr))
+ exit(1);
+ if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED))
+ exit(2);
+ if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST_NP))
+ exit(3);
+ if (pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT))
+ exit(4);
+ if (pthread_mutex_init(&mutex, &attr))
+ exit(5);
+ if (pthread_mutexattr_destroy(&attr))
+ exit(6);
+ if (pthread_mutex_destroy(&mutex))
+ exit(7);
+
+ exit(0);
+}], [apr_cv_mutex_robust_shared=yes], [apr_cv_mutex_robust_shared=no])])
+
+if test "$apr_cv_mutex_robust_shared" = "yes"; then
+ AC_DEFINE([HAVE_PTHREAD_MUTEX_ROBUST], 1,
+ [Define if cross-process robust mutexes are available])
+fi
+])
diff --git a/configure.in b/configure.in
index c8059db74..8d29a20aa 100644
--- a/configure.in
+++ b/configure.in
@@ -1603,7 +1603,7 @@ if test "$threads" = "1"; then
ac_cv_func_pthread_mutexattr_setpshared=$apr_cv_process_shared_works])
if test "$ac_cv_func_pthread_mutexattr_setpshared" = "yes"; then
- AC_CHECK_FUNCS(pthread_mutexattr_setrobust_np)
+ APR_CHECK_PTHREAD_ROBUST_SHARED_MUTEX
fi
fi
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index 514bebabe..de9a5b047 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -325,15 +325,7 @@ static apr_status_t proc_mutex_proc_pthread_create(apr_proc_mutex_t *new_mutex,
return rv;
}
- /* It is strictly not necessary to only enable robust mutexes iff
- * priority inheritance is supported, but historically this always
- * has been the case. glibc 2.3 supports robust mutexes, but not
- * cross-process robust mutexes, so enabling the robust mutex
- * support like this ensures it is only used on Solaris, for now.
- * A (more complicated) configure check would be necessary
- * otherwise. */
-#if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) \
- && defined(_POSIX_THREAD_PRIO_INHERIT) && _POSIX_THREAD_PRIO_INHERIT > 0
+#ifdef HAVE_PTHREAD_MUTEX_ROBUST
if ((rv = pthread_mutexattr_setrobust_np(&mattr,
PTHREAD_MUTEX_ROBUST_NP))) {
#ifdef PTHREAD_SETS_ERRNO
@@ -351,7 +343,7 @@ static apr_status_t proc_mutex_proc_pthread_create(apr_proc_mutex_t *new_mutex,
pthread_mutexattr_destroy(&mattr);
return rv;
}
-#endif /* HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP && _POSIX_THREAD_PRIO_INHERIT > 0 */
+#endif /* HAVE_PTHREAD_MUTEX_ROBUST */
if ((rv = pthread_mutex_init(new_mutex->pthread_interproc, &mattr))) {
#ifdef PTHREAD_SETS_ERRNO