apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <n...@webthing.com>
Subject Re: apr_dbd_init
Date Fri, 31 Mar 2006 10:00:16 GMT
On Tuesday 28 March 2006 00:21, Bojan Smojver wrote:
> Quoting Nick Kew <nick@webthing.com>:
> > I don't think your suggestion is quite enough, as the lifetime
> > of "drivers" is tied to the pool.  But if we add a pool cleanup
> > that resets drivers to NULL, it should be fine AFAICS.
> >
> > I'll put that in if noone shouts.
>
> Excellent! Thanks.

Proposed patch below.

When I ran svn diff on it, I found another uncommitted change:
apr_dbd_get_name (get column names).  I see a bunch of patches
from you dated February.  I'm going to work through and (hopefully)
apply them now, if I can keep distractions at bay for long enough.


--- apr_dbd.c   (revision 390371)
+++ apr_dbd.c   (working copy)
@@ -63,17 +63,32 @@
     }
 #endif

+static apr_status_t apr_dbd_term(void *ptr)
+{
+    /* set drivers to NULL so init can work again */
+    drivers = NULL;
+
+    /* Everything else we need is handled by cleanups registered
+     * when we created mutexes and loaded DSOs
+     */
+    return APR_SUCCESS;
+}
+
 APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool)
 {
     apr_status_t ret = APR_SUCCESS;
+
+    if (drivers != NULL) {
+        return APR_SUCCESS;
+    }
     drivers = apr_hash_make(pool);
+    apr_pool_cleanup_register(pool, NULL, apr_dbd_term,
+                              apr_pool_cleanup_null);


 #if APR_HAS_THREADS
     ret = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, pool);
-    apr_pool_cleanup_register(pool, mutex,
-                              CLEANUP_CAST apr_thread_mutex_destroy,
-                              apr_pool_cleanup_null);
+    /* This already registers a pool cleanup */
 #endif

 #ifndef APR_DSO_BUILD

-- 
Nick Kew

Mime
View raw message