mod_dbd.c revision 985e9c42880c9b0ded7c99d780efa917aec4b4ae
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering/* Copyright 2003-5 The Apache Software Foundation or its licensors, as
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * Licensed under the Apache License, Version 2.0 (the "License");
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * you may not use this file except in compliance with the License.
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * You may obtain a copy of the License at
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * http://www.apache.org/licenses/LICENSE-2.0
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * Unless required by applicable law or agreed to in writing, software
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * distributed under the License is distributed on an "AS IS" BASIS,
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * See the License for the specific language governing permissions and
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * limitations under the License.
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering/* Overview of what this is and does:
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poetteringextern module AP_MODULE_DECLARE_DATA dbd_module;
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering/************ svr cfg: manage db connection pool ****************/
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poetteringtypedef struct svr_cfg {
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poetteringtypedef enum { cmd_name, cmd_params, cmd_persist,
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering for (p = val; *p; ++p) \
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering return "Argument must be numeric!"
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poetteringstatic const char *dbd_param(cmd_parms *cmd, void *cfg, const char *val)
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering const char *p;
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering svr_cfg *svr = (svr_cfg*) ap_get_module_config
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering (cmd->server->module_config, &dbd_module);
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering /* loading the driver involves once-only dlloading that is
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * best done at server startup. This also guarantees that
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering * we won't return an error later.
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering switch (apr_dbd_get_driver(cmd->pool, svr->name, &driver)) {
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering return apr_psprintf(cmd->pool, "DBD: No driver for %s", svr->name);
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering "DBD: Can't load driver file apr_dbd_%s.so",
7ccbd1ae843d77275f2c542582a9a80e5e058a70Lennart Poettering "DBD: Failed to load driver apr_dbd_%s_driver",
return NULL;
const char *label)
return NULL;
"Use persistent connection/pool"),
#if APR_HAS_THREADS
{NULL}
#define DEFAULT_NMIN 0
#if APR_HAS_THREADS
return cfg;
#if APR_HAS_THREADS
return svr;
dbd_prepared *p;
return ret;
switch (rv) {
case APR_ENOTIMPL:
return rv;
case APR_EDSOOPEN:
return rv;
case APR_ESYMNOTFOUND:
return rv;
return rv;
case APR_SUCCESS:
switch (rv) {
case APR_EGENERAL:
return rv;
return rv;
case APR_SUCCESS:
return rv;
#if APR_HAS_THREADS
(void*)apr_reslist_destroy,
return rv;
#if APR_HAS_THREADS
#if APR_HAS_THREADS
const char *errmsg;
return NULL;
return NULL;
if (!errmsg) {
return NULL;
return arec;
const char *errmsg;
if (!errmsg) {
#if APR_HAS_THREADS
} dbd_pool_rec;
return APR_SUCCESS;
if (!req) {
if (!req) {
if (!ret) {
if (ret) {
return ret;
if (!ret) {
if (ret) {
return ret;
#if APR_HAS_THREADS
NULL,
NULL,