summaryrefslogtreecommitdiff
path: root/modules/database
diff options
context:
space:
mode:
authorArno Töll <debian@toell.net>2012-01-08 22:53:17 +0100
committerArno Töll <debian@toell.net>2012-01-08 22:53:17 +0100
commite072a2dd866b7cb9f14319b80326a4e7fd16fcdf (patch)
treea49dfc56d94a26011fe157835ff6cbe14edbd8a9 /modules/database
parent0890390c00801651d08d3794e13b31a5dabbf5ef (diff)
downloadapache2-e072a2dd866b7cb9f14319b80326a4e7fd16fcdf.tar.gz
Imported Upstream version 2.3.16-beta
Diffstat (limited to 'modules/database')
-rw-r--r--modules/database/NWGNUmakefile20
-rw-r--r--modules/database/config.m42
-rw-r--r--modules/database/mod_dbd.c240
-rw-r--r--modules/database/mod_dbd.dep32
-rw-r--r--modules/database/mod_dbd.h24
-rw-r--r--modules/database/mod_dbd.mak353
6 files changed, 186 insertions, 485 deletions
diff --git a/modules/database/NWGNUmakefile b/modules/database/NWGNUmakefile
index 23013365..7a96c04e 100644
--- a/modules/database/NWGNUmakefile
+++ b/modules/database/NWGNUmakefile
@@ -3,7 +3,7 @@
#
SUBDIRS = \
- $(EOLIST)
+ $(EOLIST)
#
# Get the 'head' of the build environment. This includes default targets and
@@ -102,7 +102,7 @@ endif
NLM_NAME = moddbd
#
-# This is used by the link '-desc ' directive.
+# This is used by the link '-desc ' directive.
# If left blank, NLM_NAME will be used.
#
NLM_DESCRIPTION = Apache $(VERSION_STR) DBD Module
@@ -114,7 +114,7 @@ NLM_DESCRIPTION = Apache $(VERSION_STR) DBD Module
NLM_THREAD_NAME = DBD Module
#
-# If this is specified, it will override VERSION value in
+# If this is specified, it will override VERSION value in
# $(AP_WORK)/build/NWGNUenvironment.inc
#
NLM_VERSION =
@@ -146,11 +146,11 @@ NLM_CHECK_SYM =
NLM_FLAGS =
#
-# If this is specified it will be linked in with the XDCData option in the def
+# If this is specified it will be linked in with the XDCData option in the def
# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled
# by setting APACHE_UNIPROC in the environment
#
-XDCDATA =
+XDCDATA =
#
# If there is an NLM target, put it here
@@ -194,7 +194,7 @@ FILES_nlm_modules = \
# If the nlm has a msg file, put it's path here
#
FILE_nlm_msg =
-
+
#
# If the nlm has a hlp file put it's path here
#
@@ -213,8 +213,8 @@ FILES_nlm_Ximports = \
@httpd.imp \
@libc.imp \
$(EOLIST)
-
-#
+
+#
# Any symbols exported to here
#
FILES_nlm_exports = \
@@ -226,7 +226,7 @@ FILES_nlm_exports = \
ap_dbd_prepare \
$(EOLIST)
-#
+#
# These are the OBJ files needed to create the LIB target above.
# Paths must all use the '/' character
#
@@ -242,7 +242,7 @@ libs :: $(OBJDIR) $(TARGET_lib)
nlms :: libs $(TARGET_nlm)
#
-# Updated this target to create necessary directories and copy files to the
+# Updated this target to create necessary directories and copy files to the
# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples)
#
install :: nlms FORCE
diff --git a/modules/database/config.m4 b/modules/database/config.m4
index ab2f9415..809270be 100644
--- a/modules/database/config.m4
+++ b/modules/database/config.m4
@@ -3,4 +3,6 @@ APACHE_MODPATH_INIT(database)
APACHE_MODULE(dbd, Apache DBD Framework, , , most)
+APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current])
+
APACHE_MODPATH_FINISH
diff --git a/modules/database/mod_dbd.c b/modules/database/mod_dbd.c
index cb01193f..5ff1ea20 100644
--- a/modules/database/mod_dbd.c
+++ b/modules/database/mod_dbd.c
@@ -39,6 +39,11 @@
extern module AP_MODULE_DECLARE_DATA dbd_module;
+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(dbd, DBD, apr_status_t, post_connect,
+ (apr_pool_t *pool, dbd_cfg_t *cfg,
+ ap_dbd_t *dbd),
+ (pool, cfg, dbd), OK, DECLINED)
+
/************ svr cfg: manage db connection pool ****************/
#define NMIN_SET 0x1
@@ -46,21 +51,6 @@ extern module AP_MODULE_DECLARE_DATA dbd_module;
#define NMAX_SET 0x4
#define EXPTIME_SET 0x8
-typedef struct {
- server_rec *server;
- const char *name;
- const char *params;
- int persist;
-#if APR_HAS_THREADS
- int nmin;
- int nkeep;
- int nmax;
- int exptime;
- int set;
-#endif
- apr_hash_t *queries;
-} dbd_cfg_t;
-
typedef struct dbd_group_t dbd_group_t;
struct dbd_group_t {
@@ -99,6 +89,8 @@ static const char *const no_dbdriver = "[DBDriver unset]";
#define DEFAULT_NMAX 10
#define DEFAULT_EXPTIME 300
+#define DEFAULT_SQL_INIT_ARRAY_SIZE 5
+
static void *create_dbd_config(apr_pool_t *pool, server_rec *s)
{
svr_cfg *svr = apr_pcalloc(pool, sizeof(svr_cfg));
@@ -115,6 +107,8 @@ static void *create_dbd_config(apr_pool_t *pool, server_rec *s)
cfg->exptime = DEFAULT_EXPTIME;
#endif
cfg->queries = apr_hash_make(pool);
+ cfg->init_queries = apr_array_make(pool, DEFAULT_SQL_INIT_ARRAY_SIZE,
+ sizeof(const char *));
return svr;
}
@@ -137,22 +131,36 @@ static void *merge_dbd_config(apr_pool_t *pool, void *basev, void *addv)
new->exptime = (add->set&EXPTIME_SET) ? add->exptime : base->exptime;
#endif
new->queries = apr_hash_overlay(pool, add->queries, base->queries);
+ new->init_queries = apr_array_append(pool, add->init_queries,
+ base->init_queries);
return svr;
}
-#define ISINT(val) do { \
- const char *p; \
- \
- for (p = val; *p; ++p) { \
- if (!apr_isdigit(*p)) { \
- return "Argument must be numeric!"; \
- } \
- } \
- } while (0)
+static void ap_dbd_sql_init(server_rec *s, const char *query)
+{
+ svr_cfg *svr;
+ const char **arr_item;
+
+ svr = ap_get_module_config(s->module_config, &dbd_module);
+ if (!svr) {
+ /* some modules may call from within config directive handlers, and
+ * if these are called in a server context that contains no mod_dbd
+ * config directives, then we have to create our own server config
+ */
+ svr = create_dbd_config(config_pool, s);
+ ap_set_module_config(s->module_config, &dbd_module, svr);
+ }
+
+ if (query) {
+ arr_item = apr_array_push(svr->cfg->init_queries);
+ *arr_item = query;
+ }
+}
static const char *dbd_param(cmd_parms *cmd, void *dconf, const char *val)
{
+ apr_status_t rv;
const apr_dbd_driver_t *driver = NULL;
svr_cfg *svr = ap_get_module_config(cmd->server->module_config,
&dbd_module);
@@ -165,52 +173,69 @@ static const char *dbd_param(cmd_parms *cmd, void *dconf, const char *val)
* best done at server startup. This also guarantees that
* we won't return an error later.
*/
- switch (apr_dbd_get_driver(cmd->pool, cfg->name, &driver)) {
- case APR_ENOTIMPL:
- return apr_psprintf(cmd->pool, "DBD: No driver for %s", cfg->name);
- case APR_EDSOOPEN:
+ rv = apr_dbd_get_driver(cmd->pool, cfg->name, &driver);
+ if (APR_STATUS_IS_ENOTIMPL(rv)) {
+ return apr_psprintf(cmd->pool, "No driver for %s", cfg->name);
+ }
+ else if (APR_STATUS_IS_EDSOOPEN(rv)) {
return apr_psprintf(cmd->pool,
#ifdef NETWARE
- "DBD: Can't load driver file dbd%s.nlm",
+ "Can't load driver file dbd%s.nlm",
#else
- "DBD: Can't load driver file apr_dbd_%s.so",
+ "Can't load driver file apr_dbd_%s.so",
#endif
cfg->name);
- case APR_ESYMNOTFOUND:
+ }
+ else if (APR_STATUS_IS_ESYMNOTFOUND(rv)) {
return apr_psprintf(cmd->pool,
- "DBD: Failed to load driver apr_dbd_%s_driver",
+ "Failed to load driver apr_dbd_%s_driver",
cfg->name);
}
break;
case cmd_params:
cfg->params = val;
break;
+ }
+
+ return NULL;
+}
+
#if APR_HAS_THREADS
+static const char *dbd_param_int(cmd_parms *cmd, void *dconf, const char *val)
+{
+ svr_cfg *svr = ap_get_module_config(cmd->server->module_config,
+ &dbd_module);
+ dbd_cfg_t *cfg = svr->cfg;
+ const char *p;
+
+ for (p = val; *p; ++p) {
+ if (!apr_isdigit(*p)) {
+ return "Argument must be numeric!";
+ }
+ }
+
+ switch ((long) cmd->info) {
case cmd_min:
- ISINT(val);
cfg->nmin = atoi(val);
cfg->set |= NMIN_SET;
break;
case cmd_keep:
- ISINT(val);
cfg->nkeep = atoi(val);
cfg->set |= NKEEP_SET;
break;
case cmd_max:
- ISINT(val);
cfg->nmax = atoi(val);
cfg->set |= NMAX_SET;
break;
case cmd_exp:
- ISINT(val);
cfg->exptime = atoi(val);
cfg->set |= EXPTIME_SET;
break;
-#endif
}
return NULL;
}
+#endif
static const char *dbd_param_flag(cmd_parms *cmd, void *dconf, int flag)
{
@@ -239,6 +264,17 @@ static const char *dbd_prepare(cmd_parms *cmd, void *dconf, const char *query,
return NULL;
}
+static const char *dbd_init_sql(cmd_parms *cmd, void *dconf, const char *query)
+{
+ if (!query || *query == '\n') {
+ return "You should specify SQL statement";
+ }
+
+ ap_dbd_sql_init(cmd->server, query);
+
+ return NULL;
+}
+
static const command_rec dbd_cmds[] = {
AP_INIT_TAKE1("DBDriver", dbd_param, (void*)cmd_name, RSRC_CONF,
"SQL Driver"),
@@ -249,16 +285,18 @@ static const command_rec dbd_cmds[] = {
AP_INIT_TAKE12("DBDPrepareSQL", dbd_prepare, NULL, RSRC_CONF,
"SQL statement to prepare (or nothing, to override "
"statement inherited from main server) and label"),
+ AP_INIT_TAKE1("DBDInitSQL", dbd_init_sql, NULL, RSRC_CONF,
+ "SQL statement to be executed after connection is created"),
#if APR_HAS_THREADS
- AP_INIT_TAKE1("DBDMin", dbd_param, (void*)cmd_min, RSRC_CONF,
+ AP_INIT_TAKE1("DBDMin", dbd_param_int, (void*)cmd_min, RSRC_CONF,
"Minimum number of connections"),
/* XXX: note that mod_proxy calls this "smax" */
- AP_INIT_TAKE1("DBDKeep", dbd_param, (void*)cmd_keep, RSRC_CONF,
+ AP_INIT_TAKE1("DBDKeep", dbd_param_int, (void*)cmd_keep, RSRC_CONF,
"Maximum number of sustained connections"),
- AP_INIT_TAKE1("DBDMax", dbd_param, (void*)cmd_max, RSRC_CONF,
+ AP_INIT_TAKE1("DBDMax", dbd_param_int, (void*)cmd_max, RSRC_CONF,
"Maximum number of connections"),
/* XXX: note that mod_proxy calls this "ttl" (time to live) */
- AP_INIT_TAKE1("DBDExptime", dbd_param, (void*)cmd_exp, RSRC_CONF,
+ AP_INIT_TAKE1("DBDExptime", dbd_param_int, (void*)cmd_exp, RSRC_CONF,
"Keepalive time for idle connections"),
#endif
{NULL}
@@ -397,7 +435,6 @@ static apr_status_t dbd_prepared_init(apr_pool_t *pool, dbd_cfg_t *cfg,
ap_dbd_t *rec)
{
apr_hash_index_t *hi;
- apr_status_t rv = APR_SUCCESS;
rec->prepared = apr_hash_make(pool);
@@ -415,13 +452,34 @@ static apr_status_t dbd_prepared_init(apr_pool_t *pool, dbd_cfg_t *cfg,
stmt = NULL;
if (apr_dbd_prepare(rec->driver, pool, rec->handle, query,
label, &stmt)) {
- rv = APR_EGENERAL;
+ return APR_EGENERAL;
}
else {
apr_hash_set(rec->prepared, label, APR_HASH_KEY_STRING, stmt);
}
}
+ return APR_SUCCESS;
+}
+
+static apr_status_t dbd_init_sql_init(apr_pool_t *pool, dbd_cfg_t *cfg,
+ ap_dbd_t *rec)
+{
+ int i;
+ apr_status_t rv = APR_SUCCESS;
+
+ for (i = 0; i < cfg->init_queries->nelts; i++) {
+ int nrows;
+ char **query_p;
+
+ query_p = (char **)cfg->init_queries->elts + i;
+
+ if (apr_dbd_query(rec->driver, rec->handle, &nrows, *query_p)) {
+ rv = APR_EGENERAL;
+ break;
+ }
+ }
+
return rv;
}
@@ -459,11 +517,12 @@ static apr_status_t dbd_construct(void **data_ptr,
apr_pool_t *rec_pool, *prepared_pool;
ap_dbd_t *rec;
apr_status_t rv;
+ const char *err = "";
rv = apr_pool_create(&rec_pool, pool);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server,
- "DBD: Failed to create memory pool");
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server, APLOGNO(00624)
+ "Failed to create memory pool");
return rv;
}
@@ -478,40 +537,37 @@ static apr_status_t dbd_construct(void **data_ptr,
*/
rv = apr_dbd_get_driver(rec->pool, cfg->name, &rec->driver);
if (rv != APR_SUCCESS) {
- switch (rv) {
- case APR_ENOTIMPL:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: driver for %s not available", cfg->name);
- break;
- case APR_EDSOOPEN:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: can't find driver for %s", cfg->name);
- break;
- case APR_ESYMNOTFOUND:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: driver for %s is invalid or corrupted",
+ if (APR_STATUS_IS_ENOTIMPL(rv)) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00625)
+ "driver for %s not available", cfg->name);
+ }
+ else if (APR_STATUS_IS_EDSOOPEN(rv)) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00626)
+ "can't find driver for %s", cfg->name);
+ }
+ else if (APR_STATUS_IS_ESYMNOTFOUND(rv)) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00627)
+ "driver for %s is invalid or corrupted",
cfg->name);
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: mod_dbd not compatible with APR in get_driver");
- break;
}
-
+ else {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00628)
+ "mod_dbd not compatible with APR in get_driver");
+ }
apr_pool_destroy(rec->pool);
return rv;
}
- rv = apr_dbd_open(rec->driver, rec->pool, cfg->params, &rec->handle);
+ rv = apr_dbd_open_ex(rec->driver, rec->pool, cfg->params, &rec->handle, &err);
if (rv != APR_SUCCESS) {
switch (rv) {
case APR_EGENERAL:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: Can't connect to %s", cfg->name);
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00629)
+ "Can't connect to %s: %s", cfg->name, err);
break;
default:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: mod_dbd not compatible with APR in open");
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00630)
+ "mod_dbd not compatible with APR in open");
break;
}
@@ -527,8 +583,8 @@ static apr_status_t dbd_construct(void **data_ptr,
*/
rv = apr_pool_create(&prepared_pool, rec->pool);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server,
- "DBD: Failed to create memory pool");
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, cfg->server, APLOGNO(00631)
+ "Failed to create memory pool");
apr_pool_destroy(rec->pool);
return rv;
@@ -537,14 +593,16 @@ static apr_status_t dbd_construct(void **data_ptr,
rv = dbd_prepared_init(prepared_pool, cfg, rec);
if (rv != APR_SUCCESS) {
const char *errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server,
- "DBD: failed to prepare SQL statements: %s",
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, cfg->server, APLOGNO(00632)
+ "failed to prepare SQL statements: %s",
(errmsg ? errmsg : "[???]"));
apr_pool_destroy(rec->pool);
return rv;
}
+ dbd_run_post_connect(prepared_pool, cfg, rec);
+
*data_ptr = rec;
return APR_SUCCESS;
@@ -589,8 +647,8 @@ static apr_status_t dbd_setup(server_rec *s, dbd_group_t *group)
dbd_construct, dbd_destruct, group,
group->pool);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
- "DBD: failed to initialise");
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00633)
+ "failed to initialise");
return rv;
}
@@ -611,8 +669,8 @@ static apr_status_t dbd_setup_init(apr_pool_t *pool, server_rec *s)
rv2 = apr_pool_create(&group->pool, pool);
if (rv2 != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s,
- "DBD: Failed to create reslist cleanup memory pool");
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s, APLOGNO(00634)
+ "Failed to create reslist cleanup memory pool");
return rv2;
}
@@ -631,8 +689,8 @@ static apr_status_t dbd_setup_init(apr_pool_t *pool, server_rec *s)
rv2 = apr_thread_mutex_create(&group->mutex,
APR_THREAD_MUTEX_DEFAULT, pool);
if (rv2 != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s,
- "DBD: Failed to create thread mutex");
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv2, s, APLOGNO(00635)
+ "Failed to create thread mutex");
return rv2;
}
#endif
@@ -645,8 +703,8 @@ static void dbd_child_init(apr_pool_t *p, server_rec *s)
{
apr_status_t rv = dbd_setup_init(p, s);
if (rv) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
- "DBD: child init failed!");
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(00636)
+ "child init failed!");
}
}
@@ -665,8 +723,8 @@ static apr_status_t dbd_setup_lock(server_rec *s, dbd_group_t *group)
rv2 = apr_thread_mutex_lock(group->mutex);
if (rv2 != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s,
- "DBD: Failed to acquire thread mutex");
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s, APLOGNO(00637)
+ "Failed to acquire thread mutex");
return rv2;
}
@@ -676,8 +734,8 @@ static apr_status_t dbd_setup_lock(server_rec *s, dbd_group_t *group)
rv2 = apr_thread_mutex_unlock(group->mutex);
if (rv2 != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s,
- "DBD: Failed to release thread mutex");
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s, APLOGNO(00638)
+ "Failed to release thread mutex");
if (rv == APR_SUCCESS) {
rv = rv2;
}
@@ -715,13 +773,16 @@ static apr_status_t dbd_check(apr_pool_t *pool, server_rec *s, ap_dbd_t *rec)
return APR_SUCCESS;
}
- errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
+ /* we don't have a driver-specific error code, so we'll just pass
+ * a "success" value and rely on the driver to ignore it
+ */
+ errmsg = apr_dbd_error(rec->driver, rec->handle, 0);
if (!errmsg) {
errmsg = "(unknown)";
}
svr = ap_get_module_config(s->module_config, &dbd_module);
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00639)
"DBD [%s] Error: %s", svr->cfg->name, errmsg);
return rv;
}
@@ -738,7 +799,7 @@ DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t *pool, server_rec *s)
/* If nothing is configured, we shouldn't be here */
if (cfg->name == no_dbdriver) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "DBD: not configured");
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "not configured");
return NULL;
}
@@ -912,10 +973,13 @@ static void dbd_hooks(apr_pool_t *pool)
APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
APR_REGISTER_OPTIONAL_FN(ap_dbd_cacquire);
+ APR_OPTIONAL_HOOK(dbd, post_connect, dbd_init_sql_init,
+ NULL, NULL, APR_HOOK_MIDDLE);
+
apr_dbd_init(pool);
}
-module AP_MODULE_DECLARE_DATA dbd_module = {
+AP_DECLARE_MODULE(dbd) = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
diff --git a/modules/database/mod_dbd.dep b/modules/database/mod_dbd.dep
deleted file mode 100644
index 4869e6d9..00000000
--- a/modules/database/mod_dbd.dep
+++ /dev/null
@@ -1,32 +0,0 @@
-# Microsoft Developer Studio Generated Dependency File, included by mod_dbd.mak
-
-..\..\build\win32\httpd.rc : \
- "..\..\include\ap_release.h"\
-
-
-.\mod_dbd.c : \
- "..\..\include\ap_config.h"\
- "..\..\include\ap_mmn.h"\
- "..\..\include\ap_regex.h"\
- "..\..\include\ap_release.h"\
- "..\..\include\http_config.h"\
- "..\..\include\http_log.h"\
- "..\..\include\http_protocol.h"\
- "..\..\include\http_request.h"\
- "..\..\include\httpd.h"\
- "..\..\include\os.h"\
- "..\..\include\util_cfgtree.h"\
- "..\..\include\util_filter.h"\
- "..\..\srclib\apr-util\include\apr_dbd.h"\
- "..\..\srclib\apr-util\include\apr_hooks.h"\
- "..\..\srclib\apr-util\include\apr_optional.h"\
- "..\..\srclib\apr-util\include\apr_optional_hooks.h"\
- "..\..\srclib\apr-util\include\apr_uri.h"\
- "..\..\srclib\apr\include\apr_hash.h"\
- "..\..\srclib\apr\include\apr_lib.h"\
- "..\..\srclib\apr\include\apr_mmap.h"\
- "..\..\srclib\apr\include\apr_poll.h"\
- "..\..\srclib\apr\include\apr_portable.h"\
- "..\..\srclib\apr\include\apr_strings.h"\
- ".\mod_dbd.h"\
-
diff --git a/modules/database/mod_dbd.h b/modules/database/mod_dbd.h
index 1fad46ff..e4d21536 100644
--- a/modules/database/mod_dbd.h
+++ b/modules/database/mod_dbd.h
@@ -22,7 +22,7 @@
* http://www.apache.org/~niq/dbd.html
* or
* http://apache.webthing.com/database/
- *
+ *
* @defgroup MOD_DBD mod_dbd
* @ingroup APACHE_MODS
* @{
@@ -31,7 +31,7 @@
#ifndef DBD_H
#define DBD_H
-/* Create a set of DBD_DECLARE(type), DBD_DECLARE_NONSTD(type) and
+/* Create a set of DBD_DECLARE(type), DBD_DECLARE_NONSTD(type) and
* DBD_DECLARE_DATA with appropriate export and import tags for the platform
*/
#if !defined(WIN32)
@@ -55,6 +55,23 @@
#include <httpd.h>
#include <apr_optional.h>
#include <apr_hash.h>
+#include <apr_hooks.h>
+
+typedef struct {
+ server_rec *server;
+ const char *name;
+ const char *params;
+ int persist;
+#if APR_HAS_THREADS
+ int nmin;
+ int nkeep;
+ int nmax;
+ int exptime;
+ int set;
+#endif
+ apr_hash_t *queries;
+ apr_array_header_t *init_queries;
+} dbd_cfg_t;
typedef struct {
apr_dbd_t *handle;
@@ -98,6 +115,9 @@ APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*));
APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*));
APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*));
+APR_DECLARE_EXTERNAL_HOOK(dbd, DBD, apr_status_t, post_connect,
+ (apr_pool_t *, dbd_cfg_t *, ap_dbd_t *))
+
#endif
/** @} */
diff --git a/modules/database/mod_dbd.mak b/modules/database/mod_dbd.mak
deleted file mode 100644
index 6d96ff2e..00000000
--- a/modules/database/mod_dbd.mak
+++ /dev/null
@@ -1,353 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Based on mod_dbd.dsp
-!IF "$(CFG)" == ""
-CFG=mod_dbd - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to mod_dbd - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "mod_dbd - Win32 Release" && "$(CFG)" != "mod_dbd - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mod_dbd.mak" CFG="mod_dbd - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mod_dbd - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mod_dbd - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release"
-
-OUTDIR=.\Release
-INTDIR=.\Release
-DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
-# Begin Custom Macros
-OutDir=.\Release
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\mod_dbd.so" "$(DS_POSTBUILD_DEP)"
-
-!ELSE
-
-ALL : "libhttpd - Win32 Release" "libaprutil - Win32 Release" "libapr - Win32 Release" "$(OUTDIR)\mod_dbd.so" "$(DS_POSTBUILD_DEP)"
-
-!ENDIF
-
-!IF "$(RECURSE)" == "1"
-CLEAN :"libapr - Win32 ReleaseCLEAN" "libaprutil - Win32 ReleaseCLEAN" "libhttpd - Win32 ReleaseCLEAN"
-!ELSE
-CLEAN :
-!ENDIF
- -@erase "$(INTDIR)\mod_dbd.obj"
- -@erase "$(INTDIR)\mod_dbd.res"
- -@erase "$(INTDIR)\mod_dbd_src.idb"
- -@erase "$(INTDIR)\mod_dbd_src.pdb"
- -@erase "$(OUTDIR)\mod_dbd.exp"
- -@erase "$(OUTDIR)\mod_dbd.lib"
- -@erase "$(OUTDIR)\mod_dbd.pdb"
- -@erase "$(OUTDIR)\mod_dbd.so"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "DBD_DECLARE_EXPORT" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_dbd_src" /FD /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
-RSC=rc.exe
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_dbd.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_dbd.so" /d LONG_NAME="dbd_module for Apache"
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_dbd.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_dbd.pdb" /debug /out:"$(OUTDIR)\mod_dbd.so" /implib:"$(OUTDIR)\mod_dbd.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_dbd.so /opt:ref
-LINK32_OBJS= \
- "$(INTDIR)\mod_dbd.obj" \
- "$(INTDIR)\mod_dbd.res" \
- "..\..\srclib\apr\Release\libapr-1.lib" \
- "..\..\srclib\apr-util\Release\libaprutil-1.lib" \
- "..\..\Release\libhttpd.lib"
-
-"$(OUTDIR)\mod_dbd.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-TargetPath=.\Release\mod_dbd.so
-SOURCE="$(InputPath)"
-PostBuild_Desc=Embed .manifest
-DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
-
-# Begin Custom Macros
-OutDir=.\Release
-# End Custom Macros
-
-"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_dbd.so"
- if exist .\Release\mod_dbd.so.manifest mt.exe -manifest .\Release\mod_dbd.so.manifest -outputresource:.\Release\mod_dbd.so;2
- echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
-
-!ELSEIF "$(CFG)" == "mod_dbd - Win32 Debug"
-
-OUTDIR=.\Debug
-INTDIR=.\Debug
-DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
-# Begin Custom Macros
-OutDir=.\Debug
-# End Custom Macros
-
-!IF "$(RECURSE)" == "0"
-
-ALL : "$(OUTDIR)\mod_dbd.so" "$(DS_POSTBUILD_DEP)"
-
-!ELSE
-
-ALL : "libhttpd - Win32 Debug" "libaprutil - Win32 Debug" "libapr - Win32 Debug" "$(OUTDIR)\mod_dbd.so" "$(DS_POSTBUILD_DEP)"
-
-!ENDIF
-
-!IF "$(RECURSE)" == "1"
-CLEAN :"libapr - Win32 DebugCLEAN" "libaprutil - Win32 DebugCLEAN" "libhttpd - Win32 DebugCLEAN"
-!ELSE
-CLEAN :
-!ENDIF
- -@erase "$(INTDIR)\mod_dbd.obj"
- -@erase "$(INTDIR)\mod_dbd.res"
- -@erase "$(INTDIR)\mod_dbd_src.idb"
- -@erase "$(INTDIR)\mod_dbd_src.pdb"
- -@erase "$(OUTDIR)\mod_dbd.exp"
- -@erase "$(OUTDIR)\mod_dbd.lib"
- -@erase "$(OUTDIR)\mod_dbd.pdb"
- -@erase "$(OUTDIR)\mod_dbd.so"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP=cl.exe
-CPP_PROJ=/nologo /MDd /W3 /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "DBD_DECLARE_EXPORT" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_dbd_src" /FD /EHsc /c
-
-.c{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.c{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cxx{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-MTL=midl.exe
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
-RSC=rc.exe
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mod_dbd.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_dbd.so" /d LONG_NAME="dbd_module for Apache"
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_dbd.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-LINK32_FLAGS=kernel32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_dbd.pdb" /debug /out:"$(OUTDIR)\mod_dbd.so" /implib:"$(OUTDIR)\mod_dbd.lib" /base:@..\..\os\win32\BaseAddr.ref,mod_dbd.so
-LINK32_OBJS= \
- "$(INTDIR)\mod_dbd.obj" \
- "$(INTDIR)\mod_dbd.res" \
- "..\..\srclib\apr\Debug\libapr-1.lib" \
- "..\..\srclib\apr-util\Debug\libaprutil-1.lib" \
- "..\..\Debug\libhttpd.lib"
-
-"$(OUTDIR)\mod_dbd.so" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-TargetPath=.\Debug\mod_dbd.so
-SOURCE="$(InputPath)"
-PostBuild_Desc=Embed .manifest
-DS_POSTBUILD_DEP=$(INTDIR)\postbld.dep
-
-# Begin Custom Macros
-OutDir=.\Debug
-# End Custom Macros
-
-"$(DS_POSTBUILD_DEP)" : "$(OUTDIR)\mod_dbd.so"
- if exist .\Debug\mod_dbd.so.manifest mt.exe -manifest .\Debug\mod_dbd.so.manifest -outputresource:.\Debug\mod_dbd.so;2
- echo Helper for Post-build step > "$(DS_POSTBUILD_DEP)"
-
-!ENDIF
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("mod_dbd.dep")
-!INCLUDE "mod_dbd.dep"
-!ELSE
-!MESSAGE Warning: cannot find "mod_dbd.dep"
-!ENDIF
-!ENDIF
-
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release" || "$(CFG)" == "mod_dbd - Win32 Debug"
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release"
-
-"libapr - Win32 Release" :
- cd ".\..\..\srclib\apr"
- $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release"
- cd "..\..\modules\database"
-
-"libapr - Win32 ReleaseCLEAN" :
- cd ".\..\..\srclib\apr"
- $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Release" RECURSE=1 CLEAN
- cd "..\..\modules\database"
-
-!ELSEIF "$(CFG)" == "mod_dbd - Win32 Debug"
-
-"libapr - Win32 Debug" :
- cd ".\..\..\srclib\apr"
- $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug"
- cd "..\..\modules\database"
-
-"libapr - Win32 DebugCLEAN" :
- cd ".\..\..\srclib\apr"
- $(MAKE) /$(MAKEFLAGS) /F ".\libapr.mak" CFG="libapr - Win32 Debug" RECURSE=1 CLEAN
- cd "..\..\modules\database"
-
-!ENDIF
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release"
-
-"libaprutil - Win32 Release" :
- cd ".\..\..\srclib\apr-util"
- $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release"
- cd "..\..\modules\database"
-
-"libaprutil - Win32 ReleaseCLEAN" :
- cd ".\..\..\srclib\apr-util"
- $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Release" RECURSE=1 CLEAN
- cd "..\..\modules\database"
-
-!ELSEIF "$(CFG)" == "mod_dbd - Win32 Debug"
-
-"libaprutil - Win32 Debug" :
- cd ".\..\..\srclib\apr-util"
- $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug"
- cd "..\..\modules\database"
-
-"libaprutil - Win32 DebugCLEAN" :
- cd ".\..\..\srclib\apr-util"
- $(MAKE) /$(MAKEFLAGS) /F ".\libaprutil.mak" CFG="libaprutil - Win32 Debug" RECURSE=1 CLEAN
- cd "..\..\modules\database"
-
-!ENDIF
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release"
-
-"libhttpd - Win32 Release" :
- cd ".\..\.."
- $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release"
- cd ".\modules\database"
-
-"libhttpd - Win32 ReleaseCLEAN" :
- cd ".\..\.."
- $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Release" RECURSE=1 CLEAN
- cd ".\modules\database"
-
-!ELSEIF "$(CFG)" == "mod_dbd - Win32 Debug"
-
-"libhttpd - Win32 Debug" :
- cd ".\..\.."
- $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug"
- cd ".\modules\database"
-
-"libhttpd - Win32 DebugCLEAN" :
- cd ".\..\.."
- $(MAKE) /$(MAKEFLAGS) /F ".\libhttpd.mak" CFG="libhttpd - Win32 Debug" RECURSE=1 CLEAN
- cd ".\modules\database"
-
-!ENDIF
-
-SOURCE=..\..\build\win32\httpd.rc
-
-!IF "$(CFG)" == "mod_dbd - Win32 Release"
-
-
-"$(INTDIR)\mod_dbd.res" : $(SOURCE) "$(INTDIR)"
- $(RSC) /l 0x409 /fo"$(INTDIR)\mod_dbd.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "NDEBUG" /d BIN_NAME="mod_dbd.so" /d LONG_NAME="dbd_module for Apache" $(SOURCE)
-
-
-!ELSEIF "$(CFG)" == "mod_dbd - Win32 Debug"
-
-
-"$(INTDIR)\mod_dbd.res" : $(SOURCE) "$(INTDIR)"
- $(RSC) /l 0x409 /fo"$(INTDIR)\mod_dbd.res" /i "../../include" /i "../../srclib/apr/include" /i ".\..\..\build\win32" /d "_DEBUG" /d BIN_NAME="mod_dbd.so" /d LONG_NAME="dbd_module for Apache" $(SOURCE)
-
-
-!ENDIF
-
-SOURCE=.\mod_dbd.c
-
-"$(INTDIR)\mod_dbd.obj" : $(SOURCE) "$(INTDIR)"
-
-
-
-!ENDIF
-