mpm_common.h revision 7c7372abe2484e7fcf81937b93496d1246e5b816
97a9a944b5887e91042b019776c41d5dd74557aferikabele/* ====================================================================
97a9a944b5887e91042b019776c41d5dd74557aferikabele * The Apache Software License, Version 1.1
97a9a944b5887e91042b019776c41d5dd74557aferikabele *
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * Copyright (c) 2000 The Apache Software Foundation. All rights
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * reserved.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive *
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Redistribution and use in source and binary forms, with or without
5a58787efeb02a1c3f06569d019ad81fd2efa06end * modification, are permitted provided that the following conditions
5a58787efeb02a1c3f06569d019ad81fd2efa06end * are met:
5a58787efeb02a1c3f06569d019ad81fd2efa06end *
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 1. Redistributions of source code must retain the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
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.
5a58787efeb02a1c3f06569d019ad81fd2efa06end *
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.
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd *
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.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung *
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 *
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 * ====================================================================
f8396ed8364b56ec8adeaa49cac35a929758a29eslive *
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 * <http://www.apache.org/>.
5a58787efeb02a1c3f06569d019ad81fd2efa06end *
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.
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl */
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
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 *
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
117c1f888a14e73cdd821dc6c23eb0411144a41cnd */
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
117c1f888a14e73cdd821dc6c23eb0411144a41cnd#ifndef APACHE_MPM_COMMON_H
117c1f888a14e73cdd821dc6c23eb0411144a41cnd#define APACHE_MPM_COMMON_H
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
87ffb6e33f3cbef3b9bb406cc2d27039fa336eaatrawick#include "ap_config_auto.h"
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl
5a58787efeb02a1c3f06569d019ad81fd2efa06end#ifdef HAVE_NETINET_TCP_H
5a58787efeb02a1c3f06569d019ad81fd2efa06end#include <netinet/tcp.h> /* for TCP_NODELAY */
5a58787efeb02a1c3f06569d019ad81fd2efa06end#endif
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end#ifdef __cplusplus
5a58787efeb02a1c3f06569d019ad81fd2efa06endextern "C" {
654d8eb036bedc99e90e11910ee02d3421417697rbowen#endif
5a58787efeb02a1c3f06569d019ad81fd2efa06end
5a58787efeb02a1c3f06569d019ad81fd2efa06end/**
5a58787efeb02a1c3f06569d019ad81fd2efa06end * @package Multi-Processing Modules functions
5a58787efeb02a1c3f06569d019ad81fd2efa06end */
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick/* The maximum length of the queue of pending connections, as defined
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * by listen(2). Under some systems, it should be increased if you
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * are experiencing a heavy TCP SYN flood attack.
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick *
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * It defaults to 511 instead of 512 because some systems store it
654d8eb036bedc99e90e11910ee02d3421417697rbowen * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * 255 when truncated.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#ifndef DEFAULT_LISTENBACKLOG
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive#define DEFAULT_LISTENBACKLOG 511
97a9a944b5887e91042b019776c41d5dd74557aferikabele#endif
654d8eb036bedc99e90e11910ee02d3421417697rbowen
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive/**
97a9a944b5887e91042b019776c41d5dd74557aferikabele * Make sure all child processes that have been spawned by the parent process
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * have died. This includes process registered as "other_children".
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive * @warning This is only defined if the MPM defines
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive * MPM_NEEDS_RECLAIM_CHILD_PROCESS
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM
ffb01336be79c64046b636e59fa8ddca8ec029edsf * each time through the loop. If 0, give the process time to die
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * on its own before signalling it.
ffb01336be79c64046b636e59fa8ddca8ec029edsf * @tip This function requires that some macros are defined by the MPM: <PRE>
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * MPM_SYNC_CHILD_TABLE -- sync the scoreboard image between child and parent
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * MPM_CHILD_PID -- Get the pid from the specified spot in the scoreboard
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * MPM_NOTE_CHILD_KILLED -- Note the child died in the scoreboard
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick */
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawickvoid ap_reclaim_child_processes(int terminate);
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick/**
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * Determine if any child process has died. If no child process died, then
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * this process sleeps for the amount of time specified by the MPM defined
ffb01336be79c64046b636e59fa8ddca8ec029edsf * macro SCOREBOARD_MAINTENANCE_INTERVAL.
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * @param status The return code if a process has died
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * @param ret The process id of the process that died
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * @param p The pool to allocate out of
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick */
77c77cf89621f21c8e2bbad63058b5eaa5f88d4ajimvoid ap_wait_or_timeout(apr_wait_t *status, apr_proc_t *ret, apr_pool_t *p);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf/**
ced7ef1f8c0df1805da0e87dbc5a1b6282910573nd * Log why a child died to the error log, if the child died without the
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * parent signalling it.
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * @param pid The child that has died
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * @param status The status returned from ap_wait_or_timeout
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf */
ced7ef1f8c0df1805da0e87dbc5a1b6282910573ndvoid ap_process_child_status(apr_proc_t *pid, apr_wait_t status);
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick/**
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf * Turn off the nagle algorithm for the specified socket. The nagle algorithm
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf * says that we should delay sending partial packets in the hopes of getting
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * more data. There are bad interactions between persistent connections and
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * Nagle's algorithm that have severe performance penalties.
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * @param s The socket to disable nagle for.
ffb01336be79c64046b636e59fa8ddca8ec029edsf */
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawickvoid ap_sock_disable_nagle(apr_socket_t *s);
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive#else
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive#define ap_sock_disable_nagle(s) /* NOOP */
97a9a944b5887e91042b019776c41d5dd74557aferikabele#endif
92510838f2eb125726e15c5eb4f7a23c7a0396e4slive
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd/**
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawick * Convert a username to a numeric ID
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd * @param name The name to convert
ffb01336be79c64046b636e59fa8ddca8ec029edsf * @return The user id corresponding to a name
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd * @deffunc uid_t ap_uname2id(const char *name)
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd */
8a6d5edcb07aeccca7afba02a17dd6904d6b206ctrawickAP_DECLARE(uid_t) ap_uname2id(const char *name);
ea8a727ff298d2f5368b55b7ae8d87091ae106e7nd/**
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * Convert a group name to a numeric ID
e8d485701957d5c6de870111c112e168a894d49and * @param name The name to convert
e8d485701957d5c6de870111c112e168a894d49and * @return The group id corresponding to a name
654d8eb036bedc99e90e11910ee02d3421417697rbowen * @deffunc gid_t ap_gname2id(const char *name)
654d8eb036bedc99e90e11910ee02d3421417697rbowen */
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7sliveAP_DECLARE(gid_t) ap_gname2id(const char *name);
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive
9bcfc3697a91b5215893a7d0206865b13fc72148nd#define AP_MPM_HARD_LIMITS_FILE "src/" APACHE_MPM_DIR "/mpm_default.h"
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive#ifdef __cplusplus
06ba4a61654b3763ad65f52283832ebf058fdf1cslive}
4a31db3c3a0202003c1b9f87affa7cc143e120e5sf#endif
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive
9b6a3a558cc90ffdaa0b50bd02546ffec424ded7slive#endif /* !APACHE_MPM_COMMON_H */
709e3a21ba73b8433462959cd56c773454b34441trawick