From 1edf74155f0d7bff05077c01eeec98f58e5740fa Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Sun, 22 Oct 2006 13:31:25 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@466641 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ modules/database/mod_dbd.c | 13 ++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 6f5a7d2b896..daf1b436f7a 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) 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. [Graham Leggett] + *) mod_proxy_fcgi: Added win32 build. [Mladen Turk] *) mod_authnz_ldap: Add an AuthLDAPRemoteUserAttribute directive. If diff --git a/modules/database/mod_dbd.c b/modules/database/mod_dbd.c index af404d494ea..624869c2b74 100644 --- a/modules/database/mod_dbd.c +++ b/modules/database/mod_dbd.c @@ -68,7 +68,6 @@ typedef enum { cmd_name, cmd_params, cmd_persist, } cmd_parts; static apr_hash_t *dbd_prepared_defns; -static const char *const default_hostname = "*"; /* a default DBDriver value that'll generate meaningful error messages */ static const char *const no_dbdriver = "[DBDriver unset]"; @@ -148,12 +147,7 @@ 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 = s->server_hostname; - if (key == NULL) { - key = default_hostname; - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, - "DBD: ServerName should be set before declaring any prepared statements"); - } + const char *key = apr_psprintf(s->process->pool, "%pp", s); prepared->label = label; prepared->query = query; prepared->next = apr_hash_get(dbd_prepared_defns, key, APR_HASH_KEY_STRING); @@ -623,10 +617,7 @@ 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 = s->server_hostname; - if (key == NULL) { - key = default_hostname; - } + 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, key, APR_HASH_KEY_STRING); -- 2.47.2