Author: jfrederic.clere(a)jboss.com
Date: 2007-08-29 07:33:18 -0400 (Wed, 29 Aug 2007)
New Revision: 957
Added:
trunk/httpd/src/native/mod_manager/mod_manager.c
Log:
Just add a missing file.
Added: trunk/httpd/src/native/mod_manager/mod_manager.c
===================================================================
--- trunk/httpd/src/native/mod_manager/mod_manager.c (rev 0)
+++ trunk/httpd/src/native/mod_manager/mod_manager.c 2007-08-29 11:33:18 UTC (rev 957)
@@ -0,0 +1,173 @@
+/*
+ Copyright 2007 Red Hat Middleware, LLC.
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS,i
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#include "apr_strings.h"
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_log.h"
+#include "http_main.h"
+#include "http_request.h"
+#include "http_protocol.h"
+
+#include "node.h"
+
+/* shared memory */
+mem_t *contextstatsmem = NULL;
+mem_t *nodesstatsmem = NULL;
+
+struct mod_manager_config
+{
+ /* base name for the shared memory */
+ char *basefilename = NULL;
+ /* max number of context supported */
+ int maxcontext = 100;
+ /* max munber of node supported */
+ int maxnode = 10;
+ /* enablePort */
+ int enable;
+
+};
+
+
+/*
+ * call after parser the configuration.
+ * create the shared memory.
+ * XXX: add some code there
+ */
+static int manager_init(apr_pool_t *p, apr_pool_t *plog,
+ apr_pool_t *ptemp, server_rec *s)
+{
+ char *node;
+ char *context;
+ if (basefilename) {
+ node = apr_pstrcat(ptemp, basefilename, ".node", NULL);
+ context = apr_pstrcat(ptemp, basefilename, ".context", NULL);
+ } else {
+ node = "manager.node";
+ context = "manager.context";
+ }
+ nodestatsmem = create_mem_node(node, maxnode, p);
+ if (nodestatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_node
failed");
+ return !OK;
+ }
+ /* XXX: need the context logic
+ contextstatsmem = create_mem_context(node, maxcontext, p);
+ if (contextstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s,
"create_mem_context failed");
+ return !OK;
+ }
+ */
+ return OK;
+}
+static ftp_process_connection(conn_rec *c)
+{
+ ftp_server_config *mconf = ap_get_module_config(c->base_server->module_config,
&manager_module);
+ apr_socket_t *client_socket = ap_get_module_config(c->conn_config,
&core_module);
+
+ if (!mconf->enabled) {
+ return DECLINED;
+ }
+}
+
+/*
+ * Supported directives.
+ */
+AP_DECLARE_NONSTD(const char *) cmd_manager_maxcontext(cmd_parms *cmd, void *mconfig,
const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
+ mconf->maxcontext = atoi(word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_maxnode(cmd_parms *cmd, void *mconfig, const
char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
+ mconf->maxnode = atoi(word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_memmanagerfile(cmd_parms *cmd, void *mconfig,
const char *word)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
+ mconf->basefilename = apr_pstrdup(cmd->pool, word);
+ return NULL;
+}
+AP_DECLARE_NONSTD(const char *) cmd_manager_enablePort(cmd_parms *cmd, void *mconfig, int
arg)
+{
+ mod_manager_config *mconf = ap_get_module_config(cmd->server->module_config,
&manager_module);
+ mconf->enable = arg;
+ return NULL;
+}
+static const command_rec manager_cmds[] =
+{
+ AP_INIT_TAKE1(
+ "Maxcontext",
+ cmd_manager_maxcontext,
+ NULL,
+ OR_ALL,
+ "Maxcontext - number max context support by mod_manager"
+ ),
+ AP_INIT_TAKE1(
+ "Maxnode",
+ cmd_manager_maxnode,
+ NULL,
+ OR_ALL,
+ "Maxnode - number max node support by mod_manager"
+ ),
+ AP_INIT_TAKE1(
+ "MemManagerFile",
+ cmd_manager_memmanagerfile,
+ NULL,
+ OR_ALL,
+ "MemManagerFile - base name of the files used to create/attach to shared
memory"
+ ),
+ AP_INIT_FLAG("EnableLocalPort",
+ cmd_manager_enablePort,
+ NULL,
+ RSRC_CONF,
+ "Run a TCP receivert on this host"),
+ {NULL}
+};
+
+/* hooks declaration */
+
+static void manager_hooks(apr_pool_t *p)
+{
+
+ /* Create the shared tables for mod_proxy_cluster */
+ ap_hook_post_config(manager_init, NULL, NULL, APR_HOOK_MIDDLE);
+
+ /* Process the connections from jboss nodes */
+ ap_hook_process_connection(manager_process_connection, NULL, NULL, APR_HOOK_MIDDLE);
+}
+
+/*
+ * Config creation stuff
+ */
+static void *manager_config(apr_pool_t *pool, char *x)
+{
+ return NULL;
+}
+
+/* Module declaration */
+
+module AP_MODULE_DECLARE_DATA manager_module = {
+ STANDARD20_MODULE_STUFF,
+ manager_config,
+ NULL,
+ NULL,
+ NULL,
+ manager_cmds, /* command table */
+ manager_hooks /* register hooks */
+};