summaryrefslogtreecommitdiff
path: root/atomic
diff options
context:
space:
mode:
Diffstat (limited to 'atomic')
-rw-r--r--atomic/unix/apr_atomic.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c
index 7aab87870..2bd645e05 100644
--- a/atomic/unix/apr_atomic.c
+++ b/atomic/unix/apr_atomic.c
@@ -226,12 +226,28 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem,
static apr_thread_mutex_t **hash_mutex;
#endif /* APR_HAS_THREADS */
+#if APR_HAS_THREADS
+static apr_status_t atomic_cleanup(void *data)
+{
+ if (hash_mutex == data)
+ hash_mutex = NULL;
+
+ return APR_SUCCESS;
+}
+#endif
+
apr_status_t apr_atomic_init(apr_pool_t *p)
{
#if APR_HAS_THREADS
int i;
apr_status_t rv;
+
+ if (hash_mutex != NULL)
+ return APR_SUCCESS;
+
hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH);
+ apr_pool_cleanup_register(p, hash_mutex, atomic_cleanup,
+ apr_pool_cleanup_null);
for (i = 0; i < NUM_ATOMIC_HASH; i++) {
rv = apr_thread_mutex_create(&(hash_mutex[i]),