summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in7
-rw-r--r--locks/unix/thread_mutex.c19
2 files changed, 26 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 47f0d0b26..937bc22ba 100644
--- a/configure.in
+++ b/configure.in
@@ -435,6 +435,13 @@ AC_ARG_ENABLE(pool-debug,
fi
])
+AC_ARG_ENABLE(thread-debug,
+ [ --enable-thread-debug Turn on run-time thread debugging tests],
+ [ if test $enableval = yes; then
+ APR_ADDTO(CPPFLAGS, [-DAPR_THREAD_DEBUG=1])
+ fi
+ ])
+
if test "$host" = "i586-pc-beos"; then
AC_ARG_ENABLE(malloc-debug,[ --enable-malloc-debug Switch on malloc_debug for BeOS],
APR_REMOVEFROM(CFLAGS, -O2)
diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c
index f027c791f..5e21aac13 100644
--- a/locks/unix/thread_mutex.c
+++ b/locks/unix/thread_mutex.c
@@ -68,7 +68,26 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
pthread_mutexattr_destroy(&mattr);
} else
#endif
+ {
+#if defined(APR_THREAD_DEBUG)
+ pthread_mutexattr_t mattr;
+
+ rv = pthread_mutexattr_init(&mattr);
+ if (rv) return rv;
+
+ rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ERRORCHECK);
+ if (rv) {
+ pthread_mutexattr_destroy(&mattr);
+ return rv;
+ }
+
+ rv = pthread_mutex_init(&new_mutex->mutex, &mattr);
+
+ pthread_mutexattr_destroy(&mattr);
+#else
rv = pthread_mutex_init(&new_mutex->mutex, NULL);
+#endif
+ }
if (rv) {
#ifdef HAVE_ZOS_PTHREADS