Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
prefork.c File Reference
#include "apr.h"
#include "apr_portable.h"
#include "apr_strings.h"
#include "apr_thread_proc.h"
#include "apr_signal.h"
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "mpm_default.h"
#include "http_main.h"
#include "http_log.h"
#include "http_config.h"
#include "http_core.h"
#include "http_connection.h"
#include "scoreboard.h"
#include "ap_mpm.h"
#include "util_mutex.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_listen.h"
#include "ap_mmn.h"
#include "apr_poll.h"
#include <stdlib.h>
#include <signal.h>
#include <sys/times.h>

Go to the source code of this file.

Classes

struct  prefork_retained_data
 
struct  prefork_child_bucket
 

Macros

#define APR_WANT_STDIO
 
#define APR_WANT_STRFUNC
 
#define DEFAULT_SERVER_LIMIT   256
 
#define MAX_SERVER_LIMIT   200000
 
#define HARD_THREAD_LIMIT   1
 
#define MAX_SPAWN_RATE   (32)
 
#define MPM_CHILD_PID(i)   (ap_scoreboard_image->parent[i].pid)
 
#define chdir_for_gprof()
 
#define SAFE_ACCEPT(stmt)   (stmt)
 

Typedefs

typedef struct prefork_retained_data prefork_retained_data
 
typedef struct prefork_child_bucket prefork_child_bucket
 

Functions

static void prefork_note_child_killed (int childnum, pid_t pid, ap_generation_t gen)
 
static void prefork_note_child_started (int slot, pid_t pid)
 
static void clean_child_exit (int code) __attribute__((noreturn))
 
static apr_status_t accept_mutex_on (void)
 
static apr_status_t accept_mutex_off (void)
 
static int prefork_query (int query_code, int *result, apr_status_t *rv)
 
static const charprefork_get_name (void)
 
static void just_die (int sig)
 
static void stop_listening (int sig)
 
static void child_main (int child_num_arg, int child_bucket)
 
static int make_child (server_rec *s, int slot)
 
static void startup_children (int number_to_start)
 
static void perform_idle_server_maintenance (apr_pool_t *p)
 
static int prefork_run (apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
 
static int prefork_open_logs (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
static int prefork_pre_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
 
static int prefork_check_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
static void prefork_hooks (apr_pool_t *p)
 
static const charset_daemons_to_start (cmd_parms *cmd, void *dummy, const char *arg)
 
static const charset_min_free_servers (cmd_parms *cmd, void *dummy, const char *arg)
 
static const charset_max_free_servers (cmd_parms *cmd, void *dummy, const char *arg)
 
static const charset_max_clients (cmd_parms *cmd, void *dummy, const char *arg)
 
static const charset_server_limit (cmd_parms *cmd, void *dummy, const char *arg)
 

Variables

static int ap_daemons_to_start =0
 
static int ap_daemons_min_free =0
 
static int ap_daemons_max_free =0
 
static int ap_daemons_limit =0
 
static int server_limit = 0
 
static prefork_retained_dataretained
 
static prefork_child_bucketall_buckets
 
static prefork_child_bucketmy_bucket
 
static int one_process = 0
 
static apr_pool_tpconf
 
static apr_pool_tpchild
 
static pid_t ap_my_pid
 
static pid_t parent_pid
 
static int my_child_num
 
static int volatile die_now = 0
 
static int requests_this_child
 
static int num_listensocks = 0
 
static const command_rec prefork_cmds []
 
static int *const aplog_module_index = &( mpm_prefork_module.module_index)
 

Macro Definition Documentation

◆ APR_WANT_STDIO

#define APR_WANT_STDIO

Definition at line 23 of file prefork.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 24 of file prefork.c.

◆ chdir_for_gprof

#define chdir_for_gprof ( )

Definition at line 195 of file prefork.c.

◆ DEFAULT_SERVER_LIMIT

#define DEFAULT_SERVER_LIMIT   256

Definition at line 75 of file prefork.c.

◆ HARD_THREAD_LIMIT

#define HARD_THREAD_LIMIT   1

Definition at line 86 of file prefork.c.

◆ MAX_SERVER_LIMIT

#define MAX_SERVER_LIMIT   200000

Definition at line 82 of file prefork.c.

◆ MAX_SPAWN_RATE

#define MAX_SPAWN_RATE   (32)

Definition at line 120 of file prefork.c.

◆ MPM_CHILD_PID

#define MPM_CHILD_PID (   i)    (ap_scoreboard_image->parent[i].pid)

Definition at line 134 of file prefork.c.

◆ SAFE_ACCEPT

#define SAFE_ACCEPT (   stmt)    (stmt)

Definition at line 292 of file prefork.c.

Typedef Documentation

◆ prefork_child_bucket

◆ prefork_retained_data

Function Documentation

◆ accept_mutex_off()

static apr_status_t accept_mutex_off ( void  )
static

Definition at line 262 of file prefork.c.

◆ accept_mutex_on()

static apr_status_t accept_mutex_on ( void  )
static

Definition at line 243 of file prefork.c.

◆ child_main()

static void child_main ( int  child_num_arg,
int  child_bucket 
)
static

< Descriptors passed to apr_pollset_add() * are not copied

< Can read without blocking

Definition at line 394 of file prefork.c.

◆ clean_child_exit()

static void clean_child_exit ( int  code)
static

Definition at line 219 of file prefork.c.

◆ just_die()

static void just_die ( int  sig)
static

Definition at line 357 of file prefork.c.

◆ make_child()

static int make_child ( server_rec s,
int  slot 
)
static

Definition at line 692 of file prefork.c.

◆ perform_idle_server_maintenance()

static void perform_idle_server_maintenance ( apr_pool_t p)
static

Definition at line 798 of file prefork.c.

◆ prefork_check_config()

static int prefork_check_config ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec s 
)
static

< Module has handled this stage.

Definition at line 1345 of file prefork.c.

◆ prefork_get_name()

static const char * prefork_get_name ( void  )
static

Definition at line 348 of file prefork.c.

◆ prefork_hooks()

static void prefork_hooks ( apr_pool_t p)
static

Definition at line 1458 of file prefork.c.

◆ prefork_note_child_killed()

static void prefork_note_child_killed ( int  childnum,
pid_t  pid,
ap_generation_t  gen 
)
static

Definition at line 198 of file prefork.c.

◆ prefork_note_child_started()

static void prefork_note_child_started ( int  slot,
pid_t  pid 
)
static

Definition at line 209 of file prefork.c.

◆ prefork_open_logs()

static int prefork_open_logs ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec s 
)
static

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

