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

Function prefork_run

server/mpm/prefork/prefork.c:899–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

897 */
898
899static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
900{
901 int index;
902 int remaining_children_to_start;
903 int i;
904
905 ap_log_pid(pconf, ap_pid_fname);
906
907 if (!retained->mpm->was_graceful) {
908 if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
909 retained->mpm->mpm_state = AP_MPMQ_STOPPING;
910 return !OK;
911 }
912 /* fix the generation number in the global score; we just got a new,
913 * cleared scoreboard
914 */
915 ap_scoreboard_image->global->running_generation = retained->mpm->my_generation;
916 }
917
918 ap_unixd_mpm_set_signals(pconf, one_process);
919
920 if (one_process) {
921 AP_MONCONTROL(1);
922 make_child(ap_server_conf, 0);
923 /* NOTREACHED */
924 ap_assert(0);
925 return !OK;
926 }
927
928 /* Don't thrash since num_buckets depends on the
929 * system and the number of online CPU cores...
930 */
931 if (ap_daemons_limit < retained->mpm->num_buckets)
932 ap_daemons_limit = retained->mpm->num_buckets;
933 if (ap_daemons_to_start < retained->mpm->num_buckets)
934 ap_daemons_to_start = retained->mpm->num_buckets;
935 if (ap_daemons_min_free < retained->mpm->num_buckets)
936 ap_daemons_min_free = retained->mpm->num_buckets;
937 if (ap_daemons_max_free < ap_daemons_min_free + retained->mpm->num_buckets)
938 ap_daemons_max_free = ap_daemons_min_free + retained->mpm->num_buckets;
939
940 /* If we're doing a graceful_restart then we're going to see a lot
941 * of children exiting immediately when we get into the main loop
942 * below (because we just sent them AP_SIG_GRACEFUL). This happens pretty
943 * rapidly... and for each one that exits we'll start a new one until
944 * we reach at least daemons_min_free. But we may be permitted to
945 * start more than that, so we'll just keep track of how many we're
946 * supposed to start up without the 1 second penalty between each fork.
947 */
948 remaining_children_to_start = ap_daemons_to_start;
949 if (remaining_children_to_start > ap_daemons_limit) {
950 remaining_children_to_start = ap_daemons_limit;
951 }
952 if (!retained->mpm->was_graceful) {
953 startup_children(remaining_children_to_start);
954 remaining_children_to_start = 0;
955 }
956 else {

Callers

nothing calls this directly

Calls 15

ap_log_pidFunction · 0.85
ap_unixd_mpm_set_signalsFunction · 0.85
ap_get_server_builtFunction · 0.85
ap_log_command_lineFunction · 0.85
ap_log_mpm_commonFunction · 0.85
ap_wait_or_timeoutFunction · 0.85
ap_process_child_statusFunction · 0.85
ap_find_child_by_pidFunction · 0.85

Tested by

no test coverage detected