On Tue, 2009-06-09 at 10:58 -0500, William A. Rowe, Jr. wrote:
> You are not missing anything, and solutions are welcomed.
I'm not sure that I'm addressing the right problem here. So, limit
yourself to rocks of no more than 2kg when throwing.
Obviously, there is no guarantee that int's are atomic, so this patch
as-is is bogus. However, we have an atomic API in APR, so we can replace
the int's with apr_uint32_t, use that API to increment/decrement the
variables and also initialise it from apr_initialize() function, which
would then make sure it is available.
Complete nonsense?
--
Bojan
Index: misc/apu_dso.c
===================================================================
--- misc/apu_dso.c (revision 783165)
+++ misc/apu_dso.c (working copy)
@@ -37,6 +37,7 @@
static apr_thread_mutex_t* mutex = NULL;
#endif
static apr_hash_t *dsos = NULL;
+static int initialised = 0, in_init = 1; /* int's are atomic? */
#if APR_HAS_THREADS
apr_status_t apu_dso_mutex_lock()
@@ -76,7 +77,10 @@
apr_pool_t *global;
apr_pool_t *parent;
- if (dsos != NULL) {
+ if (initialised++) {
+ while (in_init) /* wait until we get fully inited */
+ ;
+
return APR_SUCCESS;
}
@@ -94,6 +98,8 @@
apr_pool_cleanup_register(global, NULL, apu_dso_term,
apr_pool_cleanup_null);
+ in_init--;
+
return ret;
}
Index: dbm/apr_dbm.c
===================================================================
--- dbm/apr_dbm.c (revision 783165)
+++ dbm/apr_dbm.c (working copy)
@@ -59,6 +59,7 @@
#if APU_DSO_BUILD
static apr_hash_t *drivers = NULL;
+static int initialised = 0, in_init = 1; /* int's are atomic? */
static apr_status_t dbm_term(void *ptr)
{
@@ -117,8 +118,11 @@
}
else usertype = 1;
- if (!drivers)
- {
+ if (initialised++) {
+ while (in_init) /* wait until we get fully inited */
+ ;
+ }
+ else {
apr_pool_t *parent;
/* Top level pool scope, need process-scope lifetime */
@@ -133,6 +137,8 @@
apr_pool_cleanup_register(pool, NULL, dbm_term,
apr_pool_cleanup_null);
+
+ in_init--;
}
rv = apu_dso_mutex_lock();