]> granicus.if.org Git - apache/commitdiff
mod_dbd: Key the storage of prepared statements on the hex string
authorGraham Leggett <minfrin@apache.org>
Sun, 22 Oct 2006 13:31:25 +0000 (13:31 +0000)
committerGraham Leggett <minfrin@apache.org>
Sun, 22 Oct 2006 13:31:25 +0000 (13:31 +0000)
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
modules/database/mod_dbd.c

diff --git a/CHANGES b/CHANGES
index 6f5a7d2b896697b58ac0ea4c6935694cdc59f77d..daf1b436f7a7ed6cee9fb7cd2eea3e759588306b 100644 (file)
--- 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
index af404d494ea5eae71c461162ff525b8ba877fd9c..624869c2b74da484d371c8f09c8752292574c3ae 100644 (file)
@@ -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);