mpmt_pthread.c revision 174574a7fa1803ce99ffc54c19473a5057935bb9
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* ====================================================================
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * The Apache Software License, Version 1.1
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Copyright (c) 2000 The Apache Software Foundation. All rights
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Redistribution and use in source and binary forms, with or without
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * modification, are permitted provided that the following conditions
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * 1. Redistributions of source code must retain the above copyright
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * notice, this list of conditions and the following disclaimer.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * 2. Redistributions in binary form must reproduce the above copyright
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * notice, this list of conditions and the following disclaimer in
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * the documentation and/or other materials provided with the
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * distribution.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * 3. The end-user documentation included with the redistribution,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * if any, must include the following acknowledgment:
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * "This product includes software developed by the
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Apache Software Foundation (http://www.apache.org/)."
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Alternately, this acknowledgment may appear in the software itself,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * if and wherever such third-party acknowledgments normally appear.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * 4. The names "Apache" and "Apache Software Foundation" must
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * not be used to endorse or promote products derived from this
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * software without prior written permission. For written
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * permission, please contact apache@apache.org.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * 5. Products derived from this software may not be called "Apache",
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * nor may "Apache" appear in their name, without prior written
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * permission of the Apache Software Foundation.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * SUCH DAMAGE.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * ====================================================================
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * This software consists of voluntary contributions made by many
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * individuals on behalf of the Apache Software Foundation. For more
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * information on the Apache Software Foundation, please see
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Portions of this software are based upon public domain software
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * originally written at the National Center for Supercomputing Applications,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * University of Illinois, Urbana-Champaign.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "http_config.h" /* for read_config */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#include "http_core.h" /* for get_remote_host */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Actual definitions of config globals
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannint ap_threads_per_child=0; /* Worker threads per child */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannAP_DECLARE_DATA const char *ap_scoreboard_fname=NULL;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* The structure used to pass unique initialization info to each thread */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmanntypedef struct {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_pool_t *tpool; /* "pthread" would be confusing */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * The max child slot ever assigned, preserved across restarts. Necessary
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * to deal with MaxClients changes across SIGWINCH restarts. We use this
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * value to optimize routines that have to scan the entire scoreboard.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* *Non*-shared http_main globals... */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* one_process --- debugging mode variable; can be set from the command line
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * with the -X flag. If set, this gets you the child_main loop running
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * in the process which originally started up (no detach, no make_child),
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * which is a pretty nice debugging environment. (You'll get a SIGHUP
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * early in standalone_main; just continue through. This is the server
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * trying to kill off any child processes which it might have lying
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * around --- Apache doesn't keep track of their pids, it just sends
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * SIGHUP to the process group, ignoring it in the root process.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Continue through and you'll be fine.).
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic apr_pool_t *pconf; /* Pool for config stuff */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic apr_pool_t *pchild; /* Pool for httpd child stuff */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannunsigned int ap_my_pid; /* Linux getpid() doesn't work except in main
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann thread. Use this instead */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* Keep track of the number of worker threads currently active */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic pthread_mutex_t worker_thread_count_mutex;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* Locks for accept serialization */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic const char *lock_fname;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* a clean exit from a child with proper cleanup */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic void clean_child_exit(int code) __attribute__ ((noreturn));
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* handle all varieties of core dumping signals */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* At this point we've got sig blocked, because we're still inside
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * the signal handler. When we leave the signal handler it will
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * be unblocked, and we'll take the signal... and coredump or whatever
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * is appropriate for this particular Unix. In addition the parent
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * will see the real signal we received -- whereas if we called
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * abort() here, the parent would only see SIGABRT.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/*****************************************************************
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Connection structures and accounting...
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* volatile just in case */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic int volatile shutdown_pending;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic int volatile restart_pending;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic int volatile is_graceful;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * ap_start_shutdown() and ap_start_restart(), below, are a first stab at
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * functions to initiate shutdown or restart without relying on signals.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Previously this was initiated in sig_term() and restart() signal handlers,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * but we want to be able to start a shutdown/restart from other sources --
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * e.g. on Win32, from the service manager. Now the service manager can
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * these functions can also be called by the child processes, since global
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * variables are no longer used to pass on the required action to the parent.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * These should only be called from the parent process itself, since the
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * parent process will use the shutdown_pending and restart_pending variables
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * to determine whether to shutdown or restart. The child process should
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * call signal_parent() directly to tell the parent to die -- this will
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * cause neither of those variable to be set, which the parent will
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * assume means something serious is wrong (which it will be, for the
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * child to force an exit) and so do an exit anyway.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Um, is this _probably_ not an error, if the user has
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * tried to do a shutdown twice quickly, so we won't
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * worry about reporting it.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* do a graceful restart if graceful == 1 */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Probably not an error - don't bother reporting it */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic void set_signals(void)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGSEGV)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGBUS)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABORT)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABRT)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGILL)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* we want to ignore HUPs and WINCH while we're busy processing one */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGBUS */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGABORT */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGABRT */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGILL */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGXCPU */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGXFSZ */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGHUP */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGWINCH */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#endif /* SIGPIPE */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/*****************************************************************
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Here follows a long bunch of generic server bookkeeping stuff...
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* XXX - Does this really work? - Manoj */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/*****************************************************************
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Child process main loop.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannstatic void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num, int my_thread_num)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "new file descriptor %d is too large; you probably need "
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "to rebuild Apache with a larger FD_SETSIZE "
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "(currently %d)",
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann (void) ap_update_child_status(my_child_num, my_thread_num,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann current_conn = ap_new_apr_connection(p, ap_server_conf, sock,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* Sets workers_may_exit if we received a character on the pipe_of_death */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ret = apr_recv(listensocks[0], &pipe_read_char, &n);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* It lost the lottery. It must continue to suffer
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * through a life of servitude. */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* It won the lottery (or something else is very
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * wrong). Embrace death with open arms. */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_pool_t *ptrans; /* Pool for per-transaction stuff */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann pthread_mutex_lock(&worker_thread_count_mutex);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann pthread_mutex_unlock(&worker_thread_count_mutex);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_setup_poll(&pollset, num_listensocks+1, tpool);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann for(n=0 ; n <= num_listensocks ; ++n)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_add_poll_socket(pollset, listensocks[n], APR_POLLIN);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* TODO: Switch to a system where threads reuse the results from earlier
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann poll calls - manoj */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann workers_may_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann (void) ap_update_child_status(process_slot, thread_slot, SERVER_READY,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann if ((rv = SAFE_ACCEPT(apr_lock(process_accept_mutex)))
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "apr_lock failed. Attempting to shutdown "
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "process gracefully.");
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* apr_poll() will only return errors in catastrophic
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * circumstances. Let's try exiting gracefully, for now. */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ap_log_error(APLOG_MARK, APLOG_ERR, ret, (const server_rec *)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_get_revents(&event, listensocks[0], pollset);
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* A process got a signal on the shutdown pipe. Check if we're
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * the lucky process to die. */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* find a listener */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* XXX: Should we check for POLLERR? */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann apr_get_revents(&event, listensocks[curr_pollfd], pollset);
if (!workers_may_exit) {
!= APR_SUCCESS) {
!= APR_SUCCESS) {
if (worker_thread_count == 0) {
return NULL;
int signal_received;
pchild));
if (unixd_setup_child()) {
#ifdef SIGPROCMASK_SETS_THREAD_MASK
#ifdef PTHREAD_SETS_ERRNO
worker_thread_count = 0;
for (i=0; i < ap_threads_per_child; i++) {
#ifndef NO_THREADS
#ifdef PTHREAD_SETS_ERRNO
switch (signal_received) {
case SIGTERM:
case SIGINT:
int pid;
if (one_process) {
set_signals();
if (!pid) {
#ifdef AIX_BIND_PROCESSOR
#ifndef MAX_SPAWN_RATE
static int hold_off_on_exponential_spawning;
static void perform_idle_server_maintenance(void)
int idle_thread_count;
int free_length;
int last_non_dead;
int total_non_dead;
free_length = 0;
idle_thread_count = 0;
total_non_dead = 0;
for (i = 0; i < ap_daemons_limit; ++i) {
int any_dying_threads = 0;
int idle_thread_addition = 0;
for (j = 0; j < ap_threads_per_child; j++) {
++free_length;
if (!all_dead_threads) {
last_non_dead = i;
if (!any_dying_threads) {
if (free_length == 0) {
static int reported = 0;
if (!reported) {
"or Min/MaxSpareThreads), "
for (i = 0; i < free_length; ++i) {
int child_slot;
if (child_slot >= 0) {
for (i = 0; i < ap_threads_per_child; i++)
else if (is_graceful) {
else if (remaining_children_to_start) {
ap_server_conf = s;
ap_server_conf = s;
if (!is_graceful) {
set_signals();
if (!is_graceful) {
if (shutdown_pending) {
if (one_process) {
if (is_graceful) {
for (i = 0; i < ap_daemons_limit;) {
for (i = 0; i < ap_daemons_limit; ++i) {
for (j = 0; j < ap_threads_per_child; j++) {
if (!is_graceful) {
static int restart_num = 0;
int no_detach = 0;
is_graceful = 0;
apr_detach();
ap_extended_status = 0;
static void mpmt_pthread_hooks(void)
one_process = 0;
return err;
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
if (min_spare_threads <= 0) {
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "WARNING: Require MaxClients > 0, setting to 1");
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
const char *fname;
return err;
return NULL;
{ NULL }