]> granicus.if.org Git - apache/commitdiff
mpm_common.c implements a handful of config directives; the
authorJeff Trawick <trawick@apache.org>
Mon, 28 Mar 2011 16:25:20 +0000 (16:25 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 28 Mar 2011 16:25:20 +0000 (16:25 +0000)
related state has to be re-initialized to the default values
at pre-config time, but that was handled inconsistently by
the MPMs, resulting in unexpected behavior when some of the
directives were removed across restart

move that necessary initialization from the MPMs to common
code run from core's pre-config; MPMs that need to override
defaults can do so by running after core's pre-config (the
NetWare MPM now does that)

the DEFAULT_MAX_REQUESTS_PER_CHILD compile setting wasn't useful
enough to keep

the simple MPM wasn't consistent in which of these directives
were respected and which weren't, and that hasn't changed
(see procmgr.max_requests_per_child vs. ap_max_requests_per_child)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1086293 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
include/mpm_common.h
server/core.c
server/mpm/event/event.c
server/mpm/event/mpm_default.h
server/mpm/mpmt_os2/mpm_default.h
server/mpm/mpmt_os2/mpmt_os2.c
server/mpm/netware/mpm_default.h
server/mpm/netware/mpm_netware.c
server/mpm/prefork/mpm_default.h
server/mpm/prefork/prefork.c
server/mpm/simple/simple_core.c
server/mpm/winnt/mpm_default.h
server/mpm/winnt/mpm_winnt.c
server/mpm/worker/mpm_default.h
server/mpm/worker/worker.c
server/mpm_common.c

index bb512836c775db263a9406277469674e708aeb03..f08510aa469d00fa1bf12172b110b5bf8b8686f8 100644 (file)
@@ -350,6 +350,11 @@ AP_DECLARE_HOOK(const char *,mpm_get_name,(void))
  */
 #define AP_ACCEPT_MUTEX_TYPE "mpm-accept"
 
+/* internal pre-config logic for MPM-related settings, callable only from
+ * core's pre-config hook
+ */
+void mpm_common_pre_config(apr_pool_t *pconf);
+  
 #ifdef __cplusplus
 }
 #endif
index 6600df332ea025c29dddca8939a55421bdd4d171..846ee7532b91263623724aca3ec97d698e9d7472 100644 (file)
@@ -4150,6 +4150,8 @@ static int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptem
     apr_pool_cleanup_register(pconf, NULL, reset_config_defines,
                               apr_pool_cleanup_null);
 
+    mpm_common_pre_config(pconf);
+
     return APR_SUCCESS;
 }
 
index 81c2ba86953f315891acd004bb560c6d0133e85d..9d9231ce1c4eb452edfd729e1ac508faf0ca1207 100644 (file)
@@ -2463,12 +2463,7 @@ static int event_pre_config(apr_pool_t * pconf, apr_pool_t * plog,
     ap_daemons_limit = server_limit;
     threads_per_child = DEFAULT_THREADS_PER_CHILD;
     max_clients = ap_daemons_limit * threads_per_child;
-    ap_pid_fname = DEFAULT_PIDLOG;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
-    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-
-    apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 
     return OK;
 }
index 33283772b66269603a19d31db09a9db789aafc5b..079e71fe3c625ef1612f3f5b47f0dd3cac75f1d5 100644 (file)
 #define DEFAULT_THREADS_PER_CHILD 25
 #endif
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 #endif /* AP_MPM_DEFAULT_H */
 /** @} */
index b25effa8578627dfcc333560f2a274978923dff6..5db0ecd6e7a8d001666930f16556c3843a18a4d7 100644 (file)
 #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
 #endif
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 #endif /* AP_MPM_DEFAULT_H */
 /** @} */
index c961450969acee1d4a86160386fba77a9a007069..b310ff98f70b75eddc258bd2da4a91e961963ddb 100644 (file)
@@ -476,14 +476,9 @@ static int mpmt_os2_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *
     ap_listen_pre_config();
     ap_daemons_to_start = DEFAULT_START_DAEMON;
     ap_thread_limit = HARD_THREAD_LIMIT;
