From: Nick Kew Date: Sat, 9 Dec 2006 19:56:07 +0000 (+0000) Subject: mod_dbd backports: X-Git-Tag: 2.2.4~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b32b40aab44a22d0c329a82e1f3a6ebc6f2af9ea;p=thirdparty%2Fapache%2Fhttpd.git mod_dbd backports: (1) Key connection pools to virtualhosts (niq, minfrin; reviewed us + wrowe) (2) share per-request database handles across subrequests (chrisd; reviewed niq + rpluem). Including fixing compiler warning (rpluem). More to come on mod_dbd git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@485053 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c0789db3ece..f05b0573e00 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.4 + *) mod_dbd: share per-request database handles across subrequests + and internal redirects [Chris Darroch] + + *) mod_dbd: key connection pools correctly to virtual hosts + [Graham Leggett, Nick Kew] + *) Better detection and clean up of ldap connection that has been terminated by the ldap server. PR 40878. [Rob Baily ] diff --git a/STATUS b/STATUS index 1893a079e7d..497b9db8768 100644 --- a/STATUS +++ b/STATUS @@ -78,18 +78,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_dbd: Key the storage of prepared statements on the hex string - value of server_rec, rather than the server name, as the server name - may change (eg when the server name is set) at any time, causing - weird behaviour in modules dependent on mod_dbd. - Trunk: http://svn.apache.org/viewvc?view=rev&revision=466641 - niq: This is actually cumulative with R432562, R432560, 424798 - which were not yet backported. They fix a nasty bug, - and minfrin's fix is better than mine. - Cumulative patch: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/database/mod_dbd.c?r1=466641&r2=420983&pathrev=466641 - +1: minfrin, niq, wrowe - jim asks: Are the +1's on the Cumulative patch? - PATCHES PROPOSED TO BACKPORT FROM TRUNK: * mpm_winnt: Fix return values from wait_for_many_objects. @@ -241,19 +229,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK: don't you think? grow the error text pad to a sane width before backporting, please. - * mod_dbd: Stash DBD connections in request_config of initial request - only, or else sub-requests and internal redirections may cause - entire DBD pool to be stashed in a single HTTP request. - Trunk version of patch: - http://svn.apache.org/viewvc?view=rev&revision=481509 - 2.2.x version of patch: - Trunk version works - +1: chrisd, niq - rpluem says: Please add r483630 - (http://svn.apache.org/viewvc?view=rev&rev=483630) to this - proposal as it fixes a compiler warning. Once this is added - to the proposal I am +1. - * mod_proxy_balancer: Have the find_best_worker() function increment the elected counter, rather than requiring each ind lb method to do it, isolating what each lb method diff --git a/modules/database/mod_dbd.c b/modules/database/mod_dbd.c index c236fedd868..e5409a3b6fc 100644 --- a/modules/database/mod_dbd.c +++ b/modules/database/mod_dbd.c @@ -25,6 +25,7 @@ #include "http_protocol.h" #include "http_config.h" #include "http_log.h" +#include "http_request.h" #include "apr_reslist.h" #include "apr_strings.h" #include "apr_dbd.h" @@ -147,12 +148,11 @@ DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec *s, const char *query, const char *label) { dbd_prepared *prepared = apr_pcalloc(s->process->pool, sizeof(dbd_prepared)); + const char *key = apr_psprintf(s->process->pool, "%pp", s); prepared->label = label; prepared->query = query; - prepared->next = apr_hash_get(dbd_prepared_defns, s->server_hostname, - APR_HASH_KEY_STRING); - apr_hash_set(dbd_prepared_defns, s->server_hostname, APR_HASH_KEY_STRING, - prepared); + prepared->next = apr_hash_get(dbd_prepared_defns, key, APR_HASH_KEY_STRING); + apr_hash_set(dbd_prepared_defns, key, APR_HASH_KEY_STRING, prepared); } static const char *dbd_prepare(cmd_parms *cmd, void *cfg, const char *query, const char *label) @@ -525,7 +525,18 @@ static apr_status_t dbd_release(void *REQ) DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_acquire(request_rec *r) { svr_cfg *svr; - dbd_pool_rec *req = ap_get_module_config(r->request_config, &dbd_module); + dbd_pool_rec *req; + + while (!ap_is_initial_req(r)) { + if (r->prev) { + r = r->prev; + } + else if (r->main) { + r = r->main; + } + } + + req = ap_get_module_config(r->request_config, &dbd_module); if (!req) { req = apr_palloc(r->pool, sizeof(dbd_pool_rec)); req->conn = ap_dbd_open(r->pool, r->server); @@ -572,7 +583,18 @@ DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_cacquire(conn_rec *c) DBD_DECLARE_NONSTD(ap_dbd_t *) ap_dbd_acquire(request_rec *r) { svr_cfg *svr; - ap_dbd_t *ret = ap_get_module_config(r->request_config, &dbd_module); + ap_dbd_t *ret; + + while (!ap_is_initial_req(r)) { + if (r->prev) { + r = r->prev; + } + else if (r->main) { + r = r->main; + } + } + + ret = ap_get_module_config(r->request_config, &dbd_module); if (!ret) { svr = ap_get_module_config(r->server->module_config, &dbd_module); ret = ap_dbd_open(r->pool, r->server); @@ -618,8 +640,9 @@ static int dbd_post_config(apr_pool_t *pconf, apr_pool_t *plog, svr_cfg *svr; server_rec *sp; for (sp = s; sp; sp = sp->next) { + const char *key = apr_psprintf(s->process->pool, "%pp", s); svr = ap_get_module_config(sp->module_config, &dbd_module); - svr->prepared = apr_hash_get(dbd_prepared_defns, sp->server_hostname, + svr->prepared = apr_hash_get(dbd_prepared_defns, key, APR_HASH_KEY_STRING); } return OK;