You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2003/12/10 21:45:09 UTC
cvs commit: httpd-2.0/server/mpm/prefork prefork.c
trawick 2003/12/10 12:45:09
Modified: include ap_mpm.h
server/mpm/prefork prefork.c
Log:
add new MPM query -- AP_MPMQ_MPM_STATE -- to find out what the MPM
is doing
work-in-progress; not so useful until other MPMs support it
Revision Changes Path
1.36 +6 -1 httpd-2.0/include/ap_mpm.h
Index: ap_mpm.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/ap_mpm.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ap_mpm.h 26 Nov 2003 03:45:34 -0000 1.35
+++ ap_mpm.h 10 Dec 2003 20:45:09 -0000 1.36
@@ -160,6 +160,11 @@
/* an MPM is using a dynamic # */
/* threads or daemons. */
+/* Values returned for AP_MPMQ_MPM_STATE */
+#define AP_MPMQ_STARTING 0
+#define AP_MPMQ_RUNNING 1
+#define AP_MPMQ_STOPPING 2
+
#define AP_MPMQ_MAX_DAEMON_USED 1 /* Max # of daemons used so far */
#define AP_MPMQ_IS_THREADED 2 /* MPM can do threading */
#define AP_MPMQ_IS_FORKED 3 /* MPM can do forking */
@@ -172,7 +177,7 @@
#define AP_MPMQ_MAX_SPARE_THREADS 10 /* Max # of spare threads */
#define AP_MPMQ_MAX_REQUESTS_DAEMON 11 /* Max # of requests per daemon */
#define AP_MPMQ_MAX_DAEMONS 12 /* Max # of daemons by config */
-
+#define AP_MPMQ_MPM_STATE 13 /* starting, running, stopping */
/**
* Query a property of the current MPM.
1.284 +26 -2 httpd-2.0/server/mpm/prefork/prefork.c
Index: prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.283
retrieving revision 1.284
diff -u -r1.283 -r1.284
--- prefork.c 22 Nov 2003 20:43:25 -0000 1.283
+++ prefork.c 10 Dec 2003 20:45:09 -0000 1.284
@@ -141,7 +141,7 @@
static int server_limit = DEFAULT_SERVER_LIMIT;
static int first_server_limit;
static int changed_limit_at_restart;
-
+static int mpm_state = AP_MPMQ_STARTING;
static ap_pod_t *pod;
/*
@@ -235,6 +235,8 @@
static void clean_child_exit(int code) __attribute__ ((noreturn));
static void clean_child_exit(int code)
{
+ mpm_state = AP_MPMQ_STOPPING;
+
if (pchild) {
apr_pool_destroy(pchild);
}
@@ -332,6 +334,9 @@
case AP_MPMQ_MAX_DAEMONS:
*result = server_limit;
return APR_SUCCESS;
+ case AP_MPMQ_MPM_STATE:
+ *result = mpm_state;
+ return APR_SUCCESS;
}
return APR_ENOTIMPL;
}
@@ -497,6 +502,10 @@
apr_bucket_alloc_t *bucket_alloc;
int last_poll_idx = 0;
+ mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
+ * child initializes
+ */
+
my_child_num = child_num_arg;
ap_my_pid = getpid();
requests_this_child = 0;
@@ -549,6 +558,8 @@
(void) apr_pollset_add(pollset, &pfd);
}
+ mpm_state = AP_MPMQ_RUNNING;
+
bucket_alloc = apr_bucket_alloc_create(pchild);
while (!die_now) {
@@ -931,6 +942,7 @@
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
"Couldn't create accept lock");
+ mpm_state = AP_MPMQ_STOPPING;
return 1;
}
@@ -945,12 +957,14 @@
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
"Couldn't set permissions on cross-process lock; "
"check User and Group directives");
+ mpm_state = AP_MPMQ_STOPPING;
return 1;
}
}
if (!is_graceful) {
if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
+ mpm_state = AP_MPMQ_STOPPING;
return 1;
}
/* fix the generation number in the global score; we just got a new,
@@ -1004,6 +1018,8 @@
#endif
restart_pending = shutdown_pending = 0;
+ mpm_state = AP_MPMQ_RUNNING;
+
while (!restart_pending && !shutdown_pending) {
int child_slot;
apr_exit_why_e exitwhy;
@@ -1020,6 +1036,7 @@
if (pid.pid != -1) {
processed_status = ap_process_child_status(&pid, exitwhy, status);
if (processed_status == APEXIT_CHILDFATAL) {
+ mpm_state = AP_MPMQ_STOPPING;
return 1;
}
@@ -1087,6 +1104,8 @@
}
} /* one_process */
+ mpm_state = AP_MPMQ_STOPPING;
+
if (shutdown_pending) {
/* Time to gracefully shut down:
* Kill child processes, tell them to call child_exit, etc...
@@ -1187,6 +1206,8 @@
int no_detach, debug, foreground;
apr_status_t rv;
+ mpm_state = AP_MPMQ_STARTING;
+
debug = ap_exists_config_define("DEBUG");
if (debug) {
@@ -1249,7 +1270,10 @@
#endif
ap_hook_open_logs(prefork_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
- ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
+ /* we need to set the MPM state before other pre-config hooks use MPM query
+ * to retrieve it, so register as REALLY_FIRST
+ */
+ ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
}
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg)