Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Multi-Processing Modules
Collaboration diagram for Multi-Processing Modules:

Data Structures

struct  ap_pod_t
 

Macros

#define DEFAULT_LISTENBACKLOG   511
 
#define AP_SIG_GRACEFUL   SIGUSR1
 
#define AP_SIG_GRACEFUL_SHORT   USR1
 
#define AP_SIG_GRACEFUL_STRING   "SIGUSR1"
 
#define AP_SIG_GRACEFUL_STOP   SIGWINCH
 
#define AP_SIG_GRACEFUL_STOP_SHORT   WINCH
 
#define AP_SIG_GRACEFUL_STOP_STRING   "SIGWINCH"
 
#define ap_sock_disable_nagle(s)   /* NOOP */
 
#define AP_MPM_PODX_RESTART_CHAR   '$'
 
#define AP_MPM_PODX_GRACEFUL_CHAR   '!'
 
#define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND
 
#define AP_ACCEPT_MUTEX_TYPE   "mpm-accept"
 

Typedefs

typedef void ap_reclaim_callback_fn_t (int childnum, pid_t pid, ap_generation_t gen)
 
typedef struct ap_pod_t ap_pod_t
 

Enumerations

enum  ap_podx_restart_t { AP_MPM_PODX_NORESTART, AP_MPM_PODX_RESTART, AP_MPM_PODX_GRACEFUL }
 

Functions

void ap_reclaim_child_processes (int terminate, ap_reclaim_callback_fn_t *mpm_callback)
 
void ap_relieve_child_processes (ap_reclaim_callback_fn_t *mpm_callback)
 
void ap_register_extra_mpm_process (pid_t pid, ap_generation_t gen)
 
int ap_unregister_extra_mpm_process (pid_t pid, ap_generation_t *old_gen)
 
apr_status_t ap_mpm_safe_kill (pid_t pid, int sig)
 
int ap_process_child_status (apr_proc_t *pid, apr_exit_why_e why, int status)
 
apr_status_t ap_fatal_signal_setup (server_rec *s, apr_pool_t *in_pconf)
 
apr_status_t ap_fatal_signal_child_setup (server_rec *s)
 
apr_status_t ap_mpm_end_gen_helper (void *unused)
 
void ap_wait_or_timeout (apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, apr_pool_t *p, server_rec *s)
 
uid_t ap_uname2id (const char *name)
 
gid_t ap_gname2id (const char *name)
 
apr_status_t ap_mpm_pod_open (apr_pool_t *p, ap_pod_t **pod)
 
apr_status_t ap_mpm_pod_check (ap_pod_t *pod)
 
apr_status_t ap_mpm_pod_close (ap_pod_t *pod)
 
apr_status_t ap_mpm_pod_signal (ap_pod_t *pod)
 
void ap_mpm_pod_killpg (ap_pod_t *pod, int num)
 
apr_status_t ap_mpm_podx_open (apr_pool_t *p, ap_pod_t **pod)
 
int ap_mpm_podx_check (ap_pod_t *pod)
 
apr_status_t ap_mpm_podx_close (ap_pod_t *pod)
 
apr_status_t ap_mpm_podx_signal (ap_pod_t *pod, ap_podx_restart_t graceful)
 
void ap_mpm_podx_killpg (ap_pod_t *pod, int num, ap_podx_restart_t graceful)
 
const char * ap_check_mpm (void)
 
const char * ap_mpm_set_max_requests (cmd_parms *cmd, void *dummy, const char *arg)
 
const char * ap_mpm_set_pidfile (cmd_parms *cmd, void *dummy, const char *arg)
 
void ap_mpm_dump_pidfile (apr_pool_t *p, apr_file_t *out)
 
const char * ap_mpm_set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg)
 
const char * ap_mpm_set_graceful_shutdown (cmd_parms *cmd, void *dummy, const char *arg)
 
int ap_signal_server (int *, apr_pool_t *)
 
void ap_mpm_rewrite_args (process_rec *)
 
const char * ap_mpm_set_max_mem_free (cmd_parms *cmd, void *dummy, const char *arg)
 
const char * ap_mpm_set_thread_stacksize (cmd_parms *cmd, void *dummy, const char *arg)
 
void ap_core_child_status (server_rec *s, pid_t pid, ap_generation_t gen, int slot, mpm_child_status status)
 
int ap_sys_privileges_handlers (int inc)
 
int drop_privileges (apr_pool_t *pchild, server_rec *s)
 
apr_status_t mpm_register_poll_callback_timeout (apr_array_header_t *pds, ap_mpm_callback_fn_t *cbfn, ap_mpm_callback_fn_t *tofn, void *baton, apr_time_t timeout)
 
void mpm_common_pre_config (apr_pool_t *pconf)
 

Variables

AP_DECLARE_DATA int ap_max_requests_per_child
 
AP_DECLARE_DATA const char * ap_pid_fname
 
AP_DECLARE_DATA char ap_coredump_dir [MAX_STRING_LEN]
 
AP_DECLARE_DATA int ap_coredumpdir_configured
 
