diff options
author | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-30 15:34:13 +0000 |
---|---|---|
committer | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-30 15:34:13 +0000 |
commit | 048fd124c51785d138037255f2c01ab894d253ca (patch) | |
tree | 54d6e5a4c4366ebb1571780c9c32d3037d6c8172 | |
parent | f597d5ccc902ff4b4c0cca22a3b93092b877980b (diff) | |
download | libapr-048fd124c51785d138037255f2c01ab894d253ca.tar.gz |
Backport 552161 from trunk:
Avoid overwriting the hash_mutex table for applications that incorrectly calls
apr_atomic_init().
Noticied by: Tim Jones
PR: 42760
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.2.x@552163 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | atomic/unix/apr_atomic.c | 16 |
2 files changed, 19 insertions, 0 deletions
@@ -1,5 +1,8 @@ Changes for APR 1.2.10 + *) Avoid overwriting the hash_mutex table for applications that + incorrectly calls apr_atomic_init(). PR 42760. [Davi Arnaut] + *) Allow IPv6 connectivity test to fail, avoiding a potentially fatal error. [Davi Arnaut] diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c index 3110d96d7..ed85a429b 100644 --- a/atomic/unix/apr_atomic.c +++ b/atomic/unix/apr_atomic.c @@ -171,12 +171,28 @@ APR_DECLARE(apr_uint32_t) apr_atomic_add32(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]), |