mpm_common.h revision 0807f6da6091b748ab47c21ba66252fe8da2a966
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* Licensed to the Apache Software Foundation (ASF) under one or more
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * contributor license agreements. See the NOTICE file distributed with
240b85022b73af58a6d971cd3d05d54037d8f682nd * this work for additional information regarding copyright ownership.
240b85022b73af58a6d971cd3d05d54037d8f682nd * The ASF licenses this file to You under the Apache License, Version 2.0
240b85022b73af58a6d971cd3d05d54037d8f682nd * (the "License"); you may not use this file except in compliance with
240b85022b73af58a6d971cd3d05d54037d8f682nd * the License. You may obtain a copy of the License at
240b85022b73af58a6d971cd3d05d54037d8f682nd * Unless required by applicable law or agreed to in writing, software
240b85022b73af58a6d971cd3d05d54037d8f682nd * distributed under the License is distributed on an "AS IS" BASIS,
240b85022b73af58a6d971cd3d05d54037d8f682nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
240b85022b73af58a6d971cd3d05d54037d8f682nd * See the License for the specific language governing permissions and
240b85022b73af58a6d971cd3d05d54037d8f682nd * limitations under the License.
240b85022b73af58a6d971cd3d05d54037d8f682nd/* The purpose of this file is to store the code that MOST mpm's will need
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * this does not mean a function only goes into this file if every MPM needs
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * it. It means that if a function is needed by more than one MPM, and
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * future maintenance would be served by making the code common, then the
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * function belongs here.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * This is going in src/main because it is not platform specific, it is
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * specific to multi-process servers, but NOT to Unix. Which is why it
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * does not belong in src/os/unix
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @brief Multi-Processing Modules functions
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @defgroup APACHE_MPM Multi-Processing Modules
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @ingroup APACHE
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregamesextern "C" {
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* The maximum length of the queue of pending connections, as defined
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * by listen(2). Under some systems, it should be increased if you
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * are experiencing a heavy TCP SYN flood attack.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * It defaults to 511 instead of 512 because some systems store it
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * 255 when truncated.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* Signal used to gracefully restart */
cd2e0fb5f8e86eecb278e9d623f4c272d96f5e3ctrawick/* Signal used to gracefully restart (without SIG prefix) */
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* Signal used to gracefully restart (as a quoted string) */
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* Signal used to gracefully stop */
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames/* Signal used to gracefully stop (without SIG prefix) */
cd2e0fb5f8e86eecb278e9d623f4c272d96f5e3ctrawick/* Signal used to gracefully stop (as a quoted string) */
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Make sure all child processes that have been spawned by the parent process
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * have died. This includes process registered as "other_children".
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * each time through the loop. If 0, give the process time to die
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * on its own before signalling it.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @note This function requires that a hook is implemented by the MPM: <pre>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * mpm_note_child_killed -- Note the child died in the scoreboard
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @note The MPM child processes which are reclaimed are those listed
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * in the scoreboard as well as those currently registered via
88dd056b9863502bba82c2889a0c4cde9fc0ba93trawick * ap_register_extra_mpm_process().
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Catch any child processes that have been spawned by the parent process
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * which have exited. This includes processes registered as "other_children".
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @note This function requires that a hook is implemented by the MPM: <pre>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * mpm_note_child_killed -- Note the child died in the scoreboard
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * @note The MPM child processes which are relieved are those listed
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * in the scoreboard as well as those currently registered via
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * ap_register_extra_mpm_process().
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * Tell ap_reclaim_child_processes() and ap_relieve_child_processes() about
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * an MPM child process which has no entry in the scoreboard.
8b30d716ef6380801f225010838faa3c00141a06trawick * @param pid The process id of an MPM child process which should be
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * reclaimed when ap_reclaim_child_processes() is called.
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * @note If an extra MPM child process terminates prior to calling
d468ce085370fb85e0cb4e3b48bd1a47c2eca33ctrawick * ap_reclaim_child_processes(), remove it from the list of such processes
c0d403aebd449af101969d1ff60a8cbcf9ecf35cgregames * by calling ap_unregister_extra_mpm_process().
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Unregister an MPM child process which was previously registered by a
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * call to ap_register_extra_mpm_process().
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param pid The process id of an MPM child process which no longer needs to
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * be reclaimed.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @return 1 if the process was found and removed, 0 otherwise
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Safely signal an MPM child process, if the process is in the
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * current process group. Otherwise fail.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param pid the process id of a child process to signal
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param sig the signal number to send
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @return APR_SUCCESS if signal is sent, otherwise an error as per kill(3);
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * APR_EINVAL is returned if passed either an invalid (< 1) pid, or if
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * the pid is not in the current process group
1c86147fa9b58111f7df3b0e24a5bf97833d5d84trawick * Determine if any child process has died. If no child process died, then
89211a5d592cdf0170d2b541946661b1a2a279c5trawick * this process sleeps for the amount of time specified by the MPM defined
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * macro SCOREBOARD_MAINTENANCE_INTERVAL.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param status The return code if a process has died
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param exitcode The returned exit status of the child, if a child process
8b30d716ef6380801f225010838faa3c00141a06trawick * dies, or the signal that caused the child to die.
8b30d716ef6380801f225010838faa3c00141a06trawick * @param ret The process id of the process that died
8b30d716ef6380801f225010838faa3c00141a06trawick * @param p The pool to allocate out of
8b30d716ef6380801f225010838faa3c00141a06trawick * @param s The server_rec to pass
8b30d716ef6380801f225010838faa3c00141a06trawickvoid ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret,
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Log why a child died to the error log, if the child died without the
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * parent signalling it.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param pid The child that has died
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param why The return code of the child process
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param status The status returned from ap_wait_or_timeout
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @return 0 on success, APEXIT_CHILDFATAL if MPM should terminate
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregamesint ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status);
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Turn off the nagle algorithm for the specified socket. The nagle algorithm
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * says that we should delay sending partial packets in the hopes of getting
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * more data. There are bad interactions between persistent connections and
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * Nagle's algorithm that have severe performance penalties.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames * @param s The socket to disable nagle for.
#ifdef HAVE_GETPWNAM
#ifdef HAVE_GETGRNAM
struct ap_pod_t {
apr_pool_t *p;
extern int ap_max_requests_per_child;
const char *arg);
extern const char *ap_pid_fname;
const char *arg);
extern int ap_coredumpdir_configured;
const char *arg);
extern int ap_graceful_shutdown_timeout;
const char *arg);
#define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND \
const char *arg);
const char *arg);
const char *arg);
#ifdef __cplusplus