AP_DECLARE_DATA int ap_graceful_shutdown_timeout
 
AP_DECLARE_DATA apr_uint32_t ap_max_mem_free
 
AP_DECLARE_DATA apr_size_t ap_thread_stacksize
 

Detailed Description

Macro Definition Documentation

#define AP_ACCEPT_MUTEX_TYPE   "mpm-accept"
#define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND
Value:
AP_INIT_TAKE1("GracefulShutdownTimeout", ap_mpm_set_graceful_shutdown, NULL, \
RSRC_CONF, "Maximum time in seconds to wait for child " \
"processes to complete transactions during shutdown")
const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy, const char *arg)
#define AP_INIT_TAKE1(directive, func, mconfig, where, help)
Definition: http_config.h:128
#define RSRC_CONF
Definition: http_config.h:246
#define AP_MPM_PODX_GRACEFUL_CHAR   '!'
#define AP_MPM_PODX_RESTART_CHAR   '$'
#define AP_SIG_GRACEFUL   SIGUSR1
#define AP_SIG_GRACEFUL_SHORT   USR1
#define AP_SIG_GRACEFUL_STOP   SIGWINCH
#define AP_SIG_GRACEFUL_STOP_SHORT   WINCH
#define AP_SIG_GRACEFUL_STOP_STRING   "SIGWINCH"
#define AP_SIG_GRACEFUL_STRING   "SIGUSR1"
#define ap_sock_disable_nagle (   s)    /* NOOP */
#define DEFAULT_LISTENBACKLOG   511

Typedef Documentation

typedef struct ap_pod_t ap_pod_t
typedef void ap_reclaim_callback_fn_t(int childnum, pid_t pid, ap_generation_t gen)

Callback function used for ap_reclaim_child_processes() and ap_relieve_child_processes(). The callback function will be called for each terminated child process.

Enumeration Type Documentation

Enumerator
AP_MPM_PODX_NORESTART 
AP_MPM_PODX_RESTART 
AP_MPM_PODX_GRACEFUL 

Function Documentation

const char* ap_check_mpm ( void  )

Check that exactly one MPM is loaded Returns NULL if yes, error string if not.

void ap_core_child_status ( server_rec s,
pid_t  pid,
ap_generation_t  gen,
int  slot,
mpm_child_status  status 
)
apr_status_t ap_fatal_signal_child_setup ( server_rec s)
apr_status_t ap_fatal_signal_setup ( server_rec s,
apr_pool_t in_pconf 
)
gid_t ap_gname2id ( const char *  name)

Convert a group name to a numeric ID

Parameters
nameThe name to convert
Returns
The group id corresponding to a name
void ap_mpm_dump_pidfile ( apr_pool_t p,
apr_file_t out 
)
apr_status_t ap_mpm_end_gen_helper ( void unused)

Pool cleanup for end-generation hook implementation (core httpd function)

apr_status_t ap_mpm_pod_check ( ap_pod_t pod)

Check the pipe to determine if the process has been signalled to die.

apr_status_t ap_mpm_pod_close ( ap_pod_t pod)

Close the pipe-of-death

Parameters
podthe pipe-of-death to close.
void ap_mpm_pod_killpg ( ap_pod_t pod,
int  num 
)

Write data to the pipe-of-death, signalling that all child process should die.

Parameters
podThe pipe-of-death to write to.
numThe number of child processes to kill
apr_status_t ap_mpm_pod_open ( apr_pool_t p,
ap_pod_t **  pod 
)

Open the pipe-of-death. The pipe of death is used to tell all child processes that it is time to die gracefully.

Parameters
pThe pool to use for allocating the pipe
podthe pipe-of-death that is created.
apr_status_t ap_mpm_pod_signal ( ap_pod_t pod)

Write data to the pipe-of-death, signalling that one child process should die.

Parameters
podthe pipe-of-death to write to.
int ap_mpm_podx_check ( ap_pod_t pod)

Check the extended pipe to determine if the process has been signalled to die.

apr_status_t ap_mpm_podx_close ( ap_pod_t pod)

Close the pipe-of-death

Parameters
podThe pipe-of-death to close.
void ap_mpm_podx_killpg ( ap_pod_t pod,
int  num,
ap_podx_restart_t  graceful 
)

Write data to the extended pipe-of-death, signalling that all child process should die.

Parameters
podThe pipe-of-death to write to.
numThe number of child processes to kill
gracefulrestart-type
apr_status_t ap_mpm_podx_open ( apr_pool_t p,
ap_pod_t **  pod 
)

Open the extended pipe-of-death.

Parameters
pThe pool to use for allocating the pipe
podThe pipe-of-death that is created.
apr_status_t ap_mpm_podx_signal ( ap_pod_t pod,
ap_podx_restart_t  graceful 
)

Write data to the extended pipe-of-death, signalling that one child process should die.

Parameters
podthe pipe-of-death to write to.
gracefulrestart-type
void ap_mpm_rewrite_args ( process_rec )
apr_status_t ap_mpm_safe_kill ( pid_t  pid,
int  sig 
)

