apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r719448 - /apr/apr-util/trunk/dbd/apr_dbd.c
Date Fri, 21 Nov 2008 02:14:36 GMT
Author: wrowe
Date: Thu Nov 20 18:14:35 2008
New Revision: 719448

URL: http://svn.apache.org/viewvc?rev=719448&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).


Modified:
    apr/apr-util/trunk/dbd/apr_dbd.c

Modified: apr/apr-util/trunk/dbd/apr_dbd.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd.c?rev=719448&r1=719447&r2=719448&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd.c Thu Nov 20 18:14:35 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,22 +184,15 @@
 #endif
     apr_snprintf(symname, sizeof(symname), "apr_dbd_%s_driver", name);
     rv = apu_dso_load(NULL, &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);
-
-unlock:
     apu_dso_mutex_unlock();
 
 #else /* not builtin and !APR_HAS_DSO => not implemented */



Mime
View raw message