spmt_os2.c revision 87e0da4e1eabf35b0b2a48a9290c5e725854de8f
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz/* ====================================================================
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * The Apache Software License, Version 1.1
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * Copyright (c) 2000 The Apache Software Foundation. All rights
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * reserved.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Redistribution and use in source and binary forms, with or without
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * modification, are permitted provided that the following conditions
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * 1. Redistributions of source code must retain the above copyright
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * notice, this list of conditions and the following disclaimer.
71da3cca78eea6010f89b139ecadb79e6d213c4fnd * 2. Redistributions in binary form must reproduce the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer in
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the documentation and/or other materials provided with the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * distribution.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * 3. The end-user documentation included with the redistribution,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * if any, must include the following acknowledgment:
f4c310fd2555c6faca1f980f00b161eadb089023gstein * "This product includes software developed by the
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * Apache Software Foundation (http://www.apache.org/)."
952023a04a2f9d51553babd9094fb857f1c97548trawick * Alternately, this acknowledgment may appear in the software itself,
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * if and wherever such third-party acknowledgments normally appear.
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * 4. The names "Apache" and "Apache Software Foundation" must
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * not be used to endorse or promote products derived from this
f4c310fd2555c6faca1f980f00b161eadb089023gstein * software without prior written permission. For written
f4c310fd2555c6faca1f980f00b161eadb089023gstein * permission, please contact apache@apache.org.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * 5. Products derived from this software may not be called "Apache",
f4c310fd2555c6faca1f980f00b161eadb089023gstein * nor may "Apache" appear in their name, without prior written
f4c310fd2555c6faca1f980f00b161eadb089023gstein * permission of the Apache Software Foundation.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
f4c310fd2555c6faca1f980f00b161eadb089023gstein * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
f4c310fd2555c6faca1f980f00b161eadb089023gstein * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f4c310fd2555c6faca1f980f00b161eadb089023gstein * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
f4c310fd2555c6faca1f980f00b161eadb089023gstein * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f4c310fd2555c6faca1f980f00b161eadb089023gstein * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f4c310fd2555c6faca1f980f00b161eadb089023gstein * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f4c310fd2555c6faca1f980f00b161eadb089023gstein * SUCH DAMAGE.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * ====================================================================
f4c310fd2555c6faca1f980f00b161eadb089023gstein * This software consists of voluntary contributions made by many
f4c310fd2555c6faca1f980f00b161eadb089023gstein * individuals on behalf of the Apache Software Foundation. For more
f4c310fd2555c6faca1f980f00b161eadb089023gstein * information on the Apache Software Foundation, please see
5b03ba47ff7225cacb131f14b019332af27da960gstein * Portions of this software are based upon public domain software
5b03ba47ff7225cacb131f14b019332af27da960gstein * originally written at the National Center for Supercomputing Applications,
5b03ba47ff7225cacb131f14b019332af27da960gstein * University of Illinois, Urbana-Champaign.
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe/* config globals */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic int ap_extended_status = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * The max child slot ever assigned, preserved across restarts. Necessary
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * to deal with MaxClients changes across SIGUSR1 restarts. We use this
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * value to optimize routines that have to scan the entire scoreboard.
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* *Non*-shared http_main globals... */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe/* one_process --- debugging mode variable; can be set from the command line
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * with the -X flag. If set, this gets you the child_main loop running
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * in the process which originally started up (no detach, no make_child),
f4c310fd2555c6faca1f980f00b161eadb089023gstein * which is a pretty nice debugging environment. (You'll get a SIGHUP
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * early in standalone_main; just continue through. This is the server
f4c310fd2555c6faca1f980f00b161eadb089023gstein * trying to kill off any child processes which it might have lying
f4c310fd2555c6faca1f980f00b161eadb089023gstein * around --- Apache doesn't keep track of their pids, it just sends
f4c310fd2555c6faca1f980f00b161eadb089023gstein * SIGHUP to the process group, ignoring it in the root process.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Continue through and you'll be fine.).
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowestatic int one_process = 0;
58fd79b56eb624bf011772994e9761d3c2e228c1orlikowskistatic struct thread_globals **ppthread_globals = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define THREAD_GLOBAL(gvar) ((*ppthread_globals)->gvar)
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE);
58fd79b56eb624bf011772994e9761d3c2e228c1orlikowski ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Ouch! Out of memory reiniting scoreboard!");
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* a clean exit from a child with proper cleanup */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_scoreboard_image->servers[THREAD_GLOBAL(child_num)].thread_retval = code;
8b99f2a316c5e2fa6ab208206fdd7fc2bfc4a921dougmstatic ap_status_t accept_mutex_child_cleanup(void *foo)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Initialize mutex lock.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Done by each child at it's birth
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_register_cleanup(p, NULL, accept_mutex_child_cleanup, ap_null_cleanup);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Initialize mutex lock.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Must be safe to call this on a restart.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_status_t rc = ap_create_lock(&accept_mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, p);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_EMERG, rc, server_conf,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Error creating accept lock. Exiting!");
48f35e10f195dd594d75738fc536bb885eda537cgsteinstatic void accept_mutex_on(void)
48f35e10f195dd594d75738fc536bb885eda537cgstein ap_log_error(APLOG_MARK, APLOG_EMERG, rc, server_conf,
48f35e10f195dd594d75738fc536bb885eda537cgstein "Error getting accept lock. Exiting!");
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wrowestatic void accept_mutex_off(void)
48f35e10f195dd594d75738fc536bb885eda537cgstein ap_log_error(APLOG_MARK, APLOG_EMERG, rc, server_conf,
48f35e10f195dd594d75738fc536bb885eda537cgstein "Error freeing accept lock. Exiting!");
77c2148c53e0a4a20a80af735caa4e0e6bd448e0gstein/* On some architectures it's safe to do unserialized accept()s in the single
77c2148c53e0a4a20a80af735caa4e0e6bd448e0gstein * Listen case. But it's never safe to do it in the case where there's
48f35e10f195dd594d75738fc536bb885eda537cgstein * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
48f35e10f195dd594d75738fc536bb885eda537cgstein * when it's safe in the single Listen case.
48f35e10f195dd594d75738fc536bb885eda537cgstein#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next) {stmt;}} while(0)
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint ap_update_child_status(int child_num, int status, request_rec *r)
48f35e10f195dd594d75738fc536bb885eda537cgstein if (status == SERVER_READY || status == SERVER_DEAD) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Reset individual counters
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config,
77c2148c53e0a4a20a80af735caa4e0e6bd448e0gstein ap_cpystrn(ss->request, "NULL", sizeof(ss->request));
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cpystrn(ss->request, r->the_request, sizeof(ss->request));
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Don't reveal the password in the server-status view */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ",
8b99f2a316c5e2fa6ab208206fdd7fc2bfc4a921dougm ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD),
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* clean up the slot's vhostrec pointer (maybe re-used)
f4c310fd2555c6faca1f980f00b161eadb089023gstein * and mark the slot as belonging to a new generation.
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_scoreboard_image->parent[child_num].generation = ap_scoreboard_image->global.running_generation;
0206c121a68a63559b2e843288e81bcf16093e46jerenkrantzvoid ap_time_process_request(int child_num, int status)
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* TODO: call me some time */
f39230a531b23d94f86a087963299bbe2e431a4agsteinstatic void increment_counts(int child_num, request_rec *r)
f39230a531b23d94f86a087963299bbe2e431a4agstein long int bs = 0;
ab78b55c6dc4431d2c68d6bb4d169ba1554290a8gstein for (i = 0; i < max_daemons_limit; ++i)
ab78b55c6dc4431d2c68d6bb4d169ba1554290a8gstein/* Finally, this routine is used by the caretaker thread to wait for
ab78b55c6dc4431d2c68d6bb4d169ba1554290a8gstein * a while...
ab78b55c6dc4431d2c68d6bb4d169ba1554290a8gstein/* number of calls to wait_or_timeout between writable probes */
f39230a531b23d94f86a087963299bbe2e431a4agstein if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
f39230a531b23d94f86a087963299bbe2e431a4agstein if (ret == 0) {
f39230a531b23d94f86a087963299bbe2e431a4agstein *status = ap_scoreboard_image->servers[child_num].thread_retval;
f39230a531b23d94f86a087963299bbe2e431a4agstein#if defined(NSIG)
b5989e567e4fac5b3ab1252024ae19b0a54893a7gstein#define NumSIG 32 /* for 1998's unixes, this is still a good assumption */
b5989e567e4fac5b3ab1252024ae19b0a54893a7gstein#else /* platform has no sys_siglist[], define our own */
b5989e567e4fac5b3ab1252024ae19b0a54893a7gsteinstatic void siglist_init(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_sys_siglist[SIGXFSZ] = "exceeded file size limit";
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (sig=0; sig < sizeof(ap_sys_siglist)/sizeof(ap_sys_siglist[0]); ++sig)
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* platform has sys_siglist[] */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm/* handle all varieties of core dumping signals */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* At this point we've got sig blocked, because we're still inside
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the signal handler. When we leave the signal handler it will
f4c310fd2555c6faca1f980f00b161eadb089023gstein * be unblocked, and we'll take the signal... and coredump or whatever
f4c310fd2555c6faca1f980f00b161eadb089023gstein * is appropriate for this particular Unix. In addition the parent
f4c310fd2555c6faca1f980f00b161eadb089023gstein * will see the real signal we received -- whereas if we called
f4c310fd2555c6faca1f980f00b161eadb089023gstein * abort() here, the parent would only see SIGABRT.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe/*****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Connection structures and accounting...
5a8f3bcf803321e69b226d3b98314305a68a586cjerenkrantz ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die = 1;
5a8f3bcf803321e69b226d3b98314305a68a586cjerenkrantz/* volatile just in case */
5a8f3bcf803321e69b226d3b98314305a68a586cjerenkrantzstatic int volatile shutdown_pending;
5a8f3bcf803321e69b226d3b98314305a68a586cjerenkrantzstatic int volatile restart_pending;
5a8f3bcf803321e69b226d3b98314305a68a586cjerenkrantzstatic int volatile is_graceful;
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Um, is this _probably_ not an error, if the user has
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * tried to do a shutdown twice quickly, so we won't
f4c310fd2555c6faca1f980f00b161eadb089023gstein * worry about reporting it.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Probably not an error - don't bother reporting it */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void set_signals(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we want to ignore HUPs and USR1 while we're busy processing one */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGUSR1)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGBUS */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGABORT */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGABRT */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGILL */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGXCPU */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGXFSZ */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGHUP */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGUSR1 */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#endif /* SIGPIPE */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* The Nagle algorithm says that we should delay sending partial
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * packets in hopes of getting more data. We don't want to do
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * this; we are not telnet. There are bad interactions between
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * persistent connections and Nagle's algorithm that have very severe
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * performance penalties. (Failing to disable Nagle is not much of a
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * problem with simple HTTP.)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * In spite of these problems, failure here is not a shooting offense.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe status = ap_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no, sizeof(int));
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_WARNING, status, server_conf,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "setsockopt: (TCP_NODELAY)");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe/*****************************************************************
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Child process main loop.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die = 1;
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die ||
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_scoreboard_image->global.running_generation != ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].generation) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die ||
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_scoreboard_image->global.running_generation != ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].generation) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic int setup_listeners(ap_pool_t *pchild, ap_pollfd_t **listen_poll)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* Disable the restart signal handlers and enable the just_die stuff.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Note that since restart() just notes that a restart has been
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * requested there's no race condition here.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe set_signals(); /* signals aren't inherrited by child threads */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* Get a sub pool for global allocations in this child, so that
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * we can have cleanups occur when the child exits.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe *ppthread_globals = (struct thread_globals *)ap_palloc(pchild, sizeof(struct thread_globals));
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe sc_parent_rec = ap_scoreboard_image->parent + THREAD_GLOBAL(child_num);
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* needs to be done before we switch UIDs so we have permissions */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_READY, (request_rec *) NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Prepare to receive a SIGUSR1 due to graceful restart so that
f4c310fd2555c6faca1f980f00b161eadb089023gstein * we can exit cleanly.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * (Re)initialize this child to a pre-connection state.
f4c310fd2555c6faca1f980f00b161eadb089023gstein && requests_this_child++ >= ap_max_requests_per_child)) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_READY, (request_rec *) NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Wait for an acceptable connection to arrive.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Lock around "accept", if necessary */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* more than one socket */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Single Unix documents select as returning errnos
f4c310fd2555c6faca1f980f00b161eadb089023gstein * EBADF, EINTR, and EINVAL... and in none of those
f4c310fd2555c6faca1f980f00b161eadb089023gstein * cases does it make sense to continue. In fact
f4c310fd2555c6faca1f980f00b161eadb089023gstein * on Linux 2.0.x we seem to end up with EFAULT
f4c310fd2555c6faca1f980f00b161eadb089023gstein * occasionally, and we'd loop forever due to it.
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "select: (listen)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we remember the last_lr we searched last time around so that
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe we don't end up starving any particular listening socket */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* only one socket, just pretend we did the other stuff */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* if we accept() something we don't want to die, so we have to
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * defer the exit
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe break; /* We have a socket ready for reading */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Our old behaviour here was to continue after accept()
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * errors. But this leads us into lots of troubles
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * because most of the errors are quite fatal. For
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * example, EMFILE can be caused by slow descriptor
f4c310fd2555c6faca1f980f00b161eadb089023gstein * leaks (say in a 3rd party module, or libc). It's
f4c310fd2555c6faca1f980f00b161eadb089023gstein * foolish for us to continue after an EMFILE. We also
f4c310fd2555c6faca1f980f00b161eadb089023gstein * seem to tickle kernel bugs on some platforms which
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * lead to never-ending loops here. So it seems best
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * to just exit in most cases.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* EPROTO on certain older kernels really means
f4c310fd2555c6faca1f980f00b161eadb089023gstein * ECONNABORTED, so we need to ignore it for them.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * See discussion in new-httpd archives nh.9701
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * search for EPROTO.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Also see nh.9603, search for EPROTO:
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * There is potentially a bug in Solaris 2.x x<6,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * and other boxes that implement tcp sockets in
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * userland (i.e. on top of STREAMS). On these
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * systems, EPROTO can actually result in a fatal
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * loop. See PR#981 for example. It's hard to
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * handle both uses of EPROTO.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Linux generates the rest of these, other tcp
f4c310fd2555c6faca1f980f00b161eadb089023gstein * stacks (i.e. bsd) tend to hide them behind
f4c310fd2555c6faca1f980f00b161eadb089023gstein * getsockopt() interfaces. They occur when
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the net goes sour or the client disconnects
f4c310fd2555c6faca1f980f00b161eadb089023gstein * after the three-way handshake has been done
f4c310fd2555c6faca1f980f00b161eadb089023gstein * in the kernel but before userland has picked
f4c310fd2555c6faca1f980f00b161eadb089023gstein * up the socket.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* We only get hit by an EINTR if the parent is
f4c310fd2555c6faca1f980f00b161eadb089023gstein * killing us off
f4c310fd2555c6faca1f980f00b161eadb089023gstein "accept: (client socket)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* We've got a socket, let's at least process one request off the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * socket before we accept a graceful restart request. We set
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the signal to ignore because we don't want to disturb any
f4c310fd2555c6faca1f980f00b161eadb089023gstein * third party code.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * We now have a connection, so set it up with the appropriate
f4c310fd2555c6faca1f980f00b161eadb089023gstein * socket options, file descriptors, and read/write buffers.
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "error attaching to socket");
f4c310fd2555c6faca1f980f00b161eadb089023gstein (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_BUSY_READ,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe current_conn = ap_new_apr_connection(ptrans, server_conf, conn_io, csd,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic int make_child(server_rec *s, int slot, time_t now)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe struct thread_globals *parent_globals = *ppthread_globals;
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_update_child_status(slot, SERVER_STARTING, (request_rec *) NULL);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if ((tid = _beginthread(child_main, NULL, 256*1024, (void *)slot)) == -1) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s, "_beginthread: Unable to create new thread");
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz /* _beginthread didn't succeed. Fix the scoreboard or else
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz * it will say SERVER_STARTING forever and ever
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz (void) ap_update_child_status(slot, SERVER_DEAD, (request_rec *) NULL);
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz /* In case system resources are maxxed out, we don't want
0fad1368edb71b1411d6d00684900e5d2a6e6b78jerenkrantz Apache running away with the CPU trying to _beginthread over and
0df0055470838140d9797dd186b2fdbe67edcc57jorton over and over again. */
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz/* start up a bunch of children */
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantzstatic void startup_children(int number_to_start)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe for (i = 0; number_to_start && i < ap_daemons_limit; ++i) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * idle_spawn_rate is the number of children that will be spawned on the
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * next maintenance cycle if there aren't enough idle servers. It is
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * without the need to spawn.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* initialize the free_list */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe for (i = 0; i < ap_daemons_limit; ++i) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (i >= max_daemons_limit && free_length == idle_spawn_rate)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* try to keep children numbers as low as possible */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* We consider a starting server as idle because we started it
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * at least a cycle ago, and if it still hasn't finished starting
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * then we're just going to swamp things worse by forking more.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * So we hopefully won't need to fork more if we count it.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * This depends on the ordering of SERVER_READY and SERVER_STARTING.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* always kill the highest numbered child if we have to...
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * no really well thought out reason ... other than observing
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * the server behaviour under linux where lower numbered children
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * tend to service more hits (and hence are more likely to have
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * their data in cpu caches).
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* kill off one child... we use SIGUSR1 because that'll cause it to
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * shut down gracefully, in case it happened to pick up a request
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * while we were counting
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_scoreboard_image->parent[to_kill].deferred_die = 1;
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* terminate the free list */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* only report this condition once */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe static int reported = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "server reached MaxClients setting, consider"
f4c310fd2555c6faca1f980f00b161eadb089023gstein " raising the MaxClients setting");
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "server seems busy, (you may need "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "to increase StartServers, or Min/MaxSpareServers), "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "spawning %d children, there are %d idle, and "
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe for (i = 0; i < free_length; ++i) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* the next time around we want to spawn twice as many if this
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * wasn't good enough, but not if we've just done a graceful
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic void process_child_status(int tid, ap_wait_t status)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* Child died... if it died due to a fatal error,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * we should simply bail out.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Child %d returned a Fatal error... \n"
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Apache is exiting!",
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "child tid %d exit signal %s (%d), "
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "possible coredump in %s",
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "child tid %d exit signal %d",
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe/*****************************************************************
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * Executive routines.
6f15570e3adc0faf87bf55f70857028276fc9e32wroweint ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if ((status = ap_listen_open(s->process, s->port)) != APR_SUCCESS) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, status, s,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "no listening sockets available, shutting down");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (DosAllocThreadLocalMemory(1, (PULONG *)&ppthread_globals)) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Error allocating thread local storage"
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Apache is exiting!");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe *ppthread_globals = (struct thread_globals *)ap_palloc(pconf, sizeof(struct thread_globals));
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* If we're doing a graceful_restart then we're going to see a lot
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * of children exiting immediately when we get into the main loop
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * below (because we just sent them SIGUSR1). This happens pretty
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * rapidly... and for each one that exits we'll start a new one until
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * we reach at least daemons_min_free. But we may be permitted to
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * start more than that, so we'll just keep track of how many we're
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * supposed to start up without the 1 second penalty between each fork.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* give the system some time to recover before kicking into
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * exponential mode */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "%s configured -- resuming normal operations",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX: if it takes longer than 1 second for all our children
f4c310fd2555c6faca1f980f00b161eadb089023gstein * to start up and get into IDLE state then we may spawn an
f4c310fd2555c6faca1f980f00b161eadb089023gstein * extra child
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (tid >= 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* non-fatal death... note that it's gone in the scoreboard. */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe (void) ap_update_child_status(child_slot, SERVER_DEAD,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* we're still doing a 1-for-1 replacement of dead
f4c310fd2555c6faca1f980f00b161eadb089023gstein * children with new children
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* TODO: this won't work, we waited on a thread not a process
f4c310fd2555c6faca1f980f00b161eadb089023gstein else if (reap_other_child(pid, status) == 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Great, we've probably just lost a slot in the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * scoreboard. Somehow we don't know about this
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Don't perform idle maintenance when a child dies,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * only do it when there's a timeout. Remember only a
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * finite number of children can die, and it's pretty
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * pathological for a lot to die suddenly.
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein /* we hit a 1 second timeout in which none of the previous
f4c310fd2555c6faca1f980f00b161eadb089023gstein * generation of children needed to be reaped... so assume
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein * they're all done, and pick up the slack if any is left.
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* In any event we really shouldn't do the code below because
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * few of the servers we just started are in the IDLE state
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe * yet, so we'd mistakenly create an extra server.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Time to gracefully shut down */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Kill off running threads */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_scoreboard_image->servers[slot].status != SERVER_DEAD) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (rc != ERROR_INVALID_THREADID) { // Already dead, ignore
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (rc == 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
0206c121a68a63559b2e843288e81bcf16093e46jerenkrantz ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* cleanup pid file on normal shutdown */
f4c310fd2555c6faca1f980f00b161eadb089023gstein pidfile = ap_server_root_relative (pconf, ap_pid_fname);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "removed PID file %s (pid=%ld)",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "caught SIGTERM, shutting down");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we've been told to restart */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* not worth thinking about */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe /* advance to the next generation */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX: we really need to make sure this new generation number isn't in
f4c310fd2555c6faca1f980f00b161eadb089023gstein * use by any of the children.
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "SIGUSR1 received. Doing graceful restart");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* kill off the idle ones */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe for (i = 0; i < ap_daemons_limit; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This is mostly for debugging... so that we know what is still
f4c310fd2555c6faca1f980f00b161eadb089023gstein * gracefully dealing with existing request. But we can't really
f4c310fd2555c6faca1f980f00b161eadb089023gstein * do it if we're in a SCOREBOARD_FILE because it'll cause
f4c310fd2555c6faca1f980f00b161eadb089023gstein * corruption too easily.
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < ap_daemons_limit; ++i) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_scoreboard_image->servers[i].status = SERVER_GRACEFUL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Kill 'em off */
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe for (i = 0; i < ap_daemons_limit; ++i) {
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "SIGHUP received. Attempting to restart");
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void spmt_os2_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gsteinstatic void spmt_os2_hooks(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* TODO: set one_process properly */ one_process = 0;
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_hook_pre_config(spmt_os2_pre_config, NULL, NULL, AP_HOOK_MIDDLE);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe return "PidFile directive not allowed in <VirtualHost>";
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic const char *set_min_free_servers(cmd_parms *cmd, void *dummy, char *arg)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "WARNING: detected MinSpareServers set to non-positive.");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Resetting to 1 to avoid almost certain Apache failure.");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Please read the documentation.");
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic const char *set_max_free_servers(cmd_parms *cmd, void *dummy, char *arg)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
6f15570e3adc0faf87bf55f70857028276fc9e32wrowestatic const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "WARNING: MaxClients of %d exceeds compile time limit "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " lowering MaxClients to %d. To increase, please "
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " HARD_SERVER_LIMIT define in src/include/httpd.h.");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "WARNING: Require MaxClients > 0, setting to 1");
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *fname;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Stub functions until this MPM supports the connection status API */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *value)
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_reset_connection_status(long conn_id)
f4c310fd2555c6faca1f980f00b161eadb089023gstein "A file for logging the server process ID"},
f4c310fd2555c6faca1f980f00b161eadb089023gstein{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Number of child processes launched at server startup" },
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe{ "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, TAKE1,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Minimum number of idle children, to handle request spikes" },
f4c310fd2555c6faca1f980f00b161eadb089023gstein{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Maximum number of idle children" },
f4c310fd2555c6faca1f980f00b161eadb089023gstein{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe "Maximum number of children alive at the same time" },
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Maximum number of requests a particular child serves before dying." },
6f15570e3adc0faf87bf55f70857028276fc9e32wrowe{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "The location of the directory Apache changes to before dumping core" },