httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r345135 - in /httpd/httpd/branches/2.2.x/modules/database: mod_dbd.c mod_dbd.h
Date Wed, 16 Nov 2005 22:08:45 GMT
Author: niq
Date: Wed Nov 16 14:08:41 2005
New Revision: 345135

URL: http://svn.apache.org/viewcvs?rev=345135&view=rev
Log:
Backport today's simple fixes

Modified:
    httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c
    httpd/httpd/branches/2.2.x/modules/database/mod_dbd.h

Modified: httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c?rev=345135&r1=345134&r2=345135&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c (original)
+++ httpd/httpd/branches/2.2.x/modules/database/mod_dbd.c Wed Nov 16 14:08:41 2005
@@ -76,7 +76,7 @@
         svr->name = val;
         /* loading the driver involves once-only dlloading that is
          * best done at server startup.  This also guarantees that
-         * load_driver won't return an error later.
+         * we won't return an error later.
          */
         switch (apr_dbd_get_driver(cmd->pool, svr->name, &driver)) {
         case APR_ENOTIMPL:
@@ -185,6 +185,7 @@
 {
     svr_cfg *svr = (svr_cfg*) apr_pcalloc(p, sizeof(svr_cfg));
     svr->persist = -1;
+    svr->name = svr->params = ""; /* don't risk segfault on misconfiguration */
 #if APR_HAS_THREADS
     svr->nmin = DEFAULT_NMIN;
     svr->nkeep = DEFAULT_NKEEP;
@@ -298,6 +299,23 @@
         - open acquires a connection from the pool (opens one if necessary)
         - close releases it back in to the pool
 */
+void ap_dbd_close(server_rec *s, ap_dbd_t *sql)
+{
+    svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
+    if (!svr->persist) {
+        apr_dbd_close(sql->driver, sql->handle);
+    }
+#if APR_HAS_THREADS
+    else {
+        apr_reslist_release(svr->dbpool, sql);
+    }
+#endif
+}
+static apr_status_t dbd_close(void *CONN)
+{
+    ap_dbd_t *conn = CONN;
+    return apr_dbd_close(conn->driver, conn->handle);
+}
 #define arec ((ap_dbd_t*)rec)
 #if APR_HAS_THREADS
 ap_dbd_t* ap_dbd_open(apr_pool_t *pool, server_rec *s)
@@ -366,29 +384,15 @@
     }
 /* We don't have a connection right now, so we'll open one */
     if (!svr->conn) {
-        rv = dbd_construct(&rec, svr, s->process->pool);
-        svr->conn = (rv == APR_SUCCESS) ? arec : NULL;
+        if (dbd_construct(&rec, svr, s->process->pool) == APR_SUCCESS) {
+            svr->conn = arec ;
+            apr_pool_cleanup_register(s->process->pool, svr->conn,
+                                      dbd_close, apr_pool_cleanup_null);
+        }
     }
     return svr->conn;
 }
 #endif
-void ap_dbd_close(server_rec *s, ap_dbd_t *sql)
-{
-    svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
-    if (!svr->persist) {
-        apr_dbd_close(sql->driver, sql->handle);
-    }
-#if APR_HAS_THREADS
-    else {
-        apr_reslist_release(svr->dbpool, sql);
-    }
-#endif
-}
-static apr_status_t dbd_close(void *CONN)
-{
-    ap_dbd_t *conn = CONN;
-    return apr_dbd_close(conn->driver, conn->handle);
-}
 #if APR_HAS_THREADS
 typedef struct {
     ap_dbd_t *conn;

Modified: httpd/httpd/branches/2.2.x/modules/database/mod_dbd.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/2.2.x/modules/database/mod_dbd.h?rev=345135&r1=345134&r2=345135&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/database/mod_dbd.h (original)
+++ httpd/httpd/branches/2.2.x/modules/database/mod_dbd.h Wed Nov 16 14:08:41 2005
@@ -64,7 +64,10 @@
  */
 AP_DECLARE(ap_dbd_t*) ap_dbd_cacquire(conn_rec*);
 
-/* Prepare a statement for use by a client module */
+/* Prepare a statement for use by a client module during
+ * the server startup/configuration phase.  Can't be called
+ * after the server has created its children (use apr_dbd_*).
+ */
 AP_DECLARE(void) ap_dbd_prepare(server_rec*, const char*, const char*);
 
 /* Also export them as optional functions for modules that prefer it */



Mime
View raw message