diff options
author | Davi Arnaut <davi@apache.org> | 2007-06-30 15:20:55 +0000 |
---|---|---|
committer | Davi Arnaut <davi@apache.org> | 2007-06-30 15:20:55 +0000 |
commit | 728dc1a0f21a68acdc5b02744ca12c9cc9aaae88 (patch) | |
tree | c8c7aa18ba3fa4cfe43a575c29ee79e159d864e5 /atomic/unix | |
parent | 3402b461e787d36f089afd6ad4133ee631e71806 (diff) | |
download | apr-728dc1a0f21a68acdc5b02744ca12c9cc9aaae88.tar.gz |
Avoid overwriting the hash_mutex table for applications that incorrectly calls
apr_atomic_init().
Noticied by: Tim Jones
PR: 42760
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@552161 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'atomic/unix')
-rw-r--r-- | atomic/unix/apr_atomic.c | 16 |
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]), |