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

Function make_child

server/mpm/event/event.c:2813–2888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2811}
2812
2813static int make_child(server_rec * s, int slot, int bucket)
2814{
2815 int pid;
2816
2817 if (slot + 1 > retained->max_daemon_used) {
2818 retained->max_daemon_used = slot + 1;
2819 }
2820
2821 if (ap_scoreboard_image->parent[slot].pid != 0) {
2822 /* XXX replace with assert or remove ? */
2823 ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(03455)
2824 "BUG: Scoreboard slot %d should be empty but is "
2825 "in use by pid %" APR_PID_T_FMT,
2826 slot, ap_scoreboard_image->parent[slot].pid);
2827 return -1;
2828 }
2829
2830 if (one_process) {
2831 my_bucket = &all_buckets[0];
2832
2833 event_note_child_started(slot, getpid());
2834 child_main(slot, 0);
2835 /* NOTREACHED */
2836 ap_assert(0);
2837 return -1;
2838 }
2839
2840 if ((pid = fork()) == -1) {
2841 ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, APLOGNO(00481)
2842 "fork: Unable to fork new process");
2843
2844 /* fork didn't succeed. There's no need to touch the scoreboard;
2845 * if we were trying to replace a failed child process, then
2846 * server_main_loop() marked its workers SERVER_DEAD, and if
2847 * we were trying to replace a child process that exited normally,
2848 * its worker_thread()s left SERVER_DEAD or SERVER_GRACEFUL behind.
2849 */
2850
2851 /* In case system resources are maxxed out, we don't want
2852 Apache running away with the CPU trying to fork over and
2853 over and over again. */
2854 apr_sleep(apr_time_from_sec(10));
2855
2856 return -1;
2857 }
2858
2859 if (!pid) {
2860#if AP_HAS_THREAD_LOCAL
2861 ap_thread_current_after_fork();
2862#endif
2863
2864 my_bucket = &all_buckets[bucket];
2865
2866#ifdef HAVE_BINDPROCESSOR
2867 /* By default, AIX binds to a single processor. This bit unbinds
2868 * children which will then bind to another CPU.
2869 */
2870 int status = bindprocessor(BINDPROCESS, (int) getpid(),

Callers 6

startup_childrenFunction · 0.70
server_main_loopFunction · 0.70
startup_childrenFunction · 0.50
prefork_runFunction · 0.50

Calls 4

event_note_child_startedFunction · 0.85
child_mainFunction · 0.70
ap_log_errorFunction · 0.50

Tested by

no test coverage detected