mpm_common.c revision 5a63340978acb9dd7e87724be57d2bde1cf1f629
97a9a944b5887e91042b019776c41d5dd74557aferikabele/* ====================================================================
97a9a944b5887e91042b019776c41d5dd74557aferikabele * The Apache Software License, Version 1.1
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * reserved.
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Redistribution and use in source and binary forms, with or without
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * modification, are permitted provided that the following conditions
5a58787efeb02a1c3f06569d019ad81fd2efa06end * are met:
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 1. Redistributions of source code must retain the above copyright
2e545ce2450a9953665f701bb05350f0d3f26275nd * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 2. Redistributions in binary form must reproduce the above copyright
5a58787efeb02a1c3f06569d019ad81fd2efa06end * notice, this list of conditions and the following disclaimer in
5a58787efeb02a1c3f06569d019ad81fd2efa06end * the documentation and/or other materials provided with the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * distribution.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * 3. The end-user documentation included with the redistribution,
5a58787efeb02a1c3f06569d019ad81fd2efa06end * if any, must include the following acknowledgment:
5a58787efeb02a1c3f06569d019ad81fd2efa06end * "This product includes software developed by the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Apache Software Foundation (http://www.apache.org/)."
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * Alternately, this acknowledgment may appear in the software itself,
5a58787efeb02a1c3f06569d019ad81fd2efa06end * if and wherever such third-party acknowledgments normally appear.
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * 4. The names "Apache" and "Apache Software Foundation" must
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * not be used to endorse or promote products derived from this
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd * software without prior written permission. For written
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * permission, please contact apache@apache.org.
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * 5. Products derived from this software may not be called "Apache",
5a58787efeb02a1c3f06569d019ad81fd2efa06end * nor may "Apache" appear in their name, without prior written
5a58787efeb02a1c3f06569d019ad81fd2efa06end * permission of the Apache Software Foundation.
5a58787efeb02a1c3f06569d019ad81fd2efa06end * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
5a58787efeb02a1c3f06569d019ad81fd2efa06end * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5a58787efeb02a1c3f06569d019ad81fd2efa06end * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5a58787efeb02a1c3f06569d019ad81fd2efa06end * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b21197dc8e6b8c764fdcc24d4bae8b0eebb6bc4end * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * SUCH DAMAGE.
97a9a944b5887e91042b019776c41d5dd74557aferikabele * ====================================================================
ffb01336be79c64046b636e59fa8ddca8ec029edsf * This software consists of voluntary contributions made by many
f8396ed8364b56ec8adeaa49cac35a929758a29eslive * individuals on behalf of the Apache Software Foundation. For more
f8396ed8364b56ec8adeaa49cac35a929758a29eslive * information on the Apache Software Foundation, please see
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Portions of this software are based upon public domain software
5a58787efeb02a1c3f06569d019ad81fd2efa06end * originally written at the National Center for Supercomputing Applications,
deeee6bb6fd94c0ba5f3730b58abd9d299c89ccdnd * University of Illinois, Urbana-Champaign.
117c1f888a14e73cdd821dc6c23eb0411144a41cnd/* The purpose of this file is to store the code that MOST mpm's will need
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf * this does not mean a function only goes into this file if every MPM needs
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * it. It means that if a function is needed by more than one MPM, and
ffb01336be79c64046b636e59fa8ddca8ec029edsf * future maintenance would be served by making the code common, then the
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * function belongs here.
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * This is going in src/main because it is not platform specific, it is
2bc7f1cf720973a67f8ff7a8d523e40569ae5b6cnd * specific to multi-process servers, but NOT to Unix. Which is why it
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * does not belong in src/os/unix
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf /* don't want to hold up progress any more than
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd * necessary, but we need to allow children a few moments to exit.
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * Set delay with an exponential backoff.
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick /* now see who is done */
77c77cf89621f21c8e2bbad63058b5eaa5f88d4ajim for (i = 0; i < max_daemons; ++i) {
b244bbf442a0aea3dc397b4d0d751f4716c5891dnd switch (tries) {
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic /* ok, now it's being annoying */
4aa603e6448b99f9371397d439795c91a93637eand "child process %ld still did not exit, "
f0fa55ff14fa0bf8fd72d989f6625de6dc3260c8igalic "sending a SIGTERM",
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive /* die child scum */
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive "child process %ld still did not exit, "
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive "sending a SIGKILL",
709e3a21ba73b8433462959cd56c773454b34441trawick /* sending a SIGKILL kills the entire team on BeOS, and as
709e3a21ba73b8433462959cd56c773454b34441trawick * httpd thread is part of that team it removes any chance
709e3a21ba73b8433462959cd56c773454b34441trawick * of ever doing a restart. To counter this I'm changing to
709e3a21ba73b8433462959cd56c773454b34441trawick * use a kinder, gentler way of killing a specific thread
709e3a21ba73b8433462959cd56c773454b34441trawick * that is just as effective.
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd /* gave it our best shot, but alas... If this really
e1e8390280254f7f0580d701e583f670643d4f3fnilgun * is a child we are trying to kill and it really hasn't
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * exited, we will likely fail to bind to the port
727872d18412fc021f03969b8641810d8896820bhumbedooh * after the restart.
0d0ba3a410038e179b695446bb149cce6264e0abnd "could not make child process %ld exit, "
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh "attempting to continue anyway",
0d0ba3a410038e179b695446bb149cce6264e0abnd /* nothing left to wait for */
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd#endif /* AP_MPM_WANT_RECLAIM_CHILD_PROCESSES */
#ifndef INTERVAL_OF_WRITABLE_PROBES
static int wait_or_timeout_counter;
apr_pool_t *p)
#ifdef NEED_WAITPID
return status;
0, ap_server_conf,
return APEXIT_CHILDFATAL;
switch (signum) {
case SIGTERM:
case SIGHUP:
case AP_SIG_GRACEFUL:
case SIGKILL:
0, ap_server_conf,
0, ap_server_conf,
#ifdef HAVE_GETPWNAM
#ifdef HAVE_GETGRNAM
#ifndef HAVE_INITGROUPS
#if defined(QNX) || defined(MPE) || defined(BEOS) || defined(_OSD_POSIX) || defined(TPF) || defined(__TANDEM) || defined(OS2) || defined(WIN32) || defined(NETWARE)
struct group *g;
int index = 0;
setgrent();
char **names;
endgrent();
#ifdef AP_MPM_USES_POD
return rv;
(*pod)->p = p;
return APR_SUCCESS;
return APR_SUCCESS;
return rv;
return AP_NORESTART;
return rv;
return rv;
return APR_SUCCESS;
return rv;
apr_pool_t *p;
return rv;
return rv;
return rv;
apr_pool_destroy(p);
return rv;
return rv;
#ifdef AP_MPM_WANT_SET_PIDFILE
const char *arg)
return err;
return NULL;
#ifdef AP_MPM_WANT_SET_SCOREBOARD
const char *arg)
return err;
return NULL;
#ifdef AP_MPM_WANT_SET_LOCKFILE
const char *arg)
return err;
return NULL;
#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
int ap_max_requests_per_child = 0;
const char *arg)
return err;
return NULL;
#ifdef AP_MPM_WANT_SET_COREDUMPDIR
const char *arg)
const char *fname;
return err;
if (!fname) {
return NULL;
const char ap_valid_accept_mutex_string[] =
void *dummy,
const char *arg)
return err;
return NULL;
#ifdef AP_MPM_WANT_SIGNAL_SERVER
static const char *dash_k_arg;
int running = 0;
int have_pid_file = 0;
const char *status;
*exit_status = 0;
otherpid);
if (running) {
if (!running) {
if (!running) {
if (!running) {
const char *optarg;
int fixed_args;
if (!dash_k_arg) {
if (optarg) {
if (dash_k_arg) {