httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r307439 - in /httpd/httpd/trunk/modules/database: mod_dbd.c mod_dbd.h
Date Sun, 09 Oct 2005 14:19:26 GMT
Author: niq
Date: Sun Oct  9 07:19:22 2005
New Revision: 307439

URL: http://svn.apache.org/viewcvs?rev=307439&view=rev
Log:
Support dbd connections tied to the conn_rec.

Modified:
    httpd/httpd/trunk/modules/database/mod_dbd.c
    httpd/httpd/trunk/modules/database/mod_dbd.h

Modified: httpd/httpd/trunk/modules/database/mod_dbd.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/database/mod_dbd.c?rev=307439&r1=307438&r2=307439&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/database/mod_dbd.c (original)
+++ httpd/httpd/trunk/modules/database/mod_dbd.c Sun Oct  9 07:19:22 2005
@@ -420,6 +420,29 @@
     }
     return req->conn;
 }
+ap_dbd_t *ap_dbd_cacquire(conn_rec *c)
+{
+    svr_cfg *svr;
+    dbd_pool_rec *req = ap_get_module_config(c->conn_config, &dbd_module);
+    if (!req) {
+        req = apr_palloc(c->pool, sizeof(dbd_pool_rec));
+        req->conn = ap_dbd_open(c->pool, c->base_server);
+        if (req->conn) {
+            svr = ap_get_module_config(c->base_server->module_config, &dbd_module);
+            ap_set_module_config(c->conn_config, &dbd_module, req);
+            if (svr->persist) {
+                req->dbpool = svr->dbpool;
+                apr_pool_cleanup_register(c->pool, req, dbd_release,
+                                          apr_pool_cleanup_null);
+            }
+            else {
+                apr_pool_cleanup_register(c->pool, req->conn, dbd_close,
+                                          apr_pool_cleanup_null);
+            }
+        }
+    }
+    return req->conn;
+}
 #else
 ap_dbd_t *ap_dbd_acquire(request_rec *r)
 {
@@ -428,7 +451,7 @@
     if (!ret) {
         svr = ap_get_module_config(r->server->module_config, &dbd_module);
         ret = ap_dbd_open(r->pool, r->server);
-        if ( ret ) {
+        if (ret) {
             ap_set_module_config(r->request_config, &dbd_module, ret);
             if (!svr->persist) {
                 apr_pool_cleanup_register(r->pool, svr->conn, dbd_close,
@@ -439,6 +462,24 @@
     }
     return ret;
 }
+ap_dbd_t *ap_dbd_cacquire(conn_rec *c)
+{
+    svr_cfg *svr;
+    ap_dbd_t *ret = ap_get_module_config(c->conn_config, &dbd_module);
+    if (!ret) {
+        svr = ap_get_module_config(c->base_server->module_config, &dbd_module);
+        ret = ap_dbd_open(c->pool, c->base_server);
+        if (ret) {
+            ap_set_module_config(c->conn_config, &dbd_module, ret);
+            if (!svr->persist) {
+                apr_pool_cleanup_register(c->pool, svr->conn, dbd_close,
+                                          apr_pool_cleanup_null);
+            }
+            /* if persist then dbd_open registered cleanup on proc pool */
+        }
+    }
+    return ret;
+}
 #endif
 
 static void dbd_hooks(apr_pool_t *pool)
@@ -449,6 +490,7 @@
     APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
     APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
     APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
+    APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
     APR_REGISTER_OPTIONAL_FN(ap_dbd_prepare);
     apr_dbd_init(pool);
 }

Modified: httpd/httpd/trunk/modules/database/mod_dbd.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/database/mod_dbd.h?rev=307439&r1=307438&r2=307439&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/database/mod_dbd.h (original)
+++ httpd/httpd/trunk/modules/database/mod_dbd.h Sun Oct  9 07:19:22 2005
@@ -58,6 +58,12 @@
  */
 AP_DECLARE(ap_dbd_t*) ap_dbd_acquire(request_rec*);
 
+/* acquire a connection that will have the lifetime of a connection
+ * and MUST NOT be explicitly closed.  Return NULL on error.
+ * This is the preferred function for most applications.
+ */
+AP_DECLARE(ap_dbd_t*) ap_dbd_cacquire(conn_rec*);
+
 /* Prepare a statement for use by a client module */
 AP_DECLARE(void) ap_dbd_prepare(server_rec*, const char*, const char*);
 
@@ -65,6 +71,7 @@
 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*));
 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*));
 APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));
+APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));
 APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));
 
 #endif



Mime
View raw message