| 1307 | } |
| 1308 | |
| 1309 | static int make_child(server_rec *s, int slot, int bucket) |
| 1310 | { |
| 1311 | int pid; |
| 1312 | |
| 1313 | if (slot + 1 > retained->max_daemons_limit) { |
| 1314 | retained->max_daemons_limit = slot + 1; |
| 1315 | } |
| 1316 | |
| 1317 | if (one_process) { |
| 1318 | my_bucket = &all_buckets[0]; |
| 1319 | |
| 1320 | worker_note_child_started(slot, getpid()); |
| 1321 | child_main(slot, 0); |
| 1322 | /* NOTREACHED */ |
| 1323 | ap_assert(0); |
| 1324 | return -1; |
| 1325 | } |
| 1326 | |
| 1327 | if ((pid = fork()) == -1) { |
| 1328 | ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, APLOGNO(00283) |
| 1329 | "fork: Unable to fork new process"); |
| 1330 | /* fork didn't succeed. There's no need to touch the scoreboard; |
| 1331 | * if we were trying to replace a failed child process, then |
| 1332 | * server_main_loop() marked its workers SERVER_DEAD, and if |
| 1333 | * we were trying to replace a child process that exited normally, |
| 1334 | * its worker_thread()s left SERVER_DEAD or SERVER_GRACEFUL behind. |
| 1335 | */ |
| 1336 | |
| 1337 | /* In case system resources are maxxed out, we don't want |
| 1338 | Apache running away with the CPU trying to fork over and |
| 1339 | over and over again. */ |
| 1340 | apr_sleep(apr_time_from_sec(10)); |
| 1341 | |
| 1342 | return -1; |
| 1343 | } |
| 1344 | |
| 1345 | if (!pid) { |
| 1346 | #if AP_HAS_THREAD_LOCAL |
| 1347 | ap_thread_current_after_fork(); |
| 1348 | #endif |
| 1349 | |
| 1350 | my_bucket = &all_buckets[bucket]; |
| 1351 | |
| 1352 | #ifdef HAVE_BINDPROCESSOR |
| 1353 | /* By default, AIX binds to a single processor. This bit unbinds |
| 1354 | * children which will then bind to another CPU. |
| 1355 | */ |
| 1356 | int status = bindprocessor(BINDPROCESS, (int)getpid(), |
| 1357 | PROCESSOR_CLASS_ANY); |
| 1358 | if (status != OK) |
| 1359 | ap_log_error(APLOG_MARK, APLOG_DEBUG, errno, |
| 1360 | ap_server_conf, APLOGNO(00284) |
| 1361 | "processor unbind failed"); |
| 1362 | #endif |
| 1363 | RAISE_SIGSTOP(MAKE_CHILD); |
| 1364 | |
| 1365 | apr_signal(SIGTERM, just_die); |
| 1366 | child_main(slot, bucket); |
no test coverage detected