apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r719450 - /apr/apr-util/branches/1.3.x/dbd/apr_dbd.c
Date Fri, 21 Nov 2008 02:22:41 GMT
Author: wrowe
Date: Thu Nov 20 18:22:40 2008
New Revision: 719450

URL: http://svn.apache.org/viewvc?rev=719450&view=rev
Log:
Remove redundant and wrongly structured code, *driver would not
have been initialized before setting a corrupt value into the
drivers hash.

Even if re->init is not called for, this code would be better structured
+        if (rv == APR_SUCCESS && (*driver)->init) {
but I believe we must init in the context of apr (not simply the driver's
initialization logic).

Backports: 719448

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

Modified: apr/apr-util/branches/1.3.x/dbd/apr_dbd.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/dbd/apr_dbd.c?rev=719450&r1=719449&r2=719450&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/dbd/apr_dbd.c (original)
+++ apr/apr-util/branches/1.3.x/dbd/apr_dbd.c Thu Nov 20 18:22:40 2008
@@ -101,6 +101,7 @@
     /* deprecate in 2.0 - permit implicit initialization */
     apu_dso_init(pool);
 #endif
+
     drivers = apr_hash_make(pool);
 
 #if APR_HAS_THREADS
@@ -109,6 +110,7 @@
 #endif
 
 #if !APU_DSO_BUILD
+
     /* Load statically-linked drivers: */
 #if APU_HAVE_MYSQL
     DRIVER_LOAD("mysql", apr_dbd_mysql_driver, pool);
@@ -182,18 +184,16 @@
 #endif
     apr_snprintf(symname, sizeof(symname), "apr_dbd_%s_driver", name);
     rv = apu_dso_load(&symbol, modname, symname, pool);
-    if (rv != APR_SUCCESS) { /* APR_EDSOOPEN or APR_ESYMNOTFOUND? */
-        if (rv == APR_EINIT) { /* previously loaded?!? */
-            name = apr_pstrdup(pool, name);
-            apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
-            rv = APR_SUCCESS;
+    if (rv == APR_SUCCESS || rv == APR_EINIT) { /* previously loaded?!? */
+        *driver = symbol;
+        name = apr_pstrdup(pool, name);
+        apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
+        rv = APR_SUCCESS;
+        if ((*driver)->init) {
+            (*driver)->init(pool);
         }
         goto unlock;
     }
-    *driver = symbol;
-    if ((*driver)->init) {
-        (*driver)->init(pool);
-    }
     name = apr_pstrdup(pool, name);
     apr_hash_set(drivers, name, APR_HASH_KEY_STRING, *driver);
 



Mime
View raw message