-    ap_pid_fname = DEFAULT_PIDLOG;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
     ap_min_spare_threads = DEFAULT_MIN_SPARE_THREAD;
     ap_max_spare_threads = DEFAULT_MAX_SPARE_THREAD;
-#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
-        ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-#endif
     ap_sys_privileges_handlers(1);
 
     return OK;
index b79cb6bdf57359c1538124a6fdd42554e2b39e81..b8c3ad6f4bb852c02342c3eeea08768a413192b2 100644 (file)
 #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
 #endif
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 /* Default stack size allocated for each worker thread.
  */
 #ifndef DEFAULT_THREAD_STACKSIZE
index c39552d79419bcc6cbdc69e9fbf6650b63e5d4db..547fb1adf021694df395683eb18ea650ca74346a 100644 (file)
@@ -987,12 +987,10 @@ static int netware_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp
     ap_threads_min_free = DEFAULT_MIN_FREE_THREADS;
     ap_threads_max_free = DEFAULT_MAX_FREE_THREADS;
     ap_threads_limit = HARD_THREAD_LIMIT;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
+
+    /* override core's default thread stacksize */
     ap_thread_stacksize = DEFAULT_THREAD_STACKSIZE;
-#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
-    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-#endif
 
     return OK;
 }
@@ -1082,7 +1080,12 @@ static int netware_check_config(apr_pool_t *p, apr_pool_t *plog,
 
 static void netware_mpm_hooks(apr_pool_t *p)
 {
-    ap_hook_pre_config(netware_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
+    /* Run the pre-config hook after core's so that it can override the
+     * default setting of ThreadStackSize for NetWare.
+     */
+    static const char * const predecessors[] = {"core.c", NULL};
+
+    ap_hook_pre_config(netware_pre_config, predecessors, NULL, APR_HOOK_MIDDLE);
     ap_hook_check_config(netware_check_config, NULL, NULL, APR_HOOK_MIDDLE);
     //ap_hook_post_config(netware_post_config, NULL, NULL, 0);
     //ap_hook_child_init(netware_child_init, NULL, NULL, APR_HOOK_MIDDLE);
index 38b65432a9aa03411d78d45413bccae88fc97c57..5f131c5a028274318c57862536aaa2b77a8d9a08 100644 (file)
 #define DEFAULT_MIN_FREE_DAEMON 5
 #endif
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 #endif /* AP_MPM_DEFAULT_H */
 /** @} */
index 2d6d97c976a99bb7861898069b94362fd37030f9..87545bfc8f0b058eb12f2b3a0bd3499aa8710cdc 100644 (file)
@@ -1272,12 +1272,7 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp
     ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON;
     server_limit = DEFAULT_SERVER_LIMIT;
     ap_daemons_limit = server_limit;
-    ap_pid_fname = DEFAULT_PIDLOG;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
-    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-
-    apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 
     return OK;
 }
index 9e0e870f9f0dbd8bddf474a14f83ec3fc996bc1a..1315aa58728bc53bc32bcb1c3aa45173fb591822 100644 (file)
 
 static simple_core_t *g_simple_core;
 
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
-
 APLOG_USE_MODULE(mpm_simple);
 
 simple_core_t *simple_core_get()
@@ -58,7 +53,7 @@ apr_status_t simple_core_init_once(void)
     sc->mpm_state = AP_MPMQ_STARTING;
     sc->procmgr.proc_count = SIMPLE_DEF_PROC;
     sc->procmgr.thread_count = SIMPLE_DEF_THREADS;
-    sc->procmgr.max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
+    sc->procmgr.max_requests_per_child = 0; /* unlimited */
 
     sc->children = apr_hash_make(sc->pool);
     /* TODO: configurable spawning mech */
index 184dc62f4f809b2a38cbe1b48d6cf6416ea65d44..a0e38efee0e5d84d86275dcf60f17146ca5c1d44 100644 (file)
  */
 #define HARD_SERVER_LIMIT 1
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 #endif /* AP_MPM_DEFAULT_H */
 /** @} */
index a0009e8c8e738a28712cf15e0967dafa82091757..eee66cd191bd2faccdfb7e86ec5946c7ab61abf9 100644 (file)
@@ -1369,11 +1369,6 @@ static int winnt_pre_config(apr_pool_t *pconf_, apr_pool_t *plog, apr_pool_t *pt
     ap_listen_pre_config();
     thread_limit = DEFAULT_THREAD_LIMIT;
     ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
-    ap_pid_fname = DEFAULT_PIDLOG;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
-    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-
-    apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 
     return OK;
 }
index 9b8a6f91b7780fd54699f05482df590b2757b210..244a0bb1fdd2a20e84ea2118b367ef720effebce 100644 (file)
 #define DEFAULT_THREADS_PER_CHILD 25
 #endif
 
-/* Number of requests to try to handle in a single process.  If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
-#endif
-
 #endif /* AP_MPM_DEFAULT_H */
 /** @} */
index 7d373cab5b55bc28e5239bfe46cc9e8d22532752..de98b52ad150de333b65d022d404c68741e1139b 100644 (file)
@@ -1970,12 +1970,7 @@ static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
     ap_daemons_limit = server_limit;
     threads_per_child = DEFAULT_THREADS_PER_CHILD;
     max_clients = ap_daemons_limit * threads_per_child;
-    ap_pid_fname = DEFAULT_PIDLOG;
-    ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
-    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-
-    apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 
     return OK;
 }
index 153975cf50c65e9292d35fb8631974ac2ca0fef1..232cbf511cebf7454b4a8e1d56769be25b74c4d0 100644 (file)
@@ -103,6 +103,30 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(const char *, mpm_get_name,
                             (void),
                             (), NULL)
 
+/* variables representing config directives implemented here */
+const char *ap_pid_fname;
+int ap_max_requests_per_child;
+char ap_coredump_dir[MAX_STRING_LEN];
+int ap_coredumpdir_configured;
+int ap_graceful_shutdown_timeout;
+apr_uint32_t ap_max_mem_free;
+apr_size_t ap_thread_stacksize;
+
+/* Set defaults for config directives implemented here.  This is
+ * called from core's pre-config hook, so MPMs which need to override
+ * one of these should run their pre-config hook after that of core.
+ */
+void mpm_common_pre_config(apr_pool_t *pconf)
+{
+    ap_pid_fname = DEFAULT_PIDLOG;
+    ap_max_requests_per_child = 0; /* unlimited */
+    apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
+    ap_coredumpdir_configured = 0;
+    ap_graceful_shutdown_timeout = 0; /* unlimited */
+    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
+    ap_thread_stacksize = 0; /* use system default */
+}
+
 /* number of calls to wait_or_timeout between writable probes */
 #ifndef INTERVAL_OF_WRITABLE_PROBES
 #define INTERVAL_OF_WRITABLE_PROBES 10
@@ -225,7 +249,6 @@ int initgroups(const char *name, gid_t basegid)
 #endif /* def HAVE_INITGROUPS */
 
 /* standard mpm configuration handling */
-const char *ap_pid_fname = NULL;
 
 const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
                                const char *arg)
@@ -243,8 +266,6 @@ const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
     return NULL;
 }
 
-int ap_max_requests_per_child = 0;
-
 const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
                                     const char *arg)
 {
@@ -264,9 +285,6 @@ const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
     return NULL;
 }
 
-char ap_coredump_dir[MAX_STRING_LEN];
-int ap_coredumpdir_configured;
-
 const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
                                    const char *arg)
 {
@@ -295,8 +313,6 @@ const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
     return NULL;
 }
 
-int ap_graceful_shutdown_timeout = 0;
-
 const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
                                           const char *arg)
 {
@@ -308,8 +324,6 @@ const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
     return NULL;
 }
 
-apr_uint32_t ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
-
 const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
                                     const char *arg)
 {
@@ -329,8 +343,6 @@ const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
     return NULL;
 }
 
-apr_size_t ap_thread_stacksize = 0; /* use system default */
-
 const char *ap_mpm_set_thread_stacksize(cmd_parms *cmd, void *dummy,
                                         const char *arg)
 {