| 1281 | } |
| 1282 | |
| 1283 | static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) |
| 1284 | { |
| 1285 | int no_detach, debug, foreground; |
| 1286 | apr_status_t rv; |
| 1287 | const char *userdata_key = "mpm_prefork_module"; |
| 1288 | |
| 1289 | debug = ap_exists_config_define("DEBUG"); |
| 1290 | |
| 1291 | if (debug) { |
| 1292 | foreground = one_process = 1; |
| 1293 | no_detach = 0; |
| 1294 | } |
| 1295 | else |
| 1296 | { |
| 1297 | no_detach = ap_exists_config_define("NO_DETACH"); |
| 1298 | one_process = ap_exists_config_define("ONE_PROCESS"); |
| 1299 | foreground = ap_exists_config_define("FOREGROUND"); |
| 1300 | } |
| 1301 | |
| 1302 | ap_mutex_register(p, AP_ACCEPT_MUTEX_TYPE, NULL, APR_LOCK_DEFAULT, 0); |
| 1303 | |
| 1304 | retained = ap_retained_data_get(userdata_key); |
| 1305 | if (!retained) { |
| 1306 | retained = ap_retained_data_create(userdata_key, sizeof(*retained)); |
| 1307 | retained->mpm = ap_unixd_mpm_get_retained_data(); |
| 1308 | retained->idle_spawn_rate = 1; |
| 1309 | } |
| 1310 | retained->mpm->mpm_state = AP_MPMQ_STARTING; |
| 1311 | if (retained->mpm->baton != retained) { |
| 1312 | retained->mpm->was_graceful = 0; |
| 1313 | retained->mpm->baton = retained; |
| 1314 | } |
| 1315 | ++retained->mpm->module_loads; |
| 1316 | |
| 1317 | /* sigh, want this only the second time around */ |
| 1318 | if (retained->mpm->module_loads == 2) { |
| 1319 | if (!one_process && !foreground) { |
| 1320 | /* before we detach, setup crash handlers to log to errorlog */ |
| 1321 | ap_fatal_signal_setup(ap_server_conf, p /* == pconf */); |
| 1322 | rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND |
| 1323 | : APR_PROC_DETACH_DAEMONIZE); |
| 1324 | if (rv != APR_SUCCESS) { |
| 1325 | ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, APLOGNO(00174) |
| 1326 | "apr_proc_detach failed"); |
| 1327 | return HTTP_INTERNAL_SERVER_ERROR; |
| 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | parent_pid = ap_my_pid = getpid(); |
| 1333 | |
| 1334 | ap_listen_pre_config(); |
| 1335 | ap_daemons_to_start = DEFAULT_START_DAEMON; |
| 1336 | ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON; |
| 1337 | ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON; |
| 1338 | server_limit = DEFAULT_SERVER_LIMIT; |
| 1339 | ap_daemons_limit = server_limit; |
| 1340 | ap_extended_status = 0; |
nothing calls this directly
no test coverage detected