The problem is that the current 2.2.x code calls dbd_setup() only for
global server, therefore causing all other VHs to have things
uninitialised. If DBDPersist is On and dbd_setup_lock() is attempted,
mutex doesn't exist (it was never set up), so this fails. This patch
should fix all that (or so I hope :-).
Obviously, against 2.2.x branch.
--
Bojan
Index: modules/database/mod_dbd.c
===================================================================
--- modules/database/mod_dbd.c (revision 536730)
+++ modules/database/mod_dbd.c (working copy)
@@ -358,35 +358,42 @@
}
static apr_status_t dbd_setup_init(apr_pool_t *pool, server_rec *s)
{
- svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
- apr_status_t rv;
+ server_rec *sp;
+ svr_cfg *svr;
+ apr_status_t rv = APR_SUCCESS;
- /* dbd_setup in 2.2.3 and under was causing spurious error messages
- * when dbd isn't configured. We can stop that with a quick check here
- * together with a similar check in ap_dbd_open (where being
- * unconfigured is a genuine error that must be reported).
- */
- if (svr->name == no_dbdriver) {
- return APR_SUCCESS;
- }
+ for (sp = s; sp; sp = sp->next) {
+ svr = ap_get_module_config(sp->module_config, &dbd_module);
- if (!svr->persist) {
- return APR_SUCCESS;
- }
+ /* dbd_setup in 2.2.3 and under was causing spurious error messages
+ * when dbd isn't configured. We can stop that with a quick check
+ * here together with a similar check in ap_dbd_open (where being
+ * unconfigured is a genuine error that must be reported).
+ */
+ if (svr->name == no_dbdriver) {
+ continue;
+ }
- rv = dbd_setup(pool, svr);
- if (rv == APR_SUCCESS) {
- return rv;
+ if (!svr->persist) {
+ continue;
+ }
+
+ rv = dbd_setup(pool, svr);
+ if (rv == APR_SUCCESS) {
+ continue;
+ }
+
+ /* we failed, so create a mutex so that subsequent competing callers
+ * to ap_dbd_open can serialize themselves while they retry
+ */
+ rv = apr_thread_mutex_create(&svr->mutex,
+ APR_THREAD_MUTEX_DEFAULT, pool);
+ if (rv != APR_SUCCESS) {
+ ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
+ "DBD: Failed to create thread mutex");
+ }
}
- /* we failed, so create a mutex so that subsequent competing callers
- * to ap_dbd_open can serialize themselves while they retry
- */
- rv = apr_thread_mutex_create(&svr->mutex, APR_THREAD_MUTEX_DEFAULT, pool);
- if (rv != APR_SUCCESS) {
- ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
- "DBD: Failed to create thread mutex");
- }
return rv;
}
static apr_status_t dbd_setup_lock(apr_pool_t *pool, server_rec *s)