dexter.c revision a72d21c8fa26402986e82b0caa0b14d1ca36ad21
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein/* ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * The Apache Software License, Version 1.1
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Copyright (c) 2000 The Apache Software Foundation. All rights
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * reserved.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Redistribution and use in source and binary forms, with or without
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * modification, are permitted provided that the following conditions
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 1. Redistributions of source code must retain the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 2. Redistributions in binary form must reproduce the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer in
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * the documentation and/or other materials provided with the
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * distribution.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 3. The end-user documentation included with the redistribution,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * if any, must include the following acknowledgment:
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * "This product includes software developed by the
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Apache Software Foundation (http://www.apache.org/)."
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Alternately, this acknowledgment may appear in the software itself,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * if and wherever such third-party acknowledgments normally appear.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 4. The names "Apache" and "Apache Software Foundation" must
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * not be used to endorse or promote products derived from this
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * software without prior written permission. For written
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * permission, please contact apache@apache.org.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 5. Products derived from this software may not be called "Apache",
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * nor may "Apache" appear in their name, without prior written
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * permission of the Apache Software Foundation.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * SUCH DAMAGE.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * This software consists of voluntary contributions made by many
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * individuals on behalf of the Apache Software Foundation. For more
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * information on the Apache Software Foundation, please see
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Portions of this software are based upon public domain software
f4c310fd2555c6faca1f980f00b161eadb089023gstein * originally written at the National Center for Supercomputing Applications,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * University of Illinois, Urbana-Champaign.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Actual definitions of config globals
000397350b42c6266351bd618fa07df929fa7c79gsteinstatic int threads_to_start = 0; /* Worker threads per child */
000397350b42c6266351bd618fa07df929fa7c79gsteinstatic int min_spare_threads = 0;
000397350b42c6266351bd618fa07df929fa7c79gsteinstatic int max_spare_threads = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int max_threads = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int workers_may_exit = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int num_listenfds = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * The max child slot ever assigned, preserved across restarts. Necessary
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * to deal with NumServers changes across SIGWINCH restarts. We use this
f4c310fd2555c6faca1f980f00b161eadb089023gstein * value to optimize routines that have to scan the entire child table.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * XXX - It might not be worth keeping this code in. There aren't very
f4c310fd2555c6faca1f980f00b161eadb089023gstein * many child processes in this MPM.
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* *Non*-shared http_main globals... */
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein/* one_process --- debugging mode variable; can be set from the command line
f4c310fd2555c6faca1f980f00b161eadb089023gstein * with the -X flag. If set, this gets you the child_main loop running
f4c310fd2555c6faca1f980f00b161eadb089023gstein * 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
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * 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
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * SIGHUP to the process group, ignoring it in the root process.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Continue through and you'll be fine.).
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmstatic int one_process = 0;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmstatic ap_pool_t *pchild; /* Pool for httpd child stuff */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic ap_pool_t *thread_pool_parent; /* Parent of per-thread pools */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int my_pid; /* Linux getpid() doesn't work except in main thread. Use
f4c310fd2555c6faca1f980f00b161eadb089023gstein this instead */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm/* Keep track of the number of worker threads currently active */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Keep track of the number of idle worker threads */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Locks for accept serialization */
de18a9e85398b9c79c422f578633ed56c2747bbbgstein#endif /* NO_SERIALIZED_ACCEPT */
de18a9e85398b9c79c422f578633ed56c2747bbbgsteinstatic const char *lock_fname;
de18a9e85398b9c79c422f578633ed56c2747bbbgsteinstatic pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
de18a9e85398b9c79c422f578633ed56c2747bbbgsteinAPI_EXPORT(const server_rec *) ap_get_server_conf(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* a clean exit from a child with proper cleanup */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* handle all varieties of core dumping signals */
000397350b42c6266351bd618fa07df929fa7c79gstein /* At this point we've got sig blocked, because we're still inside
000397350b42c6266351bd618fa07df929fa7c79gstein * the signal handler. When we leave the signal handler it will
000397350b42c6266351bd618fa07df929fa7c79gstein * be unblocked, and we'll take the signal... and coredump or whatever
000397350b42c6266351bd618fa07df929fa7c79gstein * is appropriate for this particular Unix. In addition the parent
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * will see the real signal we received -- whereas if we called
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * abort() here, the parent would only see SIGABRT.
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Connection structures and accounting...
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm/* volatile just in case */
10a4cdd68ef1ca0e54af296fe1d08ac00150c90bwrowestatic int volatile shutdown_pending;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int volatile restart_pending;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int volatile is_graceful;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * ap_start_shutdown() and ap_start_restart(), below, are a first stab at
f4c310fd2555c6faca1f980f00b161eadb089023gstein * functions to initiate shutdown or restart without relying on signals.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Previously this was initiated in sig_term() and restart() signal handlers,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * but we want to be able to start a shutdown/restart from other sources --
f4c310fd2555c6faca1f980f00b161eadb089023gstein * e.g. on Win32, from the service manager. Now the service manager can
f4c310fd2555c6faca1f980f00b161eadb089023gstein * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that
f4c310fd2555c6faca1f980f00b161eadb089023gstein * these functions can also be called by the child processes, since global
f4c310fd2555c6faca1f980f00b161eadb089023gstein * variables are no longer used to pass on the required action to the parent.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * These should only be called from the parent process itself, since the
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * parent process will use the shutdown_pending and restart_pending variables
f4c310fd2555c6faca1f980f00b161eadb089023gstein * to determine whether to shutdown or restart. The child process should
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * call signal_parent() directly to tell the parent to die -- this will
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * cause neither of those variable to be set, which the parent will
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * assume means something serious is wrong (which it will be, for the
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * child to force an exit) and so do an exit anyway.
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein /* Um, is this _probably_ not an error, if the user has
709df1e1c2e1710570f8cb4209497e88662829c3gstein * tried to do a shutdown twice quickly, so we won't
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * worry about reporting it.
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* do a graceful restart if graceful == 1 */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Probably not an error - don't bother reporting it */
9f18c80269be35c0b5653e84b0db0a24044722c4gsteinstatic void set_signals(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGSEGV)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGBUS)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABORT)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABRT)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGILL)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we want to ignore HUPs and WINCH while we're busy processing one */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGBUS */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGABORT */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGABRT */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGILL */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGXCPU */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGXFSZ */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGHUP */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGWINCH */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /* SIGPIPE */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void process_child_status(ap_proc_t *pid, ap_wait_t status)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* Child died... if it died due to a fatal error,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * we should simply bail out.
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Child %ld returned a Fatal error... \n"
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Apache is exiting!",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "child pid %ld exit signal %s (%d), "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "possible coredump in %s",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "child pid %ld exit signal %s (%d)",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "child pid %ld exit signal %d",
d839a9822ee53ce00da24c15f2d9fe054233d342gstein/*****************************************************************
d839a9822ee53ce00da24c15f2d9fe054233d342gstein * Here follows a long bunch of generic server bookkeeping stuff...
d839a9822ee53ce00da24c15f2d9fe054233d342gstein#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void sock_disable_nagle(int s)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* The Nagle algorithm says that we should delay sending partial
f4c310fd2555c6faca1f980f00b161eadb089023gstein * packets in hopes of getting more data. We don't want to do
f4c310fd2555c6faca1f980f00b161eadb089023gstein * this; we are not telnet. There are bad interactions between
f4c310fd2555c6faca1f980f00b161eadb089023gstein * persistent connections and Nagle's algorithm that have very severe
f4c310fd2555c6faca1f980f00b161eadb089023gstein * performance penalties. (Failing to disable Nagle is not much of a
f4c310fd2555c6faca1f980f00b161eadb089023gstein * problem with simple HTTP.)
f4c310fd2555c6faca1f980f00b161eadb089023gstein * In spite of these problems, failure here is not a shooting offense.
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
f4c310fd2555c6faca1f980f00b161eadb089023gstein sizeof(int)) < 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "setsockopt: (TCP_NODELAY)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX - Does this really work? - Manoj */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Child process main loop.
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "new file descriptor %d is too large; you probably need "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "to rebuild Apache with a larger FD_SETSIZE "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "(currently %d)",
f4c310fd2555c6faca1f980f00b161eadb089023gstein current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void *worker_thread(void *);
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Starts a thread as long as we're below max_threads */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmstatic int start_thread(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (pthread_create(&thread, &worker_thread_attr, worker_thread,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "pthread_create: unable to create worker thread");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* In case system resources are maxxed out, we don't want
f4c310fd2555c6faca1f980f00b161eadb089023gstein Apache running away with the CPU trying to fork over and
f4c310fd2555c6faca1f980f00b161eadb089023gstein over and over again if we exit. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein static int reported = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "server reached MaxThreadsPerChild setting, consider raising the"
f4c310fd2555c6faca1f980f00b161eadb089023gstein " MaxThreadsPerChild or NumServers settings");
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm/* Sets workers_may_exit if we received a character on the pipe_of_death */
50bd75672ef114fb839dd9643c192b432fdf344cgsteinstatic void check_pipe_of_death(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* It lost the lottery. It must continue to suffer
f4c310fd2555c6faca1f980f00b161eadb089023gstein * through a life of servitude. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* It won the lottery (or something else is very
f4c310fd2555c6faca1f980f00b161eadb089023gstein * wrong). Embrace death with open arms. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* idle_thread_count should be incremented before starting a worker_thread */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_pool_t *ptrans; /* Pool for per-transaction stuff */
f4c310fd2555c6faca1f980f00b161eadb089023gstein long conn_id = child_num * HARD_THREAD_LIMIT + thread_num;
f4c310fd2555c6faca1f980f00b161eadb089023gstein for(n=0 ; n <= num_listenfds ; ++n)
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein ap_add_poll_socket(pollset, listenfds[n], APR_POLLIN);
f4c310fd2555c6faca1f980f00b161eadb089023gstein workers_may_exit |= (max_requests_per_child != 0) && (requests_this_child <= 0);
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex)))
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein "ap_lock failed. Attempting to shutdown "
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein "process gracefully.");
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein /* ap_poll() will only return errors in catastrophic
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein * circumstances. Let's try exiting gracefully, for now. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ERR, srv, (const server_rec *)
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein /* A process got a signal on the shutdown pipe. Check if we're
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * the lucky process to die. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* find a listener */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX: Should we check for POLLERR? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_get_revents(&event, listenfds[curr_pollfd], pollset);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "ap_accept");
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "ap_unlock failed. Attempting to shutdown "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "process gracefully.");
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "ap_unlock failed. Attempting to shutdown "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "process gracefully.");
f4c310fd2555c6faca1f980f00b161eadb089023gstein worker_thread_free_ids[worker_thread_count] = thread_num;
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* All the threads have exited, now finish the shutdown process
f4c310fd2555c6faca1f980f00b161eadb089023gstein * by signalling the sigwait thread */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*stuff to do before we switch id's, so we have permissions.*/
f4c310fd2555c6faca1f980f00b161eadb089023gstein rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Couldn't initialize cross-process lock in child");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*done with init critical section */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* All threads should mask signals out, accoring to sigwait(2) man page */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (sigprocmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "pthread_sigmask");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Set up the pollfd array */
f4c310fd2555c6faca1f980f00b161eadb089023gstein listenfds = ap_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 1));
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_socket_from_file(&listenfds[0], pipe_of_death_in);
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Setup worker threads */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < max_threads; i++) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein pthread_mutex_init(&worker_thread_count_mutex, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein pthread_attr_setdetachstate(&worker_thread_attr, &on);
f4c310fd2555c6faca1f980f00b161eadb089023gstein pthread_attr_setdetachstate(&worker_thread_attr, PTHREAD_CREATE_DETACHED);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* We are creating worker threads right now */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i=0; i < threads_to_start; i++) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* start_thread shouldn't fail here */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This thread will be the one responsible for handling signals */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int make_child(server_rec *s, int slot, time_t now)
f4c310fd2555c6faca1f980f00b161eadb089023gstein "fork: Unable to fork new process");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* In case system resources are maxxed out, we don't want
f4c310fd2555c6faca1f980f00b161eadb089023gstein Apache running away with the CPU trying to fork over and
f4c310fd2555c6faca1f980f00b161eadb089023gstein over and over again. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* By default, AIX binds to a single processor. This bit unbinds
f4c310fd2555c6faca1f980f00b161eadb089023gstein children which will then bind to another CPU.
f4c310fd2555c6faca1f980f00b161eadb089023gstein int status = bindprocessor(BINDPROCESS, (int)getpid(),
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_server_conf, "processor unbind failed %d", status);
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX - For an unthreaded server, a signal handler will be necessary
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_signal(SIGTERM, just_die);
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* start up a bunch of children */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; number_to_start && i < num_daemons; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein * spawn_rate is the number of children that will be spawned on the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * next maintenance cycle if there aren't enough servers. It is
f4c310fd2555c6faca1f980f00b161eadb089023gstein * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
f4c310fd2555c6faca1f980f00b161eadb089023gstein * without the need to spawn.
83719c22db4a6d0575bb4f7f34382d7b185a6f74gsteinstatic void perform_child_maintenance(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* initialize the free_list */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < num_daemons; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (i >= ap_max_daemons_limit && free_length >= spawn_rate) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < free_length; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* the next time around we want to spawn twice as many if this
f4c310fd2555c6faca1f980f00b161eadb089023gstein * wasn't good enough, but not if we've just done a graceful
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void server_main_loop(int remaining_children_to_start)
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* non-fatal death... note that it's gone in the child table and
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * clean out the status table. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < ap_max_daemons_limit; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (j = 0; j < HARD_THREAD_LIMIT; j++) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_dexter_force_reset_connection_status(i * HARD_THREAD_LIMIT + j);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* we're still doing a 1-for-1 replacement of dead
f4c310fd2555c6faca1f980f00b161eadb089023gstein * children with new children
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* handled */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* Great, we've probably just lost a slot in the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * child table. Somehow we don't know about this
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "long lost child came home! (pid %ld)",
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Don't perform idle maintenance when a child dies,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * only do it when there's a timeout. Remember only a
f4c310fd2555c6faca1f980f00b161eadb089023gstein * finite number of children can die, and it's pretty
f4c310fd2555c6faca1f980f00b161eadb089023gstein * pathological for a lot to die suddenly.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we hit a 1 second timeout in which none of the previous
f4c310fd2555c6faca1f980f00b161eadb089023gstein * generation of children needed to be reaped... so assume
f4c310fd2555c6faca1f980f00b161eadb089023gstein * they're all done, and pick up the slack if any is left.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* In any event we really shouldn't do the code below because
f4c310fd2555c6faca1f980f00b161eadb089023gstein * few of the servers we just started are in the IDLE state
f4c310fd2555c6faca1f980f00b161eadb089023gstein * yet, so we'd mistakenly create an extra server.
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((rv = ap_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf))
f4c310fd2555c6faca1f980f00b161eadb089023gstein "ap_create_pipe (pipe_of_death)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((rv = ap_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) {
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein "ap_set_pipe_timeout (pipe_of_death)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((num_listenfds = setup_listeners(ap_server_conf)) < 1) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "no listening sockets available, shutting down");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Initialize cross-process accept lock */
f4c310fd2555c6faca1f980f00b161eadb089023gstein rv = SAFE_ACCEPT(ap_create_lock(&process_accept_mutex, APR_MUTEX,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Couldn't create cross-process lock");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Initialize the child table */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < HARD_SERVER_LIMIT; i++) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* If we're doing a graceful_restart then we're going to see a lot
f4c310fd2555c6faca1f980f00b161eadb089023gstein * of children exiting immediately when we get into the main loop
f4c310fd2555c6faca1f980f00b161eadb089023gstein * below (because we just sent them SIGWINCH). This happens pretty
f4c310fd2555c6faca1f980f00b161eadb089023gstein * rapidly... and for each one that exits we'll start a new one until
f4c310fd2555c6faca1f980f00b161eadb089023gstein * we reach at least daemons_min_free. But we may be permitted to
f4c310fd2555c6faca1f980f00b161eadb089023gstein * start more than that, so we'll just keep track of how many we're
f4c310fd2555c6faca1f980f00b161eadb089023gstein * supposed to start up without the 1 second penalty between each fork.
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* give the system some time to recover before kicking into
7281ea331999debdc337b02ce37a3169e0e033a2gstein * exponential mode */
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, ap_server_conf,
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe "%s configured -- resuming normal operations",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Time to gracefully shut down:
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Kill child processes, tell them to call child_exit, etc...
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "killpg SIGTERM");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_reclaim_child_processes(1); /* Start with SIGTERM */
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,
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* we've been told to restart */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* not worth thinking about */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "SIGWINCH received. Doing graceful restart");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This is mostly for debugging... so that we know what is still
f4c310fd2555c6faca1f980f00b161eadb089023gstein * gracefully dealing with existing request.
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < num_daemons; ++i) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* give the children the signal to die */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (i = 0; i < num_daemons;) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((rv = ap_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "write pipe_of_death");
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Kill 'em all. Since the child acts the same on the parents SIGTERM
f4c310fd2555c6faca1f980f00b161eadb089023gstein * and a SIGHUP, we may as well use the same signal, because some user
f4c310fd2555c6faca1f980f00b161eadb089023gstein * pthreads are stealing signals from us left and right.
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "killpg SIGTERM");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_reclaim_child_processes(1); /* Start with SIGTERM */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_server_conf, "SIGHUP received. Attempting to restart");
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp)
f4c310fd2555c6faca1f980f00b161eadb089023gstein static int restart_num = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* sigh, want this only the second time around */
f4c310fd2555c6faca1f980f00b161eadb089023gstein max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void dexter_hooks(void)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_hook_pre_config(dexter_pre_config, NULL, NULL, AP_HOOK_MIDDLE);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein return "PidFile directive not allowed in <VirtualHost>";
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_num_daemons (cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: NumServers of %d exceeds compile time limit "
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein " lowering NumServers to %d. To increase, please "
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein " HARD_SERVER_LIMIT define in %s.",
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: Require NumServers > 0, setting to 1");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_threads_to_start (cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: StartThreads of %d exceeds compile time"
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein " lowering StartThreads to %d. To increase, please"
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein " HARD_THREAD_LIMIT define in %s.",
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: Require StartThreads > 0, setting to 1");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: detected MinSpareThreads set to non-positive.");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Resetting to 1 to avoid almost certain Apache failure.");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Please read the documentation.");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: detected MinSpareThreads set higher than");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
bbba27074551817d7c6a606c4362965c26a0777egsteinstatic const char *set_max_threads(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "WARNING: detected MaxThreadsPerChild set higher than");
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_maintain_connection_status(cmd_parms *cmd,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinstatic const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg)
bbba27074551817d7c6a606c4362965c26a0777egstein const char *fname;
bbba27074551817d7c6a606c4362965c26a0777egstein const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) ||
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "A file for logging the server process ID"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "A file for Apache to maintain runtime process management information"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "The lockfile used when Apache needs to lock the accept() call"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("NumServers", set_num_daemons, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Number of children alive at the same time"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("StartThreads", set_threads_to_start, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Number of threads each child creates"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Minimum number of idle threads per child, to handle request spikes"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Maximum number of idle threads per child"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("MaxThreadsPerChild", set_max_threads, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Maximum number of threads per child"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Maximum number of requests a particular child serves before dying."),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_FLAG("ConnectionStatus", set_maintain_connection_status, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "Whether or not to maintain status information on current connections"),
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gsteinAP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
c7548bcd69fbe1338ad855ba44f0b2b774e57bd8gstein "The location of the directory Apache changes to before dumping core"),