apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42760] - Atomic hash_mutex overwritten on multiple calls to apr_atomic_init
Date Thu, 28 Jun 2007 11:41:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42760>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42760





------- Additional Comments From tim@mr-dog.net  2007-06-28 04:41 -------
(From update of attachment 20408)
>Index: apr_atomic.c
>===================================================================
>--- apr_atomic.c	(revision 5)
>+++ apr_atomic.c	(working copy)
>@@ -168,7 +168,7 @@
> #define NUM_ATOMIC_HASH 7
> /* shift by 2 to get rid of alignment issues */
> #define ATOMIC_HASH(x) (unsigned int)(((unsigned long)(x)>>2)%(unsigned int)NUM_ATOMIC_HASH)
>-static apr_thread_mutex_t **hash_mutex;
>+static apr_thread_mutex_t **hash_mutex = NULL;
> #endif /* APR_HAS_THREADS */
> 
> apr_status_t apr_atomic_init(apr_pool_t *p)
>@@ -176,13 +176,16 @@
> #if APR_HAS_THREADS
>     int i;
>     apr_status_t rv;
>-    hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH);
> 
>-    for (i = 0; i < NUM_ATOMIC_HASH; i++) {
>-        rv = apr_thread_mutex_create(&(hash_mutex[i]),
>-                                     APR_THREAD_MUTEX_DEFAULT, p);
>-        if (rv != APR_SUCCESS) {
>-           return rv;
>+    if (hash_mutex == NULL) {
>+        hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH);
>+
>+        for (i = 0; i < NUM_ATOMIC_HASH; i++) {
>+            rv = apr_thread_mutex_create(&(hash_mutex[i]),
>+                                         APR_THREAD_MUTEX_DEFAULT, p);
>+            if (rv != APR_SUCCESS) {
>+                return rv;
>+            }
>         }
>     }
> #endif /* APR_HAS_THREADS */


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message