Definition at line 1220 of file prefork.c.

◆ prefork_pre_config()

static int prefork_pre_config ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp 
)
static

< Do not detach

< Detach

< Module has handled this stage.

Definition at line 1283 of file prefork.c.

◆ prefork_query()

static int prefork_query ( int  query_code,
int result,
apr_status_t rv 
)
static

< This value specifies that an * MPM is not capable of * threading or forking.

< This value specifies that * an MPM is using a dynamic * number of threads or daemons

< Module has handled this stage.

Definition at line 295 of file prefork.c.

◆ prefork_run()

static int prefork_run ( apr_pool_t _pconf,
apr_pool_t plog,
server_rec s 
)
static

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has served the response completely * - it's safe to die() with no more output

< Module has served the response completely * - it's safe to die() with no more output

< Module has served the response completely * - it's safe to die() with no more output

< Module has handled this stage.

Definition at line 899 of file prefork.c.

◆ set_daemons_to_start()

static const char * set_daemons_to_start ( cmd_parms cmd,
void *  dummy,
const char arg 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1477 of file prefork.c.

◆ set_max_clients()

static const char * set_max_clients ( cmd_parms cmd,
void *  dummy,
const char arg 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1510 of file prefork.c.

◆ set_max_free_servers()

static const char * set_max_free_servers ( cmd_parms cmd,
void *  dummy,
const char arg 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1499 of file prefork.c.

◆ set_min_free_servers()

static const char * set_min_free_servers ( cmd_parms cmd,
void *  dummy,
const char arg 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1488 of file prefork.c.

◆ set_server_limit()

static const char * set_server_limit ( cmd_parms cmd,
void *  dummy,
const char arg 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1525 of file prefork.c.

◆ startup_children()

static void startup_children ( int  number_to_start)
static

Definition at line 783 of file prefork.c.

◆ stop_listening()

static void stop_listening ( int  sig)
static

Definition at line 365 of file prefork.c.

Variable Documentation

◆ all_buckets

prefork_child_bucket* all_buckets
static

Definition at line 131 of file prefork.c.

◆ ap_daemons_limit

int ap_daemons_limit =0
static

Definition at line 94 of file prefork.c.

◆ ap_daemons_max_free

int ap_daemons_max_free =0
static

Definition at line 93 of file prefork.c.

◆ ap_daemons_min_free

int ap_daemons_min_free =0
static

Definition at line 92 of file prefork.c.

◆ ap_daemons_to_start

int ap_daemons_to_start =0
static

Definition at line 91 of file prefork.c.

◆ ap_my_pid

pid_t ap_my_pid
static

Definition at line 152 of file prefork.c.

◆ aplog_module_index

int* const aplog_module_index = &( mpm_prefork_module.module_index)
static

Definition at line 1554 of file prefork.c.

◆ die_now

int volatile die_now = 0
static

Definition at line 363 of file prefork.c.

◆ my_bucket

prefork_child_bucket * my_bucket
static

Definition at line 132 of file prefork.c.

◆ my_child_num

int my_child_num
static

Definition at line 154 of file prefork.c.

◆ num_listensocks

int num_listensocks = 0
static

Definition at line 381 of file prefork.c.

◆ one_process

int one_process = 0
static

Definition at line 147 of file prefork.c.

◆ parent_pid

pid_t parent_pid
static

Definition at line 153 of file prefork.c.

◆ pchild

apr_pool_t* pchild
static

Definition at line 150 of file prefork.c.

◆ pconf

apr_pool_t* pconf
static

Definition at line 149 of file prefork.c.

◆ prefork_cmds

const command_rec prefork_cmds[]
static
Initial value:
= {
{ "ListenBacklog" , ap_set_listenbacklog , NULL , 128 , TAKE1, "Maximum length of the queue of pending connections, as used by listen(2)" }, { "ListenCoresBucketsRatio" , ap_set_listencbratio , NULL , 128 , TAKE1, "Ratio between the number of CPU cores (online) and the number of listeners buckets" }, { "Listen" , ap_set_listener , NULL , 128 , TAKE_ARGV, "A port number or a numeric IP address and a port number, and an optional protocol" }, { "SendBufferSize" , ap_set_send_buffer_size , NULL , 128 , TAKE1, "Send buffer size in bytes" }, { "ReceiveBufferSize" , ap_set_receive_buffer_size , NULL , 128 , TAKE1, "Receive buffer size in bytes" } ,
{ "StartServers" , set_daemons_to_start , NULL , 128 , TAKE1, "Number of child processes launched at server startup" },
{ "MinSpareServers" , set_min_free_servers , NULL , 128 , TAKE1, "Minimum number of idle children, to handle request spikes" },
{ "MaxSpareServers" , set_max_free_servers , NULL , 128 , TAKE1, "Maximum number of idle children" },
{ "MaxClients" , set_max_clients , NULL , 128 , TAKE1, "Deprecated name of MaxRequestWorkers" },
{ "MaxRequestWorkers" , set_max_clients , NULL , 128 , TAKE1, "Maximum number of children alive at the same time" },
{ "ServerLimit" , set_server_limit , NULL , 128 , TAKE1, "Maximum value of MaxRequestWorkers for this run of Apache" },
{ "GracefulShutdownTimeout" , ap_mpm_set_graceful_shutdown , NULL , 128 , TAKE1, "Maximum time in seconds to wait for child " "processes to complete transactions during shutdown" } ,
{ NULL }
}
@ TAKE1
Definition http_config.h:51
@ TAKE_ARGV
Definition http_config.h:66
const char * ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg)
Definition listen.c:901
const char * ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, const char *arg)
Definition listen.c:941
const char * ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg)
Definition listen.c:921
const char * ap_set_listener(cmd_parms *cmd, void *dummy, int argc, char *const argv[])
Definition listen.c:847
const char * ap_set_receive_buffer_size(cmd_parms *cmd, void *dummy, const char *arg)
Definition listen.c:960
const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy, const char *arg)
Definition mpm_common.c:369
return NULL
Definition mod_so.c:359
static const char * set_max_free_servers(cmd_parms *cmd, void *dummy, const char *arg)
Definition prefork.c:1499
static const char * set_max_clients(cmd_parms *cmd, void *dummy, const char *arg)
Definition prefork.c:1510
static const char * set_server_limit(cmd_parms *cmd, void *dummy, const char *arg)
Definition prefork.c:1525
static const char * set_min_free_servers(cmd_parms *cmd, void *dummy, const char *arg)
Definition prefork.c:1488
static const char * set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg)
Definition prefork.c:1477

Definition at line 1536 of file prefork.c.

◆ requests_this_child

int requests_this_child
static

Definition at line 380 of file prefork.c.

◆ retained

prefork_retained_data* retained
static

Definition at line 124 of file prefork.c.

◆ server_limit

int server_limit = 0
static

Definition at line 95 of file prefork.c.