Changes with Apache 2.0.24-dev
+ *) Begin to sanitize the MPM configuration directives. Now, all
+ MPMs use the same functions for all common MPM directives. This
+ should make it easier to catch all bugs in these directives once.
+ [Cody Sherr <csherr@covalent.net>]
+
*) Close a major resource leak. Everytime we had issued a
graceful restart, we leaked a socket descriptor.
[Ryan Bloom]
AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num);
#endif
+/*
+ * These data members are common to all mpms. Each new mpm
+ * should either use the appropriate ap_mpm_set_* function
+ * in their command table or create their own for custom or
+ * OS specific needs. These should work for most.
+ */
+
+/**
+ * The maximum number of requests each child thread or
+ * process handles before dying off
+ */
+#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
+extern int ap_max_requests_per_child;
+AP_DECLARE(const char *) ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
+/**
+ * The filename used to store the process id.
+ */
+#ifdef AP_MPM_WANT_SET_PIDFILE
+extern const char *ap_pid_fname;
+AP_DECLARE(const char *) ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
+/**
+ * The name of lockfile used when Apache needs to lock the accept() call.
+ */
+#ifdef AP_MPM_WANT_SET_LOCKFILE
+extern const char *ap_lock_fname;
+AP_DECLARE(const char *) ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
+/**
+ * The system mutex implementation to use for the accept mutex.
+ */
+#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+extern apr_lockmech_e_np accept_lock_mech;
+AP_DECLARE(const char *) ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
+/*
+ * Set the scorboard file.
+ */
+#ifdef AP_MPM_WANT_SET_SCOREBOARD
+AP_DECLARE(const char *) ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
+/*
+ * The directory that the server changes directory to dump core.
+ */
+#ifdef AP_MPM_WANT_SET_COREDUMPDIR
+extern char ap_coredump_dir[MAX_STRING_LEN];
+AP_DECLARE(const char *) ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
+ const char *arg);
+#endif
+
#ifdef __cplusplus
}
#endif
#include "http_main.h"
#include "http_log.h"
#include "unixd.h"
+#include "apr_lock.h"
#include "mpm_common.h"
#include "os.h"
#include "ap_mpm.h"
#include "util_filter.h"
#include "util_ebcdic.h"
#include "mpm.h"
-
+#include "mpm_common.h"
+#include "scoreboard.h"
#include "mod_core.h"
"filters to be run"),
AP_INIT_ITERATE("SetInputFilter", add_input_filter, NULL, ACCESS_CONF,
"filters to be run on the request body"),
+
+/*
+ * These are default configuration directives that mpms can/should
+ * pay attention to. If an mpm wishes to use these, they should
+ * #defined them in mpm.h.
+ */
+#ifdef AP_MPM_WANT_SET_PIDFILE
+AP_INIT_TAKE1("PidFile", ap_mpm_set_pidfile, NULL, RSRC_CONF, \
+ "A file for logging the server process ID"),
+#endif
+#ifdef AP_MPM_WANT_SET_SCOREBOARD
+AP_INIT_TAKE1("ScoreBoardFile", ap_mpm_set_scoreboard, NULL, RSRC_CONF, \
+ "A file for Apache to maintain runtime process management information"),
+#endif
+#ifdef AP_MPM_WANT_SET_LOCKFILE
+AP_INIT_TAKE1("LockFile", ap_mpm_set_lockfile, NULL, RSRC_CONF, \
+ "The lockfile used when Apache needs to lock the accept() call"),
+#endif
+#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
+AP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,\
+ "Maximum number of requests a particular child serves before dying."),
+#endif
+#ifdef AP_MPM_WANT_SET_COREDUMPDIR
+AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF, \
+ "The location of the directory Apache changes to before dumping core"),
+#endif
+#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF, \
+ "The system mutex implementation to use for the accept mutex"),
+#endif
{ NULL }
};
#include "apr_network_io.h"
#include "apr_strings.h"
+#include "apr_lock.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "mpm.h"
#include "mpm_common.h"
-
ap_listen_rec *ap_listeners;
#if APR_HAVE_IPV6
static int default_family = APR_UNSPEC;
*/
int ap_threads_per_child=HARD_THREAD_LIMIT; /* Worker threads per child */
-static int ap_max_requests_per_child=0;
-static const char *ap_pid_fname=NULL;
static int ap_threads_to_start=0;
static int min_spare_threads=0;
static int max_spare_threads=0;
*/
int ap_max_child_assigned = -1;
int ap_max_threads_limit = -1;
-char ap_coredump_dir[MAX_STRING_LEN];
static apr_socket_t *udp_sock;
static apr_sockaddr_t *udp_sa;
ap_hook_pre_config(beos_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
static const command_rec beos_cmds[] = {
LISTEN_COMMANDS
-AP_INIT_TAKE1( "PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1( "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
AP_INIT_TAKE1( "StartServers", set_daemons_to_start, NULL, RSRC_CONF,
"Number of child processes launched at server startup"),
AP_INIT_TAKE1( "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
"Maximum number of children alive at the same time" ),
AP_INIT_TAKE1( "ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF,
"Number of threads each child creates" ),
-AP_INIT_TAKE1( "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying." ),
-AP_INIT_TAKE1( "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core" ),
{ NULL }
};
#define MPM_CHILD_PID(i) (ap_scoreboard_image->servers[0][i].tid)
#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
-extern int ap_max_child_assigned;
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+extern int ap_max_child_assigned;
extern server_rec *ap_server_conf;
-extern char ap_coredump_dir[MAX_STRING_LEN];
extern int ap_threads_per_child;
#endif /* APACHE_MPM_BEOS_H */
#define MPM_NAME "Perchild"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
#define AP_MPM_NEEDS_RECLAIM_CHILD_PROCESSES 1
#define MPM_SYNC_CHILD_TABLE()
#define MPM_CHILD_PID(i) (ap_child_table[i].pid)
extern int ap_max_daemons_limit;
extern ap_ctable ap_child_table[HARD_SERVER_LIMIT];
extern server_rec *ap_server_conf;
-extern char ap_coredump_dir[MAX_STRING_LEN];
#endif /* APACHE_MPM_PERCHILD_H */
static int max_spare_threads = 0;
static int max_threads = 0;
static int max_requests_per_child = 0;
-static const char *ap_pid_fname=NULL;
-static int num_daemons=0;
-static int curr_child_num=0;
+static int num_daemons = 0;
+static int curr_child_num = 0;
static int workers_may_exit = 0;
static int requests_this_child;
static int num_listenfds = 0;
int ap_max_daemons_limit = -1;
int ap_threads_per_child = HARD_THREAD_LIMIT;
-char ap_coredump_dir[MAX_STRING_LEN];
-
module AP_MODULE_DECLARE_DATA mpm_perchild_module;
static apr_file_t *pipe_of_death_in = NULL;
#else
#define SAFE_ACCEPT(stmt) (stmt)
static apr_lock_t *process_accept_mutex;
-static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
#endif /* NO_SERIALIZED_ACCEPT */
-static const char *lock_fname;
static apr_lock_t *thread_accept_mutex;
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
/*stuff to do before we switch id's, so we have permissions.*/
- rv = SAFE_ACCEPT(apr_lock_child_init(&process_accept_mutex, lock_fname,
- pchild));
+ rv = SAFE_ACCEPT(apr_lock_child_init(&process_accept_mutex, ap_lock_fname,
+ pchild));
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
"Couldn't initialize cross-process lock in child");
ap_log_pid(pconf, ap_pid_fname);
/* Initialize cross-process accept lock */
- lock_fname = apr_psprintf(_pconf, "%s.%u",
- ap_server_root_relative(_pconf, lock_fname),
+ ap_lock_fname = apr_psprintf(_pconf, "%s.%u",
+ ap_server_root_relative(_pconf, ap_lock_fname),
my_pid);
rv = SAFE_ACCEPT(apr_lock_create_np(&process_accept_mutex, APR_MUTEX,
APR_CROSS_PROCESS, accept_lock_mech,
- lock_fname, _pconf));
+ ap_lock_fname, _pconf));
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
"Couldn't create cross-process lock");
max_threads = HARD_THREAD_LIMIT;
ap_pid_fname = DEFAULT_PIDLOG;
ap_scoreboard_fname = DEFAULT_SCOREBOARD;
- lock_fname = DEFAULT_LOCKFILE;
+ ap_lock_fname = DEFAULT_LOCKFILE;
max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
curr_child_num = 0;
&mpm_perchild_module);
char *foo;
apr_size_t len;
- int zero = 0;
+ apr_off_t zero = 0;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", r->connection->pool);
len = strlen(foo);
return OK;
}
-static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes)
+static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_off_t *readbytes)
{
apr_bucket *e;
apr_status_t rv;
ap_register_input_filter("PERCHILD_BUFFER", perchild_buffer, AP_FTYPE_CONTENT);
}
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
static const char *set_num_daemons (cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
static const char *set_child_per_uid(cmd_parms *cmd, void *dummy, const char *u,
const char *g, const char *num)
{
return NULL;
}
-static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "default")) {
- accept_lock_mech = APR_LOCK_DEFAULT;
- }
-#if APR_HAS_FLOCK_SERIALIZE
- else if (!strcasecmp(arg, "flock")) {
- accept_lock_mech = APR_LOCK_FLOCK;
- }
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- else if (!strcasecmp(arg, "fcntl")) {
- accept_lock_mech = APR_LOCK_FCNTL;
- }
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- else if (!strcasecmp(arg, "sysvsem")) {
- accept_lock_mech = APR_LOCK_SYSVSEM;
- }
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (!strcasecmp(arg, "proc_pthread")) {
- accept_lock_mech = APR_LOCK_PROC_PTHREAD;
- }
-#endif
- else {
- return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
- "ones for this platform are: default"
-#if APR_HAS_FLOCK_SERIALIZE
- ", flock"
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- ", fcntl"
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- ", sysvsem"
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- ", proc_pthread"
-#endif
- , NULL);
- }
- return NULL;
-}
-
static const command_rec perchild_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call"),
AP_INIT_TAKE1("NumServers", set_num_daemons, NULL, RSRC_CONF,
"Number of children alive at the same time"),
AP_INIT_TAKE1("StartThreads", set_threads_to_start, NULL, RSRC_CONF,
"Maximum number of idle threads per child"),
AP_INIT_TAKE1("MaxThreadsPerChild", set_max_threads, NULL, RSRC_CONF,
"Maximum number of threads per child"),
-AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core"),
AP_INIT_TAKE3("ChildperUserID", set_child_per_uid, NULL, RSRC_CONF,
"Specify a User and Group for a specific child process."),
AP_INIT_TAKE2("AssignUserID", assign_childuid, NULL, RSRC_CONF,
"Tie a virtual host to a specific child process."),
-AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
- "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
#define MPM_NAME "Perchild"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
#define AP_MPM_NEEDS_RECLAIM_CHILD_PROCESSES 1
#define MPM_SYNC_CHILD_TABLE()
#define MPM_CHILD_PID(i) (ap_child_table[i].pid)
extern int ap_max_daemons_limit;
extern ap_ctable ap_child_table[HARD_SERVER_LIMIT];
extern server_rec *ap_server_conf;
-extern char ap_coredump_dir[MAX_STRING_LEN];
#endif /* APACHE_MPM_PERCHILD_H */
static int max_spare_threads = 0;
static int max_threads = 0;
static int max_requests_per_child = 0;
-static const char *ap_pid_fname=NULL;
-static int num_daemons=0;
-static int curr_child_num=0;
+static int num_daemons = 0;
+static int curr_child_num = 0;
static int workers_may_exit = 0;
static int requests_this_child;
static int num_listenfds = 0;
int ap_max_daemons_limit = -1;
int ap_threads_per_child = HARD_THREAD_LIMIT;
-char ap_coredump_dir[MAX_STRING_LEN];
-
module AP_MODULE_DECLARE_DATA mpm_perchild_module;
static apr_file_t *pipe_of_death_in = NULL;
#else
#define SAFE_ACCEPT(stmt) (stmt)
static apr_lock_t *process_accept_mutex;
-static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
#endif /* NO_SERIALIZED_ACCEPT */
-static const char *lock_fname;
static apr_lock_t *thread_accept_mutex;
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
/*stuff to do before we switch id's, so we have permissions.*/
- rv = SAFE_ACCEPT(apr_lock_child_init(&process_accept_mutex, lock_fname,
- pchild));
+ rv = SAFE_ACCEPT(apr_lock_child_init(&process_accept_mutex, ap_lock_fname,
+ pchild));
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
"Couldn't initialize cross-process lock in child");
ap_log_pid(pconf, ap_pid_fname);
/* Initialize cross-process accept lock */
- lock_fname = apr_psprintf(_pconf, "%s.%u",
- ap_server_root_relative(_pconf, lock_fname),
+ ap_lock_fname = apr_psprintf(_pconf, "%s.%u",
+ ap_server_root_relative(_pconf, ap_lock_fname),
my_pid);
rv = SAFE_ACCEPT(apr_lock_create_np(&process_accept_mutex, APR_MUTEX,
APR_CROSS_PROCESS, accept_lock_mech,
- lock_fname, _pconf));
+ ap_lock_fname, _pconf));
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
"Couldn't create cross-process lock");
max_threads = HARD_THREAD_LIMIT;
ap_pid_fname = DEFAULT_PIDLOG;
ap_scoreboard_fname = DEFAULT_SCOREBOARD;
- lock_fname = DEFAULT_LOCKFILE;
+ ap_lock_fname = DEFAULT_LOCKFILE;
max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
curr_child_num = 0;
&mpm_perchild_module);
char *foo;
apr_size_t len;
- int zero = 0;
+ apr_off_t zero = 0;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", r->connection->pool);
len = strlen(foo);
return OK;
}
-static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes)
+static apr_status_t perchild_buffer(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_off_t *readbytes)
{
apr_bucket *e;
apr_status_t rv;
ap_register_input_filter("PERCHILD_BUFFER", perchild_buffer, AP_FTYPE_CONTENT);
}
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
static const char *set_num_daemons (cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
static const char *set_child_per_uid(cmd_parms *cmd, void *dummy, const char *u,
const char *g, const char *num)
{
return NULL;
}
-static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "default")) {
- accept_lock_mech = APR_LOCK_DEFAULT;
- }
-#if APR_HAS_FLOCK_SERIALIZE
- else if (!strcasecmp(arg, "flock")) {
- accept_lock_mech = APR_LOCK_FLOCK;
- }
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- else if (!strcasecmp(arg, "fcntl")) {
- accept_lock_mech = APR_LOCK_FCNTL;
- }
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- else if (!strcasecmp(arg, "sysvsem")) {
- accept_lock_mech = APR_LOCK_SYSVSEM;
- }
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (!strcasecmp(arg, "proc_pthread")) {
- accept_lock_mech = APR_LOCK_PROC_PTHREAD;
- }
-#endif
- else {
- return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
- "ones for this platform are: default"
-#if APR_HAS_FLOCK_SERIALIZE
- ", flock"
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- ", fcntl"
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- ", sysvsem"
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- ", proc_pthread"
-#endif
- , NULL);
- }
- return NULL;
-}
-
static const command_rec perchild_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call"),
AP_INIT_TAKE1("NumServers", set_num_daemons, NULL, RSRC_CONF,
"Number of children alive at the same time"),
AP_INIT_TAKE1("StartThreads", set_threads_to_start, NULL, RSRC_CONF,
"Maximum number of idle threads per child"),
AP_INIT_TAKE1("MaxThreadsPerChild", set_max_threads, NULL, RSRC_CONF,
"Maximum number of threads per child"),
-AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core"),
AP_INIT_TAKE3("ChildperUserID", set_child_per_uid, NULL, RSRC_CONF,
"Specify a User and Group for a specific child process."),
AP_INIT_TAKE2("AssignUserID", assign_childuid, NULL, RSRC_CONF,
"Tie a virtual host to a specific child process."),
-AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
- "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
#define MPM_NAME "Prefork"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
#define AP_MPM_USES_POD 1
#define AP_MPM_NEEDS_RECLAIM_CHILD_PROCESSES 1
#define MPM_SYNC_CHILD_TABLE() (ap_sync_scoreboard_image())
extern int ap_threads_per_child;
extern int ap_max_daemons_limit;
extern server_rec *ap_server_conf;
-extern char ap_coredump_dir[MAX_STRING_LEN];
#endif /* APACHE_MPM_PREFORK_H */
/* config globals */
int ap_threads_per_child=0; /* Worker threads per child */
-static int ap_max_requests_per_child=0;
-static const char *ap_pid_fname=NULL;
static apr_lock_t *accept_lock;
-static const char *ap_lock_fname;
-static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
static int ap_daemons_to_start=0;
static int ap_daemons_min_free=0;
static int ap_daemons_max_free=0;
int ap_max_daemons_limit = -1;
server_rec *ap_server_conf;
-char ap_coredump_dir[MAX_STRING_LEN];
-
/* *Non*-shared http_main globals... */
static apr_socket_t *sd;
ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_lock_fname = arg;
- return NULL;
-}
-
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "default")) {
- accept_lock_mech = APR_LOCK_DEFAULT;
- }
-#if APR_HAS_FLOCK_SERIALIZE
- else if (!strcasecmp(arg, "flock")) {
- accept_lock_mech = APR_LOCK_FLOCK;
- }
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- else if (!strcasecmp(arg, "fcntl")) {
- accept_lock_mech = APR_LOCK_FCNTL;
- }
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- else if (!strcasecmp(arg, "sysvsem")) {
- accept_lock_mech = APR_LOCK_SYSVSEM;
- }
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (!strcasecmp(arg, "proc_pthread")) {
- accept_lock_mech = APR_LOCK_PROC_PTHREAD;
- }
-#endif
- else {
- return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
- "ones for this platform are: default"
-#if APR_HAS_FLOCK_SERIALIZE
- ", flock"
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- ", fcntl"
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- ", sysvsem"
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- ", proc_pthread"
-#endif
- , NULL);
- }
- return NULL;
-}
-
static const command_rec prefork_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call"),
AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF,
"Number of child processes launched at server startup"),
AP_INIT_TAKE1("MinSpareServers", set_min_free_servers, NULL, RSRC_CONF,
"Maximum number of idle children"),
AP_INIT_TAKE1("MaxClients", set_server_limit, NULL, RSRC_CONF,
"Maximum number of children alive at the same time"),
-AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core"),
-AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
- "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
#define MPM_NAME "SPMT_OS2"
-extern char ap_coredump_dir[MAX_STRING_LEN];
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+
extern server_rec *ap_server_conf;
extern int ap_threads_per_child;
/* config globals */
-static int ap_max_requests_per_child=0;
-static const char *ap_pid_fname=NULL;
static int ap_daemons_to_start=0;
static int ap_daemons_min_free=0;
static int ap_daemons_max_free=0;
_endthread();
}
-
-
static apr_lock_t *accept_mutex = NULL;
static apr_status_t accept_mutex_child_cleanup(void *foo)
ap_hook_pre_config(spmt_os2_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
/* Stub functions until this MPM supports the connection status API */
AP_DECLARE(void) ap_update_connection_status(long conn_id, const char *key, \
static const command_rec spmt_os2_cmds[] = {
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
AP_INIT_TAKE1( "StartServers", set_daemons_to_start, NULL, RSRC_CONF,
"Number of child processes launched at server startup" ),
AP_INIT_TAKE1( "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF,
"Maximum number of idle children" ),
AP_INIT_TAKE1( "MaxClients", set_server_limit, NULL, RSRC_CONF,
"Maximum number of children alive at the same time" ),
-AP_INIT_TAKE1( "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying." ),
-AP_INIT_TAKE1( "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core" ),
{ NULL }
};
#define MPM_NAME "Threaded"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
#define AP_MPM_NEEDS_RECLAIM_CHILD_PROCESSES 1
#define MPM_SYNC_CHILD_TABLE() (ap_sync_scoreboard_image())
#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
extern int ap_threads_per_child;
extern int ap_max_daemons_limit;
extern server_rec *ap_server_conf;
-extern char ap_coredump_dir[MAX_STRING_LEN];
#endif /* APACHE_MPM_THREADED_H */
*/
int ap_threads_per_child=0; /* Worker threads per child */
-static int ap_max_requests_per_child=0;
-static const char *ap_pid_fname=NULL;
static int ap_daemons_to_start=0;
static int min_spare_threads=0;
static int max_spare_threads=0;
*/
int ap_max_daemons_limit = -1;
-char ap_coredump_dir[MAX_STRING_LEN];
-
static apr_file_t *pipe_of_death_in = NULL;
static apr_file_t *pipe_of_death_out = NULL;
static apr_lock_t *pipe_of_death_mutex; /* insures that a child process only
/* Locks for accept serialization */
static apr_lock_t *accept_mutex;
-static apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
-static const char *lock_fname;
#ifdef NO_SERIALIZED_ACCEPT
#define SAFE_ACCEPT(stmt) APR_SUCCESS
ap_hook_pre_config(threaded_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
-
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
const char *arg)
{
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "default")) {
- accept_lock_mech = APR_LOCK_DEFAULT;
- }
-#if APR_HAS_FLOCK_SERIALIZE
- else if (!strcasecmp(arg, "flock")) {
- accept_lock_mech = APR_LOCK_FLOCK;
- }
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- else if (!strcasecmp(arg, "fcntl")) {
- accept_lock_mech = APR_LOCK_FCNTL;
- }
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- else if (!strcasecmp(arg, "sysvsem")) {
- accept_lock_mech = APR_LOCK_SYSVSEM;
- }
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (!strcasecmp(arg, "proc_pthread")) {
- accept_lock_mech = APR_LOCK_PROC_PTHREAD;
- }
-#endif
- else {
- return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
- "ones for this platform are: default"
-#if APR_HAS_FLOCK_SERIALIZE
- ", flock"
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- ", fcntl"
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- ", sysvsem"
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- ", proc_pthread"
-#endif
- , NULL);
- }
- return NULL;
-}
-
static const command_rec threaded_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call"),
AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF,
"Number of child processes launched at server startup"),
AP_INIT_TAKE1("MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
"Maximum number of children alive at the same time"),
AP_INIT_TAKE1("ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF,
"Number of threads each child creates"),
-AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core"),
-AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
- "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
#define MPM_NAME "WinNT"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
extern int ap_threads_per_child;
#endif /* APACHE_MPM_H */
#define MPM_NAME "Worker"
+#define AP_MPM_WANT_SET_PIDFILE
+#define AP_MPM_WANT_SET_SCOREBOARD
+#define AP_MPM_WANT_SET_LOCKFILE
+#define AP_MPM_WANT_SET_MAX_REQUESTS
+#define AP_MPM_WANT_SET_COREDUMPDIR
+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+
#define AP_MPM_NEEDS_RECLAIM_CHILD_PROCESSES 1
#define MPM_SYNC_CHILD_TABLE() (ap_sync_scoreboard_image())
#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
ap_hook_pre_config(worker_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
-
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
const char *arg)
{
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- apr_finfo_t finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
- || (finfo.filetype != APR_DIR)) {
- return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const char *set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "default")) {
- accept_lock_mech = APR_LOCK_DEFAULT;
- }
-#if APR_HAS_FLOCK_SERIALIZE
- else if (!strcasecmp(arg, "flock")) {
- accept_lock_mech = APR_LOCK_FLOCK;
- }
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- else if (!strcasecmp(arg, "fcntl")) {
- accept_lock_mech = APR_LOCK_FCNTL;
- }
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- else if (!strcasecmp(arg, "sysvsem")) {
- accept_lock_mech = APR_LOCK_SYSVSEM;
- }
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- else if (!strcasecmp(arg, "proc_pthread")) {
- accept_lock_mech = APR_LOCK_PROC_PTHREAD;
- }
-#endif
- else {
- return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
- "ones for this platform are: default"
-#if APR_HAS_FLOCK_SERIALIZE
- ", flock"
-#endif
-#if APR_HAS_FCNTL_SERIALIZE
- ", fcntl"
-#endif
-#if APR_HAS_SYSVSEM_SERIALIZE
- ", sysvsem"
-#endif
-#if APR_HAS_PROC_PTHREAD_SERIALIZE
- ", proc_pthread"
-#endif
- , NULL);
- }
- return NULL;
-}
-
static const command_rec worker_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
- "A file for logging the server process ID"),
-AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
- "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
- "The lockfile used when Apache needs to lock the accept() call"),
AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF,
"Number of child processes launched at server startup"),
AP_INIT_TAKE1("MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
"Maximum number of children alive at the same time"),
AP_INIT_TAKE1("ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF,
"Number of threads each child creates"),
-AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
- "Maximum number of requests a particular child serves before dying."),
-AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
- "The location of the directory Apache changes to before dumping core"),
-AP_INIT_TAKE1("AcceptMutex", set_accept_lock_mech, NULL, RSRC_CONF,
- "The system mutex implementation to use for the accept mutex"),
{ NULL }
};
#include "apr.h"
#include "apr_thread_proc.h"
#include "apr_signal.h"
+#include "apr_strings.h"
+#include "apr_lock.h"
#include "httpd.h"
#include "http_config.h"
#include "ap_mpm.h"
#include "ap_listen.h"
+#ifdef AP_MPM_WANT_SET_SCOREBOARD
+#include "scoreboard.h"
+#endif
+
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
return APR_SUCCESS;
}
-AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num)
+void ap_mpm_pod_killpg(ap_pod_t *pod, int num)
{
int i;
apr_status_t rv = APR_SUCCESS;
rv = ap_mpm_pod_signal(pod);
}
}
+#endif /* #ifdef AP_MPM_USES_POD */
+
+/* standard mpm configuration handling */
+#ifdef AP_MPM_WANT_SET_PIDFILE
+const char *ap_pid_fname = NULL;
+
+AP_DECLARE(const char *)ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ if (cmd->server->is_virtual) {
+ return "PidFile directive not allowed in <VirtualHost>";
+ }
+ ap_pid_fname = arg;
+ return NULL;
+}
+#endif
+
+#ifdef AP_MPM_WANT_SET_SCOREBOARD
+AP_DECLARE(const char *) ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ ap_scoreboard_fname = arg;
+ return NULL;
+}
+#endif
+
+#ifdef AP_MPM_WANT_SET_LOCKFILE
+const char *ap_lock_fname = NULL;
+AP_DECLARE(const char *) ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ ap_lock_fname = arg;
+ return NULL;
+}
+#endif
+
+#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
+int ap_max_requests_per_child = 0;
+AP_DECLARE(const char *) ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ ap_max_requests_per_child = atoi(arg);
+
+ return NULL;
+}
+#endif
+
+#ifdef AP_MPM_WANT_SET_COREDUMPDIR
+char ap_coredump_dir[MAX_STRING_LEN];
+AP_DECLARE(const char *) ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
+ const char *arg)
+{
+ apr_finfo_t finfo;
+ const char *fname;
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ fname = ap_server_root_relative(cmd->pool, arg);
+ if ((apr_stat(&finfo, fname, APR_FINFO_TYPE, cmd->pool) != APR_SUCCESS)
+ || (finfo.filetype != APR_DIR)) {
+ return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
+ " does not exist or is not a directory", NULL);
+ }
+ apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
+ return NULL;
+}
+#endif
+
+#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
+apr_lockmech_e_np accept_lock_mech = APR_LOCK_DEFAULT;
+AP_DECLARE(const char *) ap_mpm_set_accept_lock_mech(cmd_parms *cmd,
+ void *dummy,
+ const char *arg)
+{
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ if (!strcasecmp(arg, "default")) {
+ accept_lock_mech = APR_LOCK_DEFAULT;
+ }
+#if APR_HAS_FLOCK_SERIALIZE
+ else if (!strcasecmp(arg, "flock")) {
+ accept_lock_mech = APR_LOCK_FLOCK;
+ }
+#endif
+#if APR_HAS_FCNTL_SERIALIZE
+ else if (!strcasecmp(arg, "fcntl")) {
+ accept_lock_mech = APR_LOCK_FCNTL;
+ }
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE
+ else if (!strcasecmp(arg, "sysvsem")) {
+ accept_lock_mech = APR_LOCK_SYSVSEM;
+ }
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+ else if (!strcasecmp(arg, "proc_pthread")) {
+ accept_lock_mech = APR_LOCK_PROC_PTHREAD;
+ }
+#endif
+ else {
+ return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; valid "
+ "ones for this platform are: default"
+#if APR_HAS_FLOCK_SERIALIZE
+ ", flock"
+#endif
+#if APR_HAS_FCNTL_SERIALIZE
+ ", fcntl"
+#endif
+#if APR_HAS_SYSVSEM_SERIALIZE
+ ", sysvsem"
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+ ", proc_pthread"
+#endif
+ , NULL);
+ }
+ return NULL;
+}
#endif