MCPcopy Create free account
hub / github.com/apache/httpd / worker_pre_config

Function worker_pre_config

server/mpm/worker/worker.c:2055–2118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2053}
2054
2055static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
2056 apr_pool_t *ptemp)
2057{
2058 int no_detach, debug, foreground;
2059 apr_status_t rv;
2060 const char *userdata_key = "mpm_worker_module";
2061
2062 debug = ap_exists_config_define("DEBUG");
2063
2064 if (debug) {
2065 foreground = one_process = 1;
2066 no_detach = 0;
2067 }
2068 else {
2069 one_process = ap_exists_config_define("ONE_PROCESS");
2070 no_detach = ap_exists_config_define("NO_DETACH");
2071 foreground = ap_exists_config_define("FOREGROUND");
2072 }
2073
2074 ap_mutex_register(pconf, AP_ACCEPT_MUTEX_TYPE, NULL, APR_LOCK_DEFAULT, 0);
2075
2076 retained = ap_retained_data_get(userdata_key);
2077 if (!retained) {
2078 retained = ap_retained_data_create(userdata_key, sizeof(*retained));
2079 retained->mpm = ap_unixd_mpm_get_retained_data();
2080 }
2081 retained->mpm->mpm_state = AP_MPMQ_STARTING;
2082 if (retained->mpm->baton != retained) {
2083 retained->mpm->was_graceful = 0;
2084 retained->mpm->baton = retained;
2085 }
2086 ++retained->mpm->module_loads;
2087
2088 /* sigh, want this only the second time around */
2089 if (retained->mpm->module_loads == 2) {
2090 if (!one_process && !foreground) {
2091 /* before we detach, setup crash handlers to log to errorlog */
2092 ap_fatal_signal_setup(ap_server_conf, pconf);
2093 rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
2094 : APR_PROC_DETACH_DAEMONIZE);
2095 if (rv != APR_SUCCESS) {
2096 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, APLOGNO(00299)
2097 "apr_proc_detach failed");
2098 return HTTP_INTERNAL_SERVER_ERROR;
2099 }
2100 }
2101 }
2102
2103 parent_pid = ap_my_pid = getpid();
2104
2105 ap_listen_pre_config();
2106 ap_daemons_to_start = DEFAULT_START_DAEMON;
2107 min_spare_threads = DEFAULT_MIN_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
2108 max_spare_threads = DEFAULT_MAX_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
2109 server_limit = DEFAULT_SERVER_LIMIT;
2110 thread_limit = DEFAULT_THREAD_LIMIT;
2111 ap_daemons_limit = server_limit;
2112 threads_per_child = DEFAULT_THREADS_PER_CHILD;

Callers

nothing calls this directly

Calls 8

ap_exists_config_defineFunction · 0.85
ap_mutex_registerFunction · 0.85
ap_retained_data_getFunction · 0.85
ap_retained_data_createFunction · 0.85
ap_fatal_signal_setupFunction · 0.85
ap_listen_pre_configFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected