Changes with Apache 2.3.11
+ *) modules: Fix many modules that were not correctly initializing if they
+ were not active during server startup but got enabled later during a
+ graceful restart. [Stefan Fritsch]
+
*) core: Create new ap_state_query function that allows modules to determine
if the current configuration run is the initial one at server startup,
and if the server is started for testing/config dumping only.
static int initialize_module(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- void *data;
- const char *userdata_key = "auth_digest_init";
-
/* initialize_module() will be called twice, and if it's a DSO
* then all static data from the first call will be lost. Only
* set up our static data on the second call. */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return OK;
- }
+
if (initialize_secret(s) != APR_SUCCESS) {
return !OK;
}
apr_pool_t *ptemp, server_rec *s)
{
apr_status_t rv;
- const char *userdata_key = "mod_heartmonitor_init";
- void *data;
hm_ctx_t *ctx = ap_get_module_config(s->module_config,
&heartmonitor_module);
APR_OPTIONAL_FN_TYPE(ap_watchdog_get_instance) *hm_watchdog_get_instance;
}
/* Create the slotmem */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- /* first call do nothing */
- apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null, s->process->pool);
- } else {
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_CONFIG) {
+ /* this is the real thing */
if (maxworkers) {
storage = ap_lookup_provider(AP_SLOTMEM_PROVIDER_GROUP, "shared", "0");
if (!storage) {
#include "mod_watchdog.h"
#include "ap_provider.h"
#include "ap_mpm.h"
+#include "http_core.h"
#include "util_mutex.h"
#define AP_WATCHODG_PGROUP "watchdog"
if (!(wd_server_conf = apr_pcalloc(pproc, sizeof(wd_server_conf_t))))
return APR_ENOMEM;
apr_pool_create(&wd_server_conf->pool, pproc);
- wd_server_conf->s = s;
- apr_pool_userdata_set(wd_server_conf, pk, apr_pool_cleanup_null, pproc);
+ }
+
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
/* First time config phase -- skip. */
return OK;
- }
+
#if defined(WIN32)
{
const char *ppid = getenv("AP_PARENT_PID");
#include "httpd.h"
#include "http_config.h"
+#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "util_mutex.h"
static int exipc_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- void *data; /* These two help ensure that we only init once. */
- const char *userdata_key;
apr_status_t rs;
exipc_data *base;
const char *tempdir;
/*
- * The following checks if this routine has been called before.
- * This is necessary because the parent process gets initialized
- * a couple of times as the server starts up, and we don't want
- * to create any more mutexes and shared memory segments than
- * we're actually going to use.
- *
- * The key needs to be unique for the entire web server, so put
- * the module name in it.
+ * Do nothing if we are not creating the final configuration.
+ * The parent process gets initialized a couple of times as the
+ * server starts up, and we don't want to create any more mutexes
+ * and shared memory segments than we're actually going to use.
*/
- userdata_key = "example_ipc_init_module";
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- /*
- * If no data was found for our key, this must be the first
- * time the module is initialized. Put some data under that
- * key and return.
- */
- apr_pool_userdata_set((const void *) 1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return OK;
- } /* Kilroy was here */
/*
* The shared memory allocation routines take a file name.
server_rec *main_server)
{
apr_proc_t *procnew = NULL;
- int first_time = 0;
const char *userdata_key = "cgid_init";
module **m;
int ret = OK;
apr_pool_userdata_get(&data, userdata_key, main_server->process->pool);
if (!data) {
- first_time = 1;
procnew = apr_pcalloc(main_server->process->pool, sizeof(*procnew));
procnew->pid = -1;
procnew->err = procnew->in = procnew->out = NULL;
procnew = data;
}
- if (!first_time) {
+ if (ap_state_query(AP_SQ_MAIN_STATE) != AP_SQ_MS_CREATE_PRE_CONFIG) {
char *tmp_sockname;
total_modules = 0;
for (m = ap_preloaded_modules; *m != NULL; m++)
ap_get_module_config(s->module_config,
&ldap_module);
- void *data;
- const char *userdata_key = "util_ldap_init";
apr_ldap_err_t *result_err = NULL;
int rc;
/* util_ldap_post_config() will be called twice. Don't bother
* going through all of the initialization on the first call
* because it will just be thrown away.*/
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
#if APR_HAS_SHARED_MEMORY
/* If the cache file already exists then delete it. Otherwise we are
server_rec *s)
{
apr_status_t rv;
- void *data;
- int first_time = 0;
- const char *userdata_key = "rewrite_init_module";
-
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- first_time = 1;
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
- }
/* check if proxy module is available */
proxy_available = (ap_find_linked_module("mod_proxy.c") != NULL);
apr_pool_cleanup_register(p, (void *)s, rewritelock_remove,
apr_pool_cleanup_null);
- /* step through the servers and
- * - open each rewriting logfile
- * - open the RewriteMap prg:xxx programs
+ /* if we are not doing the initial config, step through the servers and
+ * open the RewriteMap prg:xxx programs,
*/
- for (; s; s = s->next) {
- if (!first_time) {
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_CONFIG) {
+ for (; s; s = s->next) {
if (run_rewritemap_programs(s, p) != APR_SUCCESS) {
return HTTP_INTERNAL_SERVER_ERROR;
}
static int lb_hb_init(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- const char *userdata_key = "mod_lbmethod_heartbeat_init";
- void *data;
apr_size_t size;
unsigned int num;
lb_hb_ctx_t *ctx = ap_get_module_config(s->module_config,
&lbmethod_heartbeat_module);
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- /* first call do nothing */
- apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null, s->process->pool);
+ /* do nothing on first call */
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return OK;
- }
+
storage = ap_lookup_provider(AP_SLOTMEM_PROVIDER_GROUP, "shared", "0");
if (!storage) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, s, "ap_lookup_provider %s failed", AP_SLOTMEM_PROVIDER_GROUP);
apr_pool_t *ptemp, server_rec *s)
{
apr_status_t rv;
- void *data;
void *sconf = s->module_config;
proxy_server_conf *conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- const char *userdata_key = "mod_proxy_balancer_init";
ap_slotmem_instance_t *new = NULL;
apr_time_t tstamp;
- /* balancer_post_config() will be called twice during startup. So, only
+ /* balancer_post_config() will be called twice during startup. So, don't
* set up the static data the 1st time through. */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return OK;
- }
/*
* Get slotmem setups
#include "apr_lib.h"
#include "apr_strings.h"
#include "http_log.h"
+#include "http_core.h"
#if APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION < 4
#define LOG_PREFIX "mod_session_crypto: "
#define DRIVER_KEY "session_crypto_driver"
-#define INIT_KEY "session_crypto_init"
module AP_MODULE_DECLARE_DATA session_crypto_module;
AP_DECLARE(int) ap_session_crypto_init(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
- void *data;
const apr_crypto_driver_t *driver = NULL;
session_crypto_conf *conf = ap_get_module_config(s->module_config,
/* session_crypto_init() will be called twice. Don't bother
* going through all of the initialization on the first call
* because it will just be thrown away.*/
- apr_pool_userdata_get(&data, INIT_KEY, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, INIT_KEY,
- apr_pool_cleanup_null, s->process->pool);
+ if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return OK;
- }
if (conf->library) {
static int post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
server_rec *s)
{
- void *data;
- const char *userdata_key = "slotmem_shm_post_config";
-
slotmem_shm_initialize_cleanup(p);
-
- /* keep this around for possible future usage */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
- /* Do Stuff */
- return OK;
- }
-
return OK;
}
{
SSLModConfigRec *mc = myModConfig(s);
apr_status_t rv;
- void *data;
- const char *userdata_key = "ssl_scache_init";
struct ap_socache_hints hints;
/* The very first invocation of this function will be the
* this first (and only the first) time through, since the pool
* will be immediately cleared anyway. For every subsequent
* invocation, initialize the configured cache. */
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
+ if (!ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG)
return;
- }
#ifdef HAVE_OCSP_STAPLING
if (mc->stapling_cache) {