apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r392812 - in /apr/apr-util/branches/1.2.x: CHANGES dbd/apr_dbd.c
Date Sun, 09 Apr 2006 19:37:13 GMT
Author: niq
Date: Sun Apr  9 12:37:11 2006
New Revision: 392812

URL: http://svn.apache.org/viewcvs?rev=392812&view=rev
Log:
Backport fix to make apr_dbd_init safe to call multiple times

Modified:
    apr/apr-util/branches/1.2.x/CHANGES
    apr/apr-util/branches/1.2.x/dbd/apr_dbd.c

Modified: apr/apr-util/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/CHANGES?rev=392812&r1=392811&r2=392812&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/CHANGES (original)
+++ apr/apr-util/branches/1.2.x/CHANGES Sun Apr  9 12:37:11 2006
@@ -1,5 +1,8 @@
 Changes with APR-util 1.2.7
 
+  *) Fix apr_dbd_init to be safe to call multiple times
+     [Bojan Smojver <bojan rexursive com>, Nick Kew]
+
   *) Win32 / Netware - add missing apu_version.c for apu_version_string()
      to the Windows and Netware specific builds.  Unix platforms supported
      this API since 0.9.1.  [William Rowe, Brad Nicholes].

Modified: apr/apr-util/branches/1.2.x/dbd/apr_dbd.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/dbd/apr_dbd.c?rev=392812&r1=392811&r2=392812&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/dbd/apr_dbd.c (original)
+++ apr/apr-util/branches/1.2.x/dbd/apr_dbd.c Sun Apr  9 12:37:11 2006
@@ -48,22 +48,36 @@
     }
 #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_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_DSO_BUILD
 
 #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
 
 #else
-    ret = APR_SUCCESS;
 
 #if APU_HAVE_MYSQL
     DRIVER_LOAD("mysql", apr_dbd_mysql_driver, pool);



Mime
View raw message