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
* 3. On Unix, if the -X commandline option is given (the 'DEBUG' config is set),
0
* detach() will not be 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. This doesn't work with Apache 2.0.x though: ppid()
0
- * doesn't return 1. So Apache 2.0.x users will just have to live with the double
0
- * initialization overhead.
0
+ * Because of property #2, the post_config hook is called twice. We initially tried
0
+ * to avoid this with all kinds of hacks and workarounds, but none of them are
0
+ * universal, i.e. it works for some people but not for others. So we got rid of the
0
+ * hacks, and now we always initialize in the post_config hook.
0
- bool passengerShouldBeInitialized;
0
- #if (AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER >= 2) || AP_SERVER_MAJORVERSION_NUMBER > 2
0
- passengerShouldBeInitialized = getppid() == 1 || ap_exists_config_define("DEBUG");
0
- passengerShouldBeInitialized = true;
0
- if (passengerShouldBeInitialized) {
0
- hooks = new Hooks(pconf, plog, ptemp, s);
0
- apr_pool_cleanup_register(pconf, NULL,
0
- apr_pool_cleanup_null);
0
- } catch (const thread_resource_error &e) {
0
- string pthread_threads_max;
0
- getrlimit(RLIMIT_NPROC, &lim);
0
- #ifdef PTHREAD_THREADS_MAX
0
- pthread_threads_max = toString(PTHREAD_THREADS_MAX);
0
- pthread_threads_max = "unknown";
0
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
- "*** Passenger could not be initialize because a "
0
- "threading resource could not be allocated or initialized. "
0
- "The error message is:");
0
- " RLIMIT_NPROC: soft = %d, hard = %d\n"
0
- " PTHREAD_THREADS_MAX: %s\n"
0
- (int) lim.rlim_cur, (int) lim.rlim_max,
0
- pthread_threads_max.c_str());
0
- fprintf(stderr, "Output of 'uname -a' follows:\n");
0
- system("uname -a >&2");
0
- fprintf(stderr, "\nOutput of 'ulimit -a' follows:\n");
0
- system("ulimit -a >&2");
0
- } catch (const exception &e) {
0
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
- "*** Passenger could not be initialized because of this error: %s",
0
+ hooks = new Hooks(pconf, plog, ptemp, s);
0
+ apr_pool_cleanup_register(pconf, NULL,
0
+ apr_pool_cleanup_null);
0
+ } catch (const thread_resource_error &e) {
0
+ string pthread_threads_max;
0
+ getrlimit(RLIMIT_NPROC, &lim);
0
+ #ifdef PTHREAD_THREADS_MAX
0
+ pthread_threads_max = toString(PTHREAD_THREADS_MAX);
0
+ pthread_threads_max = "unknown";
0
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
+ "*** Passenger could not be initialize because a "
0
+ "threading resource could not be allocated or initialized. "
0
+ "The error message is:");
0
+ " RLIMIT_NPROC: soft = %d, hard = %d\n"
0
+ " PTHREAD_THREADS_MAX: %s\n"
0
+ (int) lim.rlim_cur, (int) lim.rlim_max,
0
+ pthread_threads_max.c_str());
0
+ fprintf(stderr, "Output of 'uname -a' follows:\n");
0
+ system("uname -a >&2");
0
+ fprintf(stderr, "\nOutput of 'ulimit -a' follows:\n");
0
+ system("ulimit -a >&2");
0
+ } catch (const exception &e) {
0
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
0
+ "*** Passenger could not be initialized because of this error: %s",
Comments
No one has commented yet.