You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/03/02 23:46:35 UTC
cvs commit: httpd-2.0/server/mpm/winnt mpm_winnt.c
rbb 01/03/02 14:46:35
Modified: . CHANGES
include ap_mpm.h
modules/generators mod_info.c
server mpm_common.c scoreboard.c
server/mpm/beos beos.c
server/mpm/perchild perchild.c
server/mpm/prefork prefork.c
server/mpm/spmt_os2 spmt_os2.c
server/mpm/threaded threaded.c
server/mpm/winnt mpm_winnt.c
Log:
Allow modules to query the MPM about it's execution profile. This
query API can and should be extended in the future, but for now,
max_daemons, and threading or forking is a very good start.
Non-Unix MPM's do have the MPM query function, although there is no
garauntee that the information is perfect, please check.
Submitted by: Jon Travis <jt...@covalent.net>
Revision Changes Path
1.118 +5 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -b -w -u -r1.117 -r1.118
--- CHANGES 2001/03/02 06:58:00 1.117
+++ CHANGES 2001/03/02 22:46:30 1.118
@@ -1,5 +1,10 @@
Changes with Apache 2.0.14-dev
+ *) Allow modules to query the MPM about it's execution profile. This
+ query API can and should be extended in the future, but for now,
+ max_daemons, and threading or forking is a very good start.
+ [Jon Travis <jt...@covalent.net>]
+
*) Modify mod_include to send blocks of data no larger than 9k.
Without this, mod_include will wait until the whole file is parsed,
or the first tag is found to send any data to the client.
1.24 +13 -7 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.23
retrieving revision 1.24
diff -u -d -b -w -u -r1.23 -r1.24
--- ap_mpm.h 2001/02/16 04:26:30 1.23
+++ ap_mpm.h 2001/03/02 22:46:31 1.24
@@ -126,13 +126,6 @@
AP_DECLARE(int) ap_graceful_stop_signalled(void);
/**
- * Get the maximum number of daemons processes for this version of Apache
- * @return The maximum number of daemon processes
- * @deffunc int ap_get_max_daemons(void)
- */
-AP_DECLARE(int) ap_get_max_daemons(void);
-
-/**
* Spawn a process with privileges that another module has requested
* @param r The request_rec of the current request
* @param newproc The resulting process handle.
@@ -154,5 +147,18 @@
apr_procattr_t *attr,
apr_pool_t *p);
+
+#define AP_MPMQ_MAX_DAEMONS 1 /* Max # of daemons */
+#define AP_MPMQ_IS_THREADED 2 /* MPM can do threading */
+#define AP_MPMQ_IS_FORKED 3 /* MPM can do forking */
+
+/**
+ * Query a property of the current MPM.
+ * @param query_code One of APM_MPMQ_*
+ * @param result A location to place the result of the query
+ * @return APR_SUCCESS or APR_ENOTIMPL
+ * @deffunc int ap_mpm_query(int query_code, int *result)
+ */
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result);
#endif
1.33 +10 -0 httpd-2.0/modules/generators/mod_info.c
Index: mod_info.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_info.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -b -w -u -r1.32 -r1.33
--- mod_info.c 2001/03/02 21:51:00 1.32
+++ mod_info.c 2001/03/02 22:46:31 1.33
@@ -97,6 +97,7 @@
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
+#include "ap_mpm.h"
typedef struct {
const char *name; /* matching module name */
@@ -305,6 +306,8 @@
}
if (!r->args || !strcasecmp(r->args, "server")) {
+ int max_daemons, forked, threaded;
+
ap_rprintf(r, "<a name=\"server\"><strong>Server Version:</strong> "
"<font size=+1><tt>%s</tt></a></font><br>\n",
ap_get_server_version());
@@ -321,6 +324,13 @@
"<tt>connection: %d "
"keep-alive: %d</tt><br>",
serv->timeout, serv->keep_alive_timeout);
+ ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_daemons);
+ ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded);
+ ap_mpm_query(AP_MPMQ_IS_FORKED, &forked);
+ ap_rprintf(r, "<strong>MPM Information:</strong> "
+ "<tt>Max Daemons: %d Threaded: %s Forked: %s</tt><br>\n",
+ max_daemons, threaded ? "yes" : "no",
+ forked ? "yes" : "no");
ap_rprintf(r, "<strong>Server Root:</strong> "
"<tt>%s</tt><br>\n", ap_server_root);
ap_rprintf(r, "<strong>Config File:</strong> "
1.43 +2 -1 httpd-2.0/server/mpm_common.c
Index: mpm_common.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -b -w -u -r1.42 -r1.43
--- mpm_common.c 2001/02/16 04:26:47 1.42
+++ mpm_common.c 2001/03/02 22:46:31 1.43
@@ -94,8 +94,9 @@
apr_status_t waitret;
int tries;
int not_dead_yet;
- int max_daemons = ap_get_max_daemons();
+ int max_daemons;
+ ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_daemons);
MPM_SYNC_CHILD_TABLE();
for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
1.19 +3 -1 httpd-2.0/server/scoreboard.c
Index: scoreboard.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/scoreboard.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -b -w -u -r1.18 -r1.19
--- scoreboard.c 2001/02/24 11:23:22 1.18
+++ scoreboard.c 2001/03/02 22:46:31 1.19
@@ -253,7 +253,9 @@
AP_DECLARE(int) find_child_by_pid(apr_proc_t *pid)
{
int i;
- int max_daemons_limit = ap_get_max_daemons();
+ int max_daemons_limit;
+
+ ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_daemons_limit);
for (i = 0; i < max_daemons_limit; ++i)
if (ap_scoreboard_image->parent[i].pid == pid->pid)
1.47 +16 -5 httpd-2.0/server/mpm/beos/beos.c
Index: beos.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -b -w -u -r1.46 -r1.47
--- beos.c 2001/02/23 18:17:17 1.46
+++ beos.c 2001/03/02 22:46:31 1.47
@@ -140,11 +140,6 @@
int raise_sigstop_flags;
#endif
-AP_DECLARE(int) ap_get_max_daemons(void)
-{
- return ap_max_child_assigned;
-}
-
/* a clean exit from a child with proper cleanup
static void clean_child_exit(int code) __attribute__ ((noreturn)); */
static void clean_child_exit(int code)
@@ -631,6 +626,22 @@
}
perform_idle_server_maintenance();
}
+}
+
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
+{
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = ap_max_daemons_limit;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 1;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 1;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
}
int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
1.54 +13 -2 httpd-2.0/server/mpm/perchild/perchild.c
Index: perchild.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -b -w -u -r1.53 -r1.54
--- perchild.c 2001/02/28 18:23:37 1.53
+++ perchild.c 2001/03/02 22:46:32 1.54
@@ -215,9 +215,20 @@
static const char *lock_fname;
static apr_lock_t *thread_accept_mutex;
-AP_DECLARE(int) ap_get_max_daemons(void)
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
{
- return ap_max_daemons_limit;
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = ap_max_daemons_limit;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 1;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 1;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
}
/* a clean exit from a child with proper cleanup */
1.170 +13 -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.169
retrieving revision 1.170
diff -u -d -b -w -u -r1.169 -r1.170
--- prefork.c 2001/03/02 18:52:00 1.169
+++ prefork.c 2001/03/02 22:46:32 1.170
@@ -302,9 +302,20 @@
#define SAFE_ACCEPT(stmt) do {stmt;} while(0)
#endif
-AP_DECLARE(int) ap_get_max_daemons(void)
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
{
- return ap_max_daemons_limit;
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = ap_daemons_limit;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 0;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 1;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
}
#if defined(NEED_WAITPID)
1.90 +15 -5 httpd-2.0/server/mpm/spmt_os2/spmt_os2.c
Index: spmt_os2.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/spmt_os2/spmt_os2.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -b -w -u -r1.89 -r1.90
--- spmt_os2.c 2001/02/24 00:40:28 1.89
+++ spmt_os2.c 2001/03/02 22:46:32 1.90
@@ -217,11 +217,6 @@
#define SAFE_ACCEPT(stmt) do {stmt;} while(0)
#endif
-AP_DECLARE(int) ap_get_max_daemons(void)
-{
- return max_daemons_limit;
-}
-
static int find_thread_by_tid(int tid)
{
int i;
@@ -883,6 +878,21 @@
}
}
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
+{
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = max_daemons_limit;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 1;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 0;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
+}
/*****************************************************************
* Executive routines.
1.11 +13 -2 httpd-2.0/server/mpm/threaded/threaded.c
Index: threaded.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -b -w -u -r1.10 -r1.11
--- threaded.c 2001/03/02 18:52:23 1.10
+++ threaded.c 2001/03/02 22:46:33 1.11
@@ -171,9 +171,20 @@
#define SAFE_ACCEPT(stmt) (stmt)
#endif
-AP_DECLARE(int) ap_get_max_daemons(void)
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
{
- return ap_max_daemons_limit;
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = ap_max_daemons_limit;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 1;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 1;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
}
/* a clean exit from a child with proper cleanup */
1.145 +16 -4 httpd-2.0/server/mpm/winnt/mpm_winnt.c
Index: mpm_winnt.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -b -w -u -r1.144 -r1.145
--- mpm_winnt.c 2001/02/24 11:23:21 1.144
+++ mpm_winnt.c 2001/03/02 22:46:33 1.145
@@ -126,10 +126,6 @@
* code
*/
ap_generation_t volatile ap_my_generation=0; /* Used by the scoreboard */
-AP_DECLARE(int) ap_get_max_daemons(void)
-{
- return 1;
-}
/* This is the helper code to resolve late bound entry points
* missing from one or more releases of the Win32 API...
@@ -1779,6 +1775,22 @@
* Remember inst_argc and inst_argv for installing or starting the
* service after we preflight the config.
*/
+
+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
+{
+ switch(query_code){
+ case AP_MPMQ_MAX_DAEMONS:
+ *result = MAXIMUM_WAIT_OBJECTS;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_THREADED:
+ *result = 1;
+ return APR_SUCCESS;
+ case AP_MPMQ_IS_FORKED:
+ *result = 0;
+ return APR_SUCCESS;
+ }
+ return APR_ENOTIMPL;
+}
static apr_status_t service_to_start_success;
static int inst_argc;