0
init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) {
0
+ * The Apache initialization process has the following properties:
0
* 1. Apache on Unix calls the post_config hook twice, once before detach() and once
0
* after. On Windows it never calls detach().
0
* 2. When Apache is compiled to use DSO modules, the modules are unloaded between the
0
* two post_config hook calls.
0
- * 3. On Unix, if the -X commandline option is given, detach() will not be called.
0
+ * 3. On Unix, if the -X commandline option is given (the 'DEBUG' config is set),
0
+ * detach() will not be called.
0
- * Because of these 3 issues (and especially #2), we only want to intialize the second
0
- * time the post_config hook is called.
0
+ * The Passenger initialization process is pretty expensive because a spawn server has
0
+ * to be started, so we'll want to avoid initializing twice because of property #2.
0
+ * The most straightforward solution is to initialize Passenger the second time
0
+ * post_config is called. But unfortunately, that doesn't work if the Passenger
0
+ * module is loaded after a graceful restart. There also doesn't seem to be any
0
+ * good hooks that we can use to avoid double initialization.
0
+ * So as a hack, we check whether Apache has already been daemonized, by checking
0
+ * whether ppid() returns 1.
0
- void *firstInitCall = NULL;
0
- apr_pool_t *processPool = s->process->pool;
0
- apr_pool_userdata_get(&firstInitCall, "mod_passenger", processPool);
0
- if (firstInitCall == NULL) {
0
- apr_pool_userdata_set((const void *) 1, "mod_passenger",
0
- apr_pool_cleanup_null, processPool);
0
+ if (getppid() == 1 || ap_exists_config_define("DEBUG")) {
0
hooks = new Hooks(pconf, plog, ptemp, s);
0
apr_pool_cleanup_register(pconf, NULL,
Comments
No one has commented yet.