Safely signal an MPM child process, if the process is in the current process group. Otherwise fail.

Parameters
pidthe process id of a child process to signal
sigthe signal number to send
Returns
APR_SUCCESS if signal is sent, otherwise an error as per kill(3); APR_EINVAL is returned if passed either an invalid (< 1) pid, or if the pid is not in the current process group
const char* ap_mpm_set_coredumpdir ( cmd_parms cmd,
void dummy,
const char *  arg 
)
const char* ap_mpm_set_graceful_shutdown ( cmd_parms cmd,
void dummy,
const char *  arg 
)
const char* ap_mpm_set_max_mem_free ( cmd_parms cmd,
void dummy,
const char *  arg 
)
const char* ap_mpm_set_max_requests ( cmd_parms cmd,
void dummy,
const char *  arg 
)
const char* ap_mpm_set_pidfile ( cmd_parms cmd,
void dummy,
const char *  arg 
)
const char* ap_mpm_set_thread_stacksize ( cmd_parms cmd,
void dummy,
const char *  arg 
)
int ap_process_child_status ( apr_proc_t pid,
apr_exit_why_e  why,
int  status 
)

Log why a child died to the error log, if the child died without the parent signalling it.

Parameters
pidThe child that has died
whyThe return code of the child process
statusThe status returned from ap_wait_or_timeout
Returns
0 on success, APEXIT_CHILDFATAL if MPM should terminate
void ap_reclaim_child_processes ( int  terminate,
ap_reclaim_callback_fn_t mpm_callback 
)

Make sure all child processes that have been spawned by the parent process have died. This includes process registered as "other_children".

Parameters
terminateEither 1 or 0. If 1, send the child processes SIGTERM each time through the loop. If 0, give the process time to die on its own before signalling it.
mpm_callbackCallback invoked for each dead child process
Note
The MPM child processes which are reclaimed are those listed in the scoreboard as well as those currently registered via ap_register_extra_mpm_process().
void ap_register_extra_mpm_process ( pid_t  pid,
ap_generation_t  gen 
)

Tell ap_reclaim_child_processes() and ap_relieve_child_processes() about an MPM child process which has no entry in the scoreboard.

Parameters
pidThe process id of an MPM child process which should be reclaimed when ap_reclaim_child_processes() is called.
genThe generation of this MPM child process.
Note
If an extra MPM child process terminates prior to calling ap_reclaim_child_processes(), remove it from the list of such processes by calling ap_unregister_extra_mpm_process().
void ap_relieve_child_processes ( ap_reclaim_callback_fn_t mpm_callback)

Catch any child processes that have been spawned by the parent process which have exited. This includes processes registered as "other_children".

Parameters
mpm_callbackCallback invoked for each dead child process
Note
The MPM child processes which are relieved are those listed in the scoreboard as well as those currently registered via ap_register_extra_mpm_process().
int ap_signal_server ( int ,
apr_pool_t  
)
int ap_sys_privileges_handlers ( int  inc)
uid_t ap_uname2id ( const char *  name)

Convert a username to a numeric ID

Parameters
nameThe name to convert
Returns
The user id corresponding to a name
int ap_unregister_extra_mpm_process ( pid_t  pid,
ap_generation_t old_gen 
)

Unregister an MPM child process which was previously registered by a call to ap_register_extra_mpm_process().

Parameters
pidThe process id of an MPM child process which no longer needs to be reclaimed.
old_genSet to the server generation of the process, if found.
Returns
1 if the process was found and removed, 0 otherwise
void ap_wait_or_timeout ( apr_exit_why_e status,
int exitcode,
apr_proc_t ret,
apr_pool_t p,
server_rec s 
)

Run the monitor hook (once every ten calls), determine if any child process has died and, if none died, sleep one second.

Parameters
statusThe return code if a process has died
exitcodeThe returned exit status of the child, if a child process dies, or the signal that caused the child to die.
retThe process id of the process that died
pThe pool to allocate out of
sThe server_rec to pass
int drop_privileges ( apr_pool_t pchild,
server_rec s 
)
void mpm_common_pre_config ( apr_pool_t pconf)
apr_status_t mpm_register_poll_callback_timeout ( apr_array_header_t pds,
ap_mpm_callback_fn_t cbfn,
ap_mpm_callback_fn_t tofn,
void baton,
apr_time_t  timeout 
)

Variable Documentation

AP_DECLARE_DATA char ap_coredump_dir[MAX_STRING_LEN]
AP_DECLARE_DATA int ap_coredumpdir_configured
AP_DECLARE_DATA int ap_graceful_shutdown_timeout

Set the timeout period for a graceful shutdown.

AP_DECLARE_DATA apr_uint32_t ap_max_mem_free
AP_DECLARE_DATA int ap_max_requests_per_child

The maximum number of requests each child thread or process handles before dying off

AP_DECLARE_DATA const char* ap_pid_fname

The filename used to store the process id.

AP_DECLARE_DATA apr_size_t ap_thread_stacksize