mpm_common.h revision b5435778a96719686b741361cd52af2f3ed3f8e8
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * applicable.
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers *
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * Licensed under the Apache License, Version 2.0 (the "License");
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * you may not use this file except in compliance with the License.
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * You may obtain a copy of the License at
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers *
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * http://www.apache.org/licenses/LICENSE-2.0
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers *
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * Unless required by applicable law or agreed to in writing, software
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * distributed under the License is distributed on an "AS IS" BASIS,
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * See the License for the specific language governing permissions and
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * limitations under the License.
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann */
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann/* The purpose of this file is to store the code that MOST mpm's will need
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann * this does not mean a function only goes into this file if every MPM needs
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann * it. It means that if a function is needed by more than one MPM, and
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann * future maintenance would be served by making the code common, then the
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * function belongs here.
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann *
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * This is going in src/main because it is not platform specific, it is
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * specific to multi-process servers, but NOT to Unix. Which is why it
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * does not belong in src/os/unix
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann */
ba76ee29bc02879fb42c048132af8889b00220d5David Herrmann
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann/**
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @file mpm_common.h
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @brief Multi-Processing Modules functions
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann *
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * @defgroup APACHE_MPM Multi-Processing Modules
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * @ingroup APACHE
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * @{
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek */
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#ifndef APACHE_MPM_COMMON_H
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek#define APACHE_MPM_COMMON_H
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek#include "ap_config.h"
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#if APR_HAVE_NETINET_TCP_H
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#include <netinet/tcp.h> /* for TCP_NODELAY */
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#endif
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek#include "mpm.h"
24a4501d70e60f15c074e9f5bda46a7fbc5735e5Peter Hutterer
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek#ifdef __cplusplus
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmekextern "C" {
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek#endif
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek/* The maximum length of the queue of pending connections, as defined
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * by listen(2). Under some systems, it should be increased if you
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * are experiencing a heavy TCP SYN flood attack.
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek *
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * It defaults to 511 instead of 512 because some systems store it
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek * 255 when truncated.
fa9d4be3f1f4a792b2f3624c2a08fe9cc6ce6e54Zbigniew Jędrzejewski-Szmek */
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#ifndef DEFAULT_LISTENBACKLOG
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define DEFAULT_LISTENBACKLOG 511
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers/* Signal used to gracefully restart */
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt#define AP_SIG_GRACEFUL SIGUSR1
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann/* Signal used to gracefully restart (without SIG prefix) */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#define AP_SIG_GRACEFUL_SHORT USR1
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/* Signal used to gracefully restart (as a quoted string) */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define AP_SIG_GRACEFUL_STRING "SIGUSR1"
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt/* Signal used to gracefully stop */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define AP_SIG_GRACEFUL_STOP SIGWINCH
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/* Signal used to gracefully stop (without SIG prefix) */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define AP_SIG_GRACEFUL_STOP_SHORT WINCH
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/* Signal used to gracefully stop (as a quoted string) */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define AP_SIG_GRACEFUL_STOP_STRING "SIGWINCH"
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Make sure all child processes that have been spawned by the parent process
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * have died. This includes process registered as "other_children".
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @warning This is only defined if the MPM defines
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * each time through the loop. If 0, give the process time to die
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * on its own before signalling it.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @tip This function requires that some macros are defined by the MPM: <pre>
42a9de1c2513aa348df369080cdd941ef4ab00abMartin Pitt * MPM_CHILD_PID -- Get the pid from the specified spot in the scoreboard
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * MPM_NOTE_CHILD_KILLED -- Note the child died in the scoreboard
84a122a008e06901ce2d1d3941864afce8fd5d15Kay Sievers * </pre>
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * @tip The MPM child processes which are reclaimed are those listed
90e633a7901060063e62bf53948c4c239a9f55d1Jason St. John * in the scoreboard as well as those currently registered via
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * ap_register_extra_mpm_process().
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pittvoid ap_reclaim_child_processes(int terminate);
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt#endif
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt/**
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * Catch any child processes that have been spawned by the parent process
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * which have exited. This includes processes registered as "other_children".
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * @warning This is only defined if the MPM defines
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @tip This function requires that some macros are defined by the MPM: <pre>
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * MPM_CHILD_PID -- Get the pid from the specified spot in the scoreboard
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * MPM_NOTE_CHILD_KILLED -- Note the child died in the scoreboard
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * </pre>
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @tip The MPM child processes which are relieved are those listed
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * in the scoreboard as well as those currently registered via
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * ap_register_extra_mpm_process().
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt */
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pittvoid ap_relieve_child_processes(void);
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt#endif
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann/**
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * Tell ap_reclaim_child_processes() and ap_relieve_child_processes() about
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * an MPM child process which has no entry in the scoreboard.
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * @warning This is only defined if the MPM defines
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * @param pid The process id of an MPM child process which should be
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * reclaimed when ap_reclaim_child_processes() is called.
c5b7838ddeae1fcd5c613ea15f04918b945823e5Martin Pitt * @tip If an extra MPM child process terminates prior to calling
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * ap_reclaim_child_processes(), remove it from the list of such processes
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * by calling ap_unregister_extra_mpm_process().
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannvoid ap_register_extra_mpm_process(pid_t pid);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#endif
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann/**
2dd30e7da94b32df03451df8cf602e9454a376cbKay Sievers * Unregister an MPM child process which was previously registered by a
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * call to ap_register_extra_mpm_process().
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @warning This is only defined if the MPM defines
1e091c1285b59d0fbab58e6e5113ad111bc08794Martin Pitt * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
1e091c1285b59d0fbab58e6e5113ad111bc08794Martin Pitt * @param pid The process id of an MPM child process which no longer needs to
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * be reclaimed.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @return 1 if the process was found and removed, 0 otherwise
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannint ap_unregister_extra_mpm_process(pid_t pid);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Determine if any child process has died. If no child process died, then
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * this process sleeps for the amount of time specified by the MPM defined
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * macro SCOREBOARD_MAINTENANCE_INTERVAL.
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @param status The return code if a process has died
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param ret The process id of the process that died
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param p The pool to allocate out of
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT
33e74db2667103e33f7e47277378612dcdbdfaa5Martin Pittvoid ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret,
e55edb22a71e67f01534d28f91c6aa27bba48fc1Martin Pitt apr_pool_t *p);
4e3deeedc15b03197d591850061316289245c9a9Martin Pitt#endif
90e633a7901060063e62bf53948c4c239a9f55d1Jason St. John
33e74db2667103e33f7e47277378612dcdbdfaa5Martin Pitt/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Log why a child died to the error log, if the child died without the
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * parent signalling it.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param pid The child that has died
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param status The status returned from ap_wait_or_timeout
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @return 0 on success, APEXIT_CHILDFATAL if MPM should terminate
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sieversint ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Turn off the nagle algorithm for the specified socket. The nagle algorithm
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers * says that we should delay sending partial packets in the hopes of getting
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * more data. There are bad interactions between persistent connections and
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Nagle's algorithm that have severe performance penalties.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param s The socket to disable nagle for.
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannvoid ap_sock_disable_nagle(apr_socket_t *s);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#else
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define ap_sock_disable_nagle(s) /* NOOP */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef HAVE_GETPWNAM
0c959b39175b126fdb70ae00de37ca6d9c8ca3a1Kay Sievers/**
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann * Convert a username to a numeric ID
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de Goede * @param name The name to convert
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de Goede * @return The user id corresponding to a name
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de Goede * @deffunc uid_t ap_uname2id(const char *name)
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de Goede */
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de GoedeAP_DECLARE(uid_t) ap_uname2id(const char *name);
fc1ae82cae69d8dbbd9e7a31938810a486fac782Hans de Goede#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef HAVE_GETGRNAM
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Convert a group name to a numeric ID
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @param name The name to convert
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @return The group id corresponding to a name
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @deffunc gid_t ap_gname2id(const char *name)
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_DECLARE(gid_t) ap_gname2id(const char *name);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#define AP_MPM_HARD_LIMITS_FILE APACHE_MPM_DIR "/mpm_default.h"
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_USES_POD
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieverstypedef struct ap_pod_t ap_pod_t;
42a9de1c2513aa348df369080cdd941ef4ab00abMartin Pitt
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversstruct ap_pod_t {
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers apr_file_t *pod_in;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers apr_file_t *pod_out;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers apr_pool_t *p;
42a9de1c2513aa348df369080cdd941ef4ab00abMartin Pitt};
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Open the pipe-of-death. The pipe of death is used to tell all child
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * processes that it is time to die gracefully.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param p The pool to use for allocating the pipe
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_DECLARE(apr_status_t) ap_mpm_pod_open(apr_pool_t *p, ap_pod_t **pod);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Check the pipe to determine if the process has been signalled to die.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_DECLARE(apr_status_t) ap_mpm_pod_check(ap_pod_t *pod);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * Close the pipe-of-death
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid HerrmannAP_DECLARE(apr_status_t) ap_mpm_pod_close(ap_pod_t *pod);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Write data to the pipe-of-death, signalling that one child process
aba248ee6b1eb10baf3d89eca2ad7569459af6abHans de Goede * should die.
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * @param p The pool to use when allocating any required structures.
aba248ee6b1eb10baf3d89eca2ad7569459af6abHans de Goede */
aba248ee6b1eb10baf3d89eca2ad7569459af6abHans de GoedeAP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod);
aba248ee6b1eb10baf3d89eca2ad7569459af6abHans de Goede
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * Write data to the pipe-of-death, signalling that all child process
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * should die.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param p The pool to use when allocating any required structures.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * @param num The number of child processes to kill
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/*
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * These data members are common to all mpms. Each new mpm
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * should either use the appropriate ap_mpm_set_* function
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * in their command table or create their own for custom or
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * OS specific needs. These should work for most.
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann */
3f42b51f21171a3166200af3d9966812f1ddd0f0Martin Pitt
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * The maximum number of requests each child thread or
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * process handles before dying off
42a9de1c2513aa348df369080cdd941ef4ab00abMartin Pitt */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
24119cf10c7ed58a8fc0851745149dcc6dd5757fStefan Brünsextern int ap_max_requests_per_child;
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannconst char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
24119cf10c7ed58a8fc0851745149dcc6dd5757fStefan Brüns const char *arg);
4f70555d76c90ffdc5a5e4f75bbc08b38022c911Zbigniew Jędrzejewski-Szmek#endif
24119cf10c7ed58a8fc0851745149dcc6dd5757fStefan Brüns
1f6d36f267186c0e3184bab4c7eca48481c6faabHui Wang/**
1f6d36f267186c0e3184bab4c7eca48481c6faabHui Wang * The filename used to store the process id.
d946bb53f94713241004810de92cc37f1e19c2d2Martin Pitt */
1f6d36f267186c0e3184bab4c7eca48481c6faabHui Wang#ifdef AP_MPM_WANT_SET_PIDFILE
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern const char *ap_pid_fname;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * The name of lockfile used when Apache needs to lock the accept() call.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_LOCKFILE
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern const char *ap_lock_fname;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * The system mutex implementation to use for the accept mutex.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern apr_lockmech_e ap_accept_lock_mech;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern const char ap_valid_accept_mutex_string[];
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy,
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann const char *arg);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/*
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann * Set the scorboard file.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_SCOREBOARD
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/*
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * The directory that the server changes directory to dump core.
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_COREDUMPDIR
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern char ap_coredump_dir[MAX_STRING_LEN];
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannextern int ap_coredumpdir_configured;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/**
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers * Set the timeout period for a graceful shutdown.
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern int ap_graceful_shutdown_timeout;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversconst char *ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND \
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_INIT_TAKE1("GracefulShutdownTimeout", ap_mpm_set_graceful_shutdown, NULL, \
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers RSRC_CONF, "Maximum time in seconds to wait for child " \
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers "processes to complete transactions during shutdown")
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SIGNAL_SERVER
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversint ap_signal_server(int *, apr_pool_t *);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmannvoid ap_mpm_rewrite_args(process_rec *);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern apr_uint32_t ap_max_mem_free;
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef AP_MPM_WANT_SET_STACKSIZE
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern apr_size_t ap_thread_stacksize;
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmekextern const char *ap_mpm_set_thread_stacksize(cmd_parms *cmd, void *dummy,
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmek const char *arg);
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmek#endif
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmek
b17de8449c3ce26031d5bb7dec1086b56e51ac9bDavid Herrmann#ifdef AP_MPM_WANT_FATAL_SIGNAL_HANDLER
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmekextern apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *pconf);
0787758d26337ec897d9553fe962678fbf0a0962Zbigniew Jędrzejewski-Szmekextern apr_status_t ap_fatal_signal_child_setup(server_rec *s);
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#if AP_ENABLE_EXCEPTION_HOOK
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sieversextern const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy,
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers const char *arg);
b26e4ced91d0ac0eabdce1c505228ccafc65a23fDavid Herrmann#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay SieversAP_DECLARE_HOOK(int,monitor,(apr_pool_t *p))
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#ifdef __cplusplus
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers}
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers#endif /* !APACHE_MPM_COMMON_H */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers/** @} */
aedc2eddd16e48d468e6ad0aea2caf00c7d37365Kay Sievers