Skip to content

Commit

Permalink
Resolve issue hyperic#6 - retain vhost global lock between graceful r…
Browse files Browse the repository at this point in the history
…estarts,

because the vhost tracking store is retained across generations.
  • Loading branch information
wrowe committed May 10, 2018
1 parent 549ed6b commit e1c60e0
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions modules/bmx/mod_bmx_vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,33 +986,40 @@ static int bmx_vhost_post_config(apr_pool_t *pconf, apr_pool_t *plog,
}
#endif

/* create a mutex to protect the DBM */
rv = apr_global_mutex_create(&dbmlock, dbmlock_fname, APR_LOCK_DEFAULT,
s->process->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "Failed to create "
"mod_bmx_vhost global mutex for DBM in file '%s'",
dbmlock_fname);
rv = HTTP_INTERNAL_SERVER_ERROR;
goto out;
}
/* Check if this is configtest or a preflight phase, clear nothing,
* but create a process-lifespan mutex to protect the DBM. This must
* survive graceful restarts (s->process->pool) because two generations
* may be manipulating the same DBM at once, so the dbmlock directives
* are only recognized at initial startup.
* TODO: XXX: Implement httpd 2.4 Mutex schema for global defaults.
*/
apr_pool_userdata_get((void**)&dbmlock, preflight_key, s->process->pool);
if (!dbmlock)
{
/* create a mutex to protect the DBM */
rv = apr_global_mutex_create(&dbmlock, dbmlock_fname, APR_LOCK_DEFAULT,
s->process->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, "Failed to create "
"mod_bmx_vhost global mutex for DBM in file '%s'",
dbmlock_fname);
rv = HTTP_INTERNAL_SERVER_ERROR;
goto out;
}

#ifdef AP_NEED_SET_MUTEX_PERMS
rv = unixd_set_global_mutex_perms(dbmlock);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
"mod_bmx_vhost could not set permissions on global mutex"
" for DBM in file '%s'; check User and Group directives",
dbmlock_fname);
rv = HTTP_INTERNAL_SERVER_ERROR;
goto out;
}
rv = unixd_set_global_mutex_perms(dbmlock);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
"mod_bmx_vhost could not set permissions on global"
" mutex for DBM in file '%s'; check User and Group"
" directives", dbmlock_fname);
rv = HTTP_INTERNAL_SERVER_ERROR;
goto out;
}
#endif

/* Check if this is configtest or a preflight phase, clear nothing! */
apr_pool_userdata_get(&preflight, preflight_key, s->process->pool);
if (!preflight) {
apr_pool_userdata_set(preflight_key, preflight_key,
apr_pool_userdata_set(dbmlock, preflight_key,
apr_pool_cleanup_null, s->process->pool);
rv = OK;
goto out;
Expand Down

0 comments on commit e1c60e0

Please sign in to comment.