apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r382030 - in /apr/apr/trunk: build/apr_threads.m4 configure.in locks/unix/proc_mutex.c
Date Wed, 01 Mar 2006 14:30:08 GMT
Author: jorton
Date: Wed Mar  1 06:29:43 2006
New Revision: 382030

URL: http://svn.apache.org/viewcvs?rev=382030&view=rev
Log:
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.

Modified:
    apr/apr/trunk/build/apr_threads.m4
    apr/apr/trunk/configure.in
    apr/apr/trunk/locks/unix/proc_mutex.c

Modified: apr/apr/trunk/build/apr_threads.m4
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/build/apr_threads.m4?rev=382030&r1=382029&r2=382030&view=diff
==============================================================================
--- apr/apr/trunk/build/apr_threads.m4 (original)
+++ apr/apr/trunk/build/apr_threads.m4 Wed Mar  1 06:29:43 2006
@@ -242,3 +242,41 @@
              [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
+])

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/configure.in?rev=382030&r1=382029&r2=382030&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Wed Mar  1 06:29:43 2006
@@ -1603,7 +1603,7 @@
       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
 

Modified: apr/apr/trunk/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/locks/unix/proc_mutex.c?rev=382030&r1=382029&r2=382030&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/proc_mutex.c (original)
+++ apr/apr/trunk/locks/unix/proc_mutex.c Wed Mar  1 06:29:43 2006
@@ -325,15 +325,7 @@
         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 @@
         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



Mime
View raw message