Commit 1dbf2abf authored by Graham Leggett's avatar Graham Leggett
Browse files

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
parent 3585f94d
Loading
Loading
Loading
Loading
+5 −0
Changes for CHANGES: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+2 −11
Changes for modules/database/mod_dbd.c: 2 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -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);