summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraaron <aaron@13f79535-47bb-0310-9956-ffa450edef68>2002-02-18 02:20:07 +0000
committeraaron <aaron@13f79535-47bb-0310-9956-ffa450edef68>2002-02-18 02:20:07 +0000
commitb023c6e199c14bfabfd949ca383c17aef58a3045 (patch)
tree49221678e5b5f871f831b11b195422924f72ec3d
parente2b037f970ce2ebc0d0d632b8a79d1738f1ae3db (diff)
downloadlibapr-b023c6e199c14bfabfd949ca383c17aef58a3045.tar.gz
Make apr_global_mutex_t work on systems w/o APR_HAS_THREADS.
If you don't have threads, you don't need to use cross-thread mutual exclusion, so this becomes essentially apr_proc_mutex_t. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63007 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/arch/unix/global_mutex.h2
-rw-r--r--locks/unix/global_mutex.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/include/arch/unix/global_mutex.h b/include/arch/unix/global_mutex.h
index e1a79bd5d..dfafcb1fd 100644
--- a/include/arch/unix/global_mutex.h
+++ b/include/arch/unix/global_mutex.h
@@ -66,7 +66,9 @@
struct apr_global_mutex_t {
apr_pool_t *pool;
apr_proc_mutex_t *proc_mutex;
+#if APR_HAS_THREADS
apr_thread_mutex_t *thread_mutex;
+#endif /* APR_HAS_THREADS */
};
#endif /* GLOBAL_MUTEX_H */
diff --git a/locks/unix/global_mutex.c b/locks/unix/global_mutex.c
index fcd6d6937..c3b1ed3e1 100644
--- a/locks/unix/global_mutex.c
+++ b/locks/unix/global_mutex.c
@@ -58,18 +58,19 @@
#include "apr_proc_mutex.h"
#include "apr_thread_mutex.h"
-
static apr_status_t global_mutex_cleanup(void *data)
{
apr_global_mutex_t *m = (apr_global_mutex_t *)data;
apr_status_t rv;
+#if APR_HAS_THREADS
if (m->thread_mutex) {
rv = apr_thread_mutex_destroy(m->thread_mutex);
if (rv != APR_SUCCESS) {
return rv;
}
}
+#endif /* APR_HAS_THREADS */
rv = apr_proc_mutex_destroy(m->proc_mutex);
if (rv != APR_SUCCESS) {
return rv;
@@ -93,6 +94,7 @@ APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
return rv;
}
+#if APR_HAS_THREADS
if (m->proc_mutex->inter_meth->flags & APR_PROCESS_LOCK_MECH_IS_GLOBAL) {
m->thread_mutex = NULL; /* We don't need a thread lock. */
}
@@ -103,6 +105,7 @@ APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
return rv;
}
}
+#endif /* APR_HAS_THREADS */
apr_pool_cleanup_register(m->pool, (void *)m,
global_mutex_cleanup, apr_pool_cleanup_null);
@@ -122,12 +125,14 @@ APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
{
apr_status_t rv;
+#if APR_HAS_THREADS
if (mutex->thread_mutex) {
rv = apr_thread_mutex_lock(mutex->thread_mutex);
if (rv != APR_SUCCESS) {
return rv;
}
}
+#endif /* APR_HAS_THREADS */
rv = apr_proc_mutex_lock(mutex->proc_mutex);
if (rv != APR_SUCCESS) {
return rv;
@@ -139,12 +144,14 @@ APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
{
apr_status_t rv;
+#if APR_HAS_THREADS
if (mutex->thread_mutex) {
rv = apr_thread_mutex_trylock(mutex->thread_mutex);
if (rv != APR_SUCCESS) {
return rv;
}
}
+#endif /* APR_HAS_THREADS */
rv = apr_proc_mutex_trylock(mutex->proc_mutex);
if (rv != APR_SUCCESS) {
return rv;
@@ -160,12 +167,14 @@ APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
if (rv != APR_SUCCESS) {
return rv;
}
+#if APR_HAS_THREADS
if (mutex->thread_mutex) {
rv = apr_thread_mutex_unlock(mutex->thread_mutex);
if (rv != APR_SUCCESS) {
return rv;
}
}
+#endif /* APR_HAS_THREADS */
return APR_SUCCESS;
}
@@ -175,4 +184,3 @@ APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
}
APR_POOL_IMPLEMENT_ACCESSOR(global_mutex);
-