Author: jfrederic.clere(a)jboss.com
Date: 2008-05-30 09:02:54 -0400 (Fri, 30 May 2008)
New Revision: 1643
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange the shared memory handling (problem reported by Mladen).
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 07:23:54 UTC (rev 1642)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-30 13:02:54 UTC (rev 1643)
@@ -258,7 +258,15 @@
char *context;
char *host;
char *balancer;
+ void *data;
+ const char *userdata_key = "mod_manager_init";
mod_manager_config *mconf = ap_get_module_config(s->module_config,
&manager_module);
+ apr_pool_userdata_get(&data, userdata_key, s->process->pool);
+ if (!data) {
+ /* first call do nothing */
+ apr_pool_userdata_set((const void *)1, userdata_key, apr_pool_cleanup_null,
s->process->pool);
+ }
+
if (mconf->basefilename) {
node = apr_pstrcat(ptemp, mconf->basefilename, ".node", NULL);
context = apr_pstrcat(ptemp, mconf->basefilename, ".context",
NULL);
@@ -1091,6 +1099,54 @@
}
/*
+ * Attach to the shared memory when the child is created.
+ */
+static void manager_child_init(apr_pool_t *p, server_rec *s)
+{
+ char *node;
+ char *context;
+ char *host;
+ char *balancer;
+ mod_manager_config *mconf = ap_get_module_config(s->module_config,
&manager_module);
+
+ if (mconf->basefilename) {
+ node = apr_pstrcat(p, mconf->basefilename, ".node", NULL);
+ context = apr_pstrcat(p, mconf->basefilename, ".context", NULL);
+ host = apr_pstrcat(p, mconf->basefilename, ".host", NULL);
+ balancer = apr_pstrcat(p, mconf->basefilename, ".balancer", NULL);
+ } else {
+ node = "manager.node";
+ context = "manager.context";
+ host = "manager.host";
+ host = "manager.balancer";
+ }
+
+ nodestatsmem = get_mem_node(node, &mconf->maxnode, p, storage);
+ if (nodestatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_node %s
failed", node);
+ return;
+ }
+
+ contextstatsmem = get_mem_context(context, &mconf->maxcontext, p, storage);
+ if (contextstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_context
failed");
+ return;
+ }
+
+ hoststatsmem = get_mem_host(host, &mconf->maxhost, p, storage);
+ if (hoststatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_host
failed");
+ return;
+ }
+
+ balancerstatsmem = get_mem_balancer(balancer, &mconf->maxhost, p, storage);
+ if (balancerstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "get_mem_balancer
failed");
+ return;
+ }
+}
+
+/*
* Supported directives.
*/
AP_DECLARE_NONSTD(const char *) cmd_manager_maxcontext(cmd_parms *cmd, void *mconfig,
const char *word)
@@ -1172,6 +1228,9 @@
/* Create the shared tables for mod_proxy_cluster */
ap_hook_post_config(manager_init, NULL, NULL, APR_HOOK_MIDDLE);
+ /* Attach to the shared tables with create the child */
+ ap_hook_child_init(manager_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+
/* post read_request handling: to be handle to use ProxyPass / */
ap_hook_translate_name(manager_trans, NULL, aszSucc,
APR_HOOK_FIRST);