JBoss Native SVN: r1595 - sandbox/httpd/src/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-09 08:04:46 -0400 (Fri, 09 May 2008)
New Revision: 1595
Modified:
sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add the proxy_hook_pre_request() and corresponding cluster scheme logic
(copy from mod_proxy_balancer.c).
Modified: sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-07 07:49:47 UTC (rev 1594)
+++ sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-09 12:04:46 UTC (rev 1595)
@@ -213,7 +213,7 @@
"create_workers_node can't read id %d", ids[j]);
continue;
}
- char *name = apr_pstrcat(pool, "balancer://", node->balancer, NULL);
+ char *name = apr_pstrcat(pool, "cluster://", node->balancer, NULL);
proxy_balancer *balancer = ap_proxy_get_balancer(pool, conf, name);
if (!balancer) {
/* Create one */
@@ -615,7 +615,7 @@
ap_get_module_config(sconf, &proxy_module);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: Entering bytraffic for BALANCER (%s)",
+ "proxy: Entering bytraffic for CLUSTER (%s)",
balancer->name);
/* create workers for new nodes */
@@ -1111,7 +1111,7 @@
char *balancer = get_context_host_balancer(r);
if (balancer) {
- r->filename = apr_pstrcat(r->pool, "proxy:balancer://", balancer, r->uri, NULL);
+ r->filename = apr_pstrcat(r->pool, "proxy:cluster://", balancer, r->uri, NULL);
r->handler = "proxy-server";
r->proxyreq = PROXYREQ_REVERSE;
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
@@ -1124,6 +1124,377 @@
}
/*
+ * canonise the url
+ */
+static int proxy_cluster_canon(request_rec *r, char *url)
+{
+ if (strncasecmp(url, "balancer:", 9) == 0) {
+ OK; /* XXX: need more */
+ }
+ else {
+ return DECLINED;
+ }
+}
+
+/* Find the worker that has the 'route' defined
+ */
+static proxy_worker *find_route_worker(proxy_balancer *balancer,
+ const char *route, request_rec *r)
+{
+ int i;
+ int checking_standby;
+ int checked_standby;
+
+ proxy_worker *worker;
+
+ checking_standby = checked_standby = 0;
+ while (!checked_standby) {
+ worker = (proxy_worker *)balancer->workers->elts;
+ for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+ if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
+ continue;
+ if (*(worker->s->route) && strcmp(worker->s->route, route) == 0) {
+ if (worker && PROXY_WORKER_IS_USABLE(worker)) {
+ return worker;
+ } else {
+ /*
+ * If the worker is in error state run
+ * retry on that worker. It will be marked as
+ * operational if the retry timeout is elapsed.
+ * The worker might still be unusable, but we try
+ * anyway.
+ */
+ ap_proxy_retry_worker("BALANCER", worker, r->server);
+ if (PROXY_WORKER_IS_USABLE(worker)) {
+ return worker;
+ } else {
+ /*
+ * We have a worker that is unusable.
+ * It can be in error or disabled, but in case
+ * it has a redirection set use that redirection worker.
+ * This enables to safely remove the member from the
+ * balancer. Of course you will need some kind of
+ * session replication between those two remote.
+ */
+ if (*worker->s->redirect) {
+ proxy_worker *rworker = NULL;
+ rworker = find_route_worker(balancer, worker->s->redirect, r);
+ /* Check if the redirect worker is usable */
+ if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) {
+ /*
+ * If the worker is in error state run
+ * retry on that worker. It will be marked as
+ * operational if the retry timeout is elapsed.
+ * The worker might still be unusable, but we try
+ * anyway.
+ */
+ ap_proxy_retry_worker("BALANCER", rworker, r->server);
+ }
+ if (rworker && PROXY_WORKER_IS_USABLE(rworker))
+ return rworker;
+ }
+ }
+ }
+ }
+ }
+ checked_standby = checking_standby++;
+ }
+ return NULL;
+}
+static proxy_worker *find_session_route(proxy_balancer *balancer,
+ request_rec *r,
+ char **route,
+ char **sticky_used,
+ char **url)
+{
+ proxy_worker *worker = NULL;
+ char *sticky, *sticky_path, *path;
+
+ if (!balancer->sticky)
+ return NULL;
+ sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
+ if ((path = strchr(sticky, '|'))) {
+ *path++ = '\0';
+ sticky_path = path;
+ }
+
+ /* Try to find the sticky route inside url */
+ *sticky_used = sticky_path;
+ *route = get_path_param(r->pool, *url, sticky_path);
+ if (!*route) {
+ *route = get_cookie_param(r, sticky);
+ *sticky_used = sticky;
+ }
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER: Found value %s for "
+ "stickysession %s", *route, balancer->sticky);
+ /*
+ * If we found a value for sticksession, find the first '.' within.
+ * Everything after '.' (if present) is our route.
+ */
+ if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
+ (*route)++;
+ if ((*route) && (**route)) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER: Found route %s", *route);
+ /* We have a route in path or in cookie
+ * Find the worker that has this route defined.
+ */
+ worker = find_route_worker(balancer, *route, r);
+ if (worker && strcmp(*route, worker->s->route)) {
+ /*
+ * Notice that the route of the worker chosen is different from
+ * the route supplied by the client.
+ */
+ apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER: Route changed from %s to %s",
+ *route, worker->s->route);
+ }
+ return worker;
+ }
+ else
+ return NULL;
+}
+
+static proxy_worker *find_best_worker(proxy_balancer *balancer,
+ request_rec *r)
+{
+ proxy_worker *candidate = NULL;
+ apr_status_t rv;
+
+ if ((rv = PROXY_THREAD_LOCK(balancer)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "proxy: CLUSTER: (%s). Lock failed for find_best_worker()", balancer->name);
+ return NULL;
+ }
+
+ candidate = (*balancer->lbmethod->finder)(balancer, r);
+
+ if (candidate)
+ candidate->s->elected++;
+
+/*
+ PROXY_THREAD_UNLOCK(balancer);
+ return NULL;
+*/
+
+ if ((rv = PROXY_THREAD_UNLOCK(balancer)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "proxy: CLUSTER: (%s). Unlock failed for find_best_worker()", balancer->name);
+ }
+
+ if (candidate == NULL) {
+ /* All the workers are in error state or disabled.
+ * If the balancer has a timeout sleep for a while
+ * and try again to find the worker. The chances are
+ * that some other thread will release a connection.
+ * By default the timeout is not set, and the server
+ * returns SERVER_BUSY.
+ */
+#if APR_HAS_THREADS
+ if (balancer->timeout) {
+ /* XXX: This can perhaps be build using some
+ * smarter mechanism, like tread_cond.
+ * But since the statuses can came from
+ * different childs, use the provided algo.
+ */
+ apr_interval_time_t timeout = balancer->timeout;
+ apr_interval_time_t step, tval = 0;
+ /* Set the timeout to 0 so that we don't
+ * end in infinite loop
+ */
+ balancer->timeout = 0;
+ step = timeout / 100;
+ while (tval < timeout) {
+ apr_sleep(step);
+ /* Try again */
+ if ((candidate = find_best_worker(balancer, r)))
+ break;
+ tval += step;
+ }
+ /* restore the timeout */
+ balancer->timeout = timeout;
+ }
+#endif
+ }
+ return candidate;
+}
+
+static int rewrite_url(request_rec *r, proxy_worker *worker,
+ char **url)
+{
+ const char *scheme = strstr(*url, "://");
+ const char *path = NULL;
+
+ if (scheme)
+ path = ap_strchr_c(scheme + 3, '/');
+
+ /* we break the URL into host, port, uri */
+ if (!worker) {
+ return ap_proxyerror(r, HTTP_BAD_REQUEST, apr_pstrcat(r->pool,
+ "missing worker. URI cannot be parsed: ", *url,
+ NULL));
+ }
+
+ *url = apr_pstrcat(r->pool, worker->name, path, NULL);
+
+ return OK;
+}
+
+/*
+ * Find a worker for mod_proxy logic
+ */
+static int proxy_cluster_pre_request(proxy_worker **worker,
+ proxy_balancer **balancer,
+ request_rec *r,
+ proxy_server_conf *conf, char **url)
+{
+ int access_status;
+ proxy_worker *runtime;
+ char *route = NULL;
+ char *sticky = NULL;
+ apr_status_t rv;
+
+ *worker = NULL;
+ /* Step 1: check if the url is for us
+ * The url we can handle starts with 'balancer://'
+ * If balancer is already provided skip the search
+ * for balancer, because this is failover attempt.
+ */
+ if (!*balancer &&
+ !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url)))
+ return DECLINED;
+
+ /* Step 2: find the session route */
+
+ runtime = find_session_route(*balancer, r, &route, &sticky, url);
+ /* Lock the LoadBalancer
+ * XXX: perhaps we need the process lock here
+ */
+ if ((rv = PROXY_THREAD_LOCK(*balancer)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "proxy: CLUSTER: (%s). Lock failed for pre_request",
+ (*balancer)->name);
+ return DECLINED;
+ }
+ if (runtime) {
+ int i, total_factor = 0;
+ proxy_worker *workers;
+ /* We have a sticky load balancer
+ * Update the workers status
+ * so that even session routes get
+ * into account.
+ */
+ workers = (proxy_worker *)(*balancer)->workers->elts;
+ for (i = 0; i < (*balancer)->workers->nelts; i++) {
+ /* Take into calculation only the workers that are
+ * not in error state or not disabled.
+ *
+ * TODO: Abstract the below, since this is dependent
+ * on the LB implementation
+ */
+ if (PROXY_WORKER_IS_USABLE(workers)) {
+ workers->s->lbstatus += workers->s->lbfactor;
+ total_factor += workers->s->lbfactor;
+ }
+ workers++;
+ }
+ runtime->s->lbstatus -= total_factor;
+ runtime->s->elected++;
+
+ *worker = runtime;
+ }
+ else if (route && (*balancer)->sticky_force) {
+ int i, member_of = 0;
+ proxy_worker *workers;
+ /*
+ * We have a route provided that doesn't match the
+ * balancer name. See if the provider route is the
+ * member of the same balancer in which case return 503
+ */
+ workers = (proxy_worker *)(*balancer)->workers->elts;
+ for (i = 0; i < (*balancer)->workers->nelts; i++) {
+ if (*(workers->s->route) && strcmp(workers->s->route, route) == 0) {
+ member_of = 1;
+ break;
+ }
+ workers++;
+ }
+ if (member_of) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "proxy: CLUSTER: (%s). All workers are in error state for route (%s)",
+ (*balancer)->name, route);
+ if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "proxy: CLUSTER: (%s). Unlock failed for pre_request",
+ (*balancer)->name);
+ }
+ return HTTP_SERVICE_UNAVAILABLE;
+ }
+ }
+
+ if ((rv = PROXY_THREAD_UNLOCK(*balancer)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "proxy: CLUSTER: (%s). Unlock failed for pre_request",
+ (*balancer)->name);
+ }
+ if (!*worker) {
+ runtime = find_best_worker(*balancer, r);
+ if (!runtime) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "proxy: CLUSTER: (%s). All workers are in error state",
+ (*balancer)->name);
+
+ return HTTP_SERVICE_UNAVAILABLE;
+ }
+ if ((*balancer)->sticky && runtime) {
+ /*
+ * This balancer has sticky sessions and the client either has not
+ * supplied any routing information or all workers for this route
+ * including possible redirect and hotstandby workers are in error
+ * state, but we have found another working worker for this
+ * balancer where we can send the request. Thus notice that we have
+ * changed the route to the backend.
+ */
+ apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+ }
+ *worker = runtime;
+ }
+
+ /* Add balancer/worker info to env. */
+ apr_table_setn(r->subprocess_env,
+ "BALANCER_NAME", (*balancer)->name);
+ apr_table_setn(r->subprocess_env,
+ "BALANCER_WORKER_NAME", (*worker)->name);
+ apr_table_setn(r->subprocess_env,
+ "BALANCER_WORKER_ROUTE", (*worker)->s->route);
+
+ /* Rewrite the url from 'balancer://url'
+ * to the 'worker_scheme://worker_hostname[:worker_port]/url'
+ * This replaces the balancers fictional name with the
+ * real hostname of the elected worker.
+ */
+ access_status = rewrite_url(r, *worker, url);
+ /* Add the session route to request notes if present */
+ if (route) {
+ apr_table_setn(r->notes, "session-sticky", sticky);
+ apr_table_setn(r->notes, "session-route", route);
+
+ /* Add session info to env. */
+ apr_table_setn(r->subprocess_env,
+ "BALANCER_SESSION_STICKY", sticky);
+ apr_table_setn(r->subprocess_env,
+ "BALANCER_SESSION_ROUTE", route);
+ }
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "proxy: CLUSTER (%s) worker (%s) rewritten to %s",
+ (*balancer)->name, (*worker)->name, *url);
+
+ return access_status;
+}
+
+/*
* Register the hooks on our module.
*/
static void proxy_cluster_hooks(apr_pool_t *p)
@@ -1141,6 +1512,10 @@
/* check the url and give the mapping to mod_proxy */
ap_hook_translate_name(proxy_cluster_trans, aszPre, aszSucc, APR_HOOK_FIRST);
+
+ proxy_hook_canon_handler(proxy_cluster_canon, NULL, NULL, APR_HOOK_FIRST);
+
+ proxy_hook_pre_request(proxy_cluster_pre_request, NULL, NULL, APR_HOOK_FIRST);
}
static void *create_proxy_cluster_dir_config(apr_pool_t *p, char *dir)
16 years, 7 months
JBoss Native SVN: r1594 - in sandbox/httpd/src/native: mod_manager and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-07 03:49:47 -0400 (Wed, 07 May 2008)
New Revision: 1594
Added:
sandbox/httpd/src/native/common/balancer.c
sandbox/httpd/src/native/common/balancer.h
Modified:
sandbox/httpd/src/native/common/Makefile.in
sandbox/httpd/src/native/mod_manager/Makefile.in
sandbox/httpd/src/native/mod_manager/mod_manager.c
sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add the table to store balancers.
Logic to create it. (From the ManagerBalancerName name for the moment).
Modified: sandbox/httpd/src/native/common/Makefile.in
===================================================================
--- sandbox/httpd/src/native/common/Makefile.in 2008-05-06 15:24:35 UTC (rev 1593)
+++ sandbox/httpd/src/native/common/Makefile.in 2008-05-07 07:49:47 UTC (rev 1594)
@@ -15,7 +15,7 @@
INCLUDES=-I$(APACHE_BASE)/include/
LINK_PROG = $(LIBTOOL) $(LTFLAGS) --mode=link $(LT_LDFLAGS) $(COMPILE) $(ALL_LDFLAGS) -o $@
-OBJS=sharedmem_util.lo node.lo context.lo host.lo
+OBJS=sharedmem_util.lo node.lo context.lo host.lo balancer.lo
all: $(OBJS)
Added: sandbox/httpd/src/native/common/balancer.c
===================================================================
--- sandbox/httpd/src/native/common/balancer.c (rev 0)
+++ sandbox/httpd/src/native/common/balancer.c 2008-05-07 07:49:47 UTC (rev 1594)
@@ -0,0 +1,228 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2008 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+/**
+ * @file balancer.c
+ * @brief balancer description Storage Module for Apache
+ *
+ * @defgroup MEM balancers
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+
+#include "balancer.h"
+#include "slotmem.h"
+
+struct mem {
+ ap_slotmem_t *slotmem;
+ const slotmem_storage_method *storage;
+ int num;
+ apr_pool_t *p;
+};
+
+static mem_t * create_attach_mem_balancer(char *string, int *num, int type, apr_pool_t *p) {
+ mem_t *ptr;
+ const char *storename;
+ apr_status_t rv;
+
+ ptr = apr_pcalloc(p, sizeof(mem_t));
+ if (!ptr) {
+ return NULL;
+ }
+ ptr->storage = mem_getstorage(p, "shared");
+ if (!ptr->storage) {
+ return NULL;
+ }
+ storename = apr_pstrcat(p, string, BALANCEREXE, NULL);
+ if (type)
+ rv = ptr->storage->ap_slotmem_create(&ptr->slotmem, storename, sizeof(balancerinfo_t), *num, p);
+ else {
+ apr_size_t size = sizeof(balancerinfo_t);
+ rv = ptr->storage->ap_slotmem_attach(&ptr->slotmem, storename, &size, num, p);
+ }
+ if (rv != APR_SUCCESS) {
+ return NULL;
+ }
+ ptr->num = *num;
+ ptr->p = p;
+ return ptr;
+}
+/**
+ * Insert(alloc) and update a balancer record in the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+static apr_status_t insert_update(void* mem, void **data, int id, apr_pool_t *pool)
+{
+ balancerinfo_t *in = (balancerinfo_t *)*data;
+ balancerinfo_t *ou = (balancerinfo_t *)mem;
+ if (strcmp(in->balancer, ou->balancer) == 0) {
+ memcpy(ou, in, sizeof(balancerinfo_t));
+ ou->id = id;
+ ou->updatetime = apr_time_sec(apr_time_now());
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+apr_status_t insert_update_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou;
+ int ident;
+
+ balancer->id = 0;
+ rv = s->storage->ap_slotmem_do(s->slotmem, insert_update, &balancer, s->p);
+ if (balancer->id != 0 && rv == APR_SUCCESS) {
+ return APR_SUCCESS; /* updated */
+ }
+
+ /* we have to insert it */
+ rv = s->storage->ap_slotmem_alloc(s->slotmem, &ident, (void **) &ou);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ memcpy(ou, balancer, sizeof(balancerinfo_t));
+ ou->id = ident;
+ ou->updatetime = apr_time_sec(apr_time_now());
+
+ return APR_SUCCESS;
+}
+
+/**
+ * read a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to read from the shared table.
+ * @return address of the read balancer or NULL if error.
+ */
+static apr_status_t loc_read_balancer(void* mem, void **data, int id, apr_pool_t *pool) {
+ balancerinfo_t *in = (balancerinfo_t *)*data;
+ balancerinfo_t *ou = (balancerinfo_t *)mem;
+
+ if (strcmp(in->balancer, ou->balancer) == 0) {
+ *data = ou;
+ return APR_SUCCESS;
+ }
+ return APR_NOTFOUND;
+}
+APR_DECLARE(balancerinfo_t *) read_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou = balancer;
+
+ if (balancer->id)
+ rv = s->storage->ap_slotmem_mem(s->slotmem, balancer->id, (void **) &ou);
+ else {
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_balancer, &ou, s->p);
+ }
+ if (rv == APR_SUCCESS)
+ return ou;
+ return NULL;
+}
+/**
+ * get a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer address where the balancer is locate in the shared table.
+ * @param ids in the balancer table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_balancer(mem_t *s, balancerinfo_t **balancer, int ids)
+{
+ return(s->storage->ap_slotmem_mem(s->slotmem, ids, (void **) balancer));
+}
+
+/**
+ * remove(free) a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_balancer(mem_t *s, balancerinfo_t *balancer)
+{
+ apr_status_t rv;
+ balancerinfo_t *ou = balancer;
+ if (balancer->id)
+ s->storage->ap_slotmem_free(s->slotmem, balancer->id, balancer);
+ else {
+ /* XXX: for the moment January 2007 ap_slotmem_free only uses ident to remove */
+ rv = s->storage->ap_slotmem_do(s->slotmem, loc_read_balancer, &ou, s->p);
+ if (rv == APR_SUCCESS)
+ rv = s->storage->ap_slotmem_free(s->slotmem, ou->id, balancer);
+ }
+ return rv;
+}
+
+/*
+ * get the ids for the used (not free) balancers in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_balancer(mem_t *s, int *ids)
+{
+ return (s->storage->ap_slotmem_get_used(s->slotmem, ids));
+}
+
+/*
+ * read the size of the table.
+ * @param pointer to the shared table.
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_balancer(mem_t *s)
+{
+ return (s->storage->ap_slotmem_get_max_size(s->slotmem));
+}
+
+/**
+ * attach to the shared balancer table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * get_mem_balancer(char *string, int *num, apr_pool_t *p)
+{
+ return(create_attach_mem_balancer(string, num, 0, p));
+}
+/**
+ * create a shared balancer table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+mem_t * create_mem_balancer(char *string, int *num, apr_pool_t *p)
+{
+ return(create_attach_mem_balancer(string, num, 1, p));
+}
Added: sandbox/httpd/src/native/common/balancer.h
===================================================================
--- sandbox/httpd/src/native/common/balancer.h (rev 0)
+++ sandbox/httpd/src/native/common/balancer.h 2008-05-07 07:49:47 UTC (rev 1594)
@@ -0,0 +1,144 @@
+/*
+ * mod_cluster
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+ */
+
+#ifndef BALANCER_H
+#define BALANCER_H
+
+/**
+ * @file balancer.h
+ * @brief balancer description Storage Module for Apache
+ *
+ * @defgroup MEM balancers
+ * @ingroup APACHE_MODS
+ * @{
+ */
+
+#define BALANCEREXE ".balancers"
+
+#ifndef MEM_T
+typedef struct mem mem_t;
+#define MEM_T
+#endif
+
+/* status of the balancer as read/store in httpd. */
+struct balancerinfo {
+ char balancer[40]; /* Name of the balancer */
+
+ unsigned long updatetime; /* time of last received message */
+ int id; /* id in table */
+};
+typedef struct balancerinfo balancerinfo_t;
+
+
+/**
+ * Insert(alloc) and update a balancer record in the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to store in the shared table.
+ * @return APR_SUCCESS if all went well
+ *
+ */
+APR_DECLARE(apr_status_t) insert_update_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/**
+ * read a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to read from the shared table.
+ * @return address of the read balancer or NULL if error.
+ */
+APR_DECLARE(balancerinfo_t *) read_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/**
+ * get a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer address of the balancer read from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) get_balancer(mem_t *s, balancerinfo_t **balancer, int ids);
+
+/**
+ * remove(free) a balancer record from the shared table
+ * @param pointer to the shared table.
+ * @param balancer balancer to remove from the shared table.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) remove_balancer(mem_t *s, balancerinfo_t *balancer);
+
+/*
+ * get the ids for the used (not free) balancers in the table
+ * @param pointer to the shared table.
+ * @param ids array of int to store the used id (must be big enough).
+ * @return number of balancer existing or -1 if error.
+ */
+APR_DECLARE(int) get_ids_used_balancer(mem_t *s, int *ids);
+
+/*
+ * get the size of the table (max size).
+ * @param pointer to the shared table.
+ * @return size of the existing table or -1 if error.
+ */
+APR_DECLARE(int) get_max_size_balancer(mem_t *s);
+
+/**
+ * attach to the shared balancer table
+ * @param name of an existing shared table.
+ * @param address to store the size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) get_mem_balancer(char *string, int *num, apr_pool_t *p);
+/**
+ * create a shared balancer table
+ * @param name to use to create the table.
+ * @param size of the shared table.
+ * @param p pool to use for allocations.
+ * @return address of struct used to access the table.
+ */
+APR_DECLARE(mem_t *) create_mem_balancer(char *string, int *num, apr_pool_t *p);
+
+/**
+ * provider for the mod_proxy_cluster or mod_jk modules.
+ */
+struct balancer_storage_method {
+/**
+ * the balancer corresponding to the ident
+ * @param ids ident of the balancer to read.
+ * @param balancer address of pointer to return the balancer.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(apr_status_t) (* read_balancer)(int ids, balancerinfo_t **balancer);
+/**
+ * read the list of ident of used balancers.
+ * @param ids address to store the idents.
+ * @return APR_SUCCESS if all went well
+ */
+APR_DECLARE(int) (* get_ids_used_balancer)(int *ids);
+/**
+ * read the max number of balancers in the shared table
+ */
+APR_DECLARE(int) (*get_max_size_balancer)();
+};
+#endif /*BALANCER_H*/
Modified: sandbox/httpd/src/native/mod_manager/Makefile.in
===================================================================
--- sandbox/httpd/src/native/mod_manager/Makefile.in 2008-05-06 15:24:35 UTC (rev 1593)
+++ sandbox/httpd/src/native/mod_manager/Makefile.in 2008-05-07 07:49:47 UTC (rev 1594)
@@ -16,7 +16,7 @@
# For .deps.
builddir = @MANAGER_BASE@
-MOD_OBJS_LO=../common/node.lo ../common/host.lo ../common/context.lo ../common/sharedmem_util.lo
+MOD_OBJS_LO=../common/node.lo ../common/host.lo ../common/context.lo ../common/balancer.lo ../common/sharedmem_util.lo
include $(APACHE_BASE)/build/rules.mk
SH_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CC) -I../common -prefer-pic -c $< && touch $@
Modified: sandbox/httpd/src/native/mod_manager/mod_manager.c
===================================================================
--- sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-05-06 15:24:35 UTC (rev 1593)
+++ sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-05-07 07:49:47 UTC (rev 1594)
@@ -27,6 +27,7 @@
#include "node.h"
#include "host.h"
#include "context.h"
+#include "balancer.h"
#define DEFMAXCONTEXT 100
#define DEFMAXNODE 10
@@ -36,6 +37,7 @@
mem_t *contextstatsmem = NULL;
mem_t *nodestatsmem = NULL;
mem_t *hoststatsmem = NULL;
+mem_t *balancerstatsmem = NULL;
module AP_MODULE_DECLARE_DATA manager_module;
@@ -119,6 +121,28 @@
loc_get_max_size_host
};
+/*
+ * routines for the balancer_storage_method
+ */
+static apr_status_t loc_read_balancer(int ids, balancerinfo_t **balancer)
+{
+ return (get_balancer(balancerstatsmem, balancer, ids));
+}
+static int loc_get_ids_used_balancer(int *ids)
+{
+ return(get_ids_used_balancer(balancerstatsmem, ids));
+}
+static int loc_get_max_size_balancer()
+{
+ return(get_max_size_balancer(balancerstatsmem));
+}
+static const struct balancer_storage_method balancer_storage =
+{
+ loc_read_balancer,
+ loc_get_ids_used_balancer,
+ loc_get_max_size_balancer
+};
+
/* helper for the handling of the Alias: host1,... Context: context1,... */
struct cluster_host {
char *host;
@@ -137,15 +161,18 @@
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(ptemp, mconf->basefilename, ".node", NULL);
context = apr_pstrcat(ptemp, mconf->basefilename, ".context", NULL);
- context = apr_pstrcat(ptemp, mconf->basefilename, ".host", NULL);
+ host = apr_pstrcat(ptemp, mconf->basefilename, ".host", NULL);
+ balancer = apr_pstrcat(ptemp, mconf->basefilename, ".balancer", NULL);
} else {
node = "manager.node";
context = "manager.context";
- context = "manager.host";
+ host = "manager.host";
+ host = "manager.balancer";
}
nodestatsmem = create_mem_node(node, &mconf->maxnode, p);
@@ -154,18 +181,24 @@
return !OK;
}
- contextstatsmem = create_mem_context(node, &mconf->maxcontext, p);
+ contextstatsmem = create_mem_context(context, &mconf->maxcontext, p);
if (contextstatsmem == NULL) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_context failed");
return !OK;
}
- hoststatsmem = create_mem_host(node, &mconf->maxhost, p);
+ hoststatsmem = create_mem_host(host, &mconf->maxhost, p);
if (hoststatsmem == NULL) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_host failed");
return !OK;
}
+ balancerstatsmem = create_mem_balancer(balancer, &mconf->maxhost, p);
+ if (balancerstatsmem == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "create_mem_balancer failed");
+ return !OK;
+ }
+
sharedmem_initialize_cleanup(p);
return OK;
}
@@ -760,6 +793,7 @@
ap_register_provider(p, "manager" , "shared", "0", &node_storage);
ap_register_provider(p, "manager" , "shared", "1", &host_storage);
ap_register_provider(p, "manager" , "shared", "2", &context_storage);
+ ap_register_provider(p, "manager" , "shared", "3", &balancer_storage);
}
/*
Modified: sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-06 15:24:35 UTC (rev 1593)
+++ sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-07 07:49:47 UTC (rev 1594)
@@ -43,6 +43,7 @@
static struct node_storage_method *node_storage = NULL;
static struct host_storage_method *host_storage = NULL;
static struct context_storage_method *context_storage = NULL;
+static struct balancer_storage_method *balancer_storage = NULL;
/*
* XXX: Should use the proxy_util.c one?.
@@ -189,6 +190,8 @@
proxy_worker *worker;
int i, j;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "create_workers_node starting");
worker = (proxy_worker *)conf->workers->elts;
for (i = 0; i < conf->workers->nelts; i++) {
/* check the id against the table of used ids */
@@ -210,8 +213,27 @@
"create_workers_node can't read id %d", ids[j]);
continue;
}
- proxy_balancer *balancer = ap_proxy_get_balancer(pool, conf,
- apr_pstrcat(pool, "balancer://", node->balancer, NULL));
+ char *name = apr_pstrcat(pool, "balancer://", node->balancer, NULL);
+ proxy_balancer *balancer = ap_proxy_get_balancer(pool, conf, name);
+ if (!balancer) {
+ /* Create one */
+ ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ "create_workers_node: Create balancer %s", name);
+ balancer = apr_array_push(conf->balancers);
+ memset(balancer, 0, sizeof(proxy_balancer));
+ balancer->name = apr_pstrdup(conf->pool, name);
+ balancer->lbmethod = ap_lookup_provider(PROXY_LBMETHOD, "cluster_bytraffic", "0");
+ balancer->workers = apr_array_make(conf->pool, 5, sizeof(proxy_worker));
+ /* XXX Is this a right place to create mutex */
+#if APR_HAS_THREADS
+ if (apr_thread_mutex_create(&(balancer->mutex),
+ APR_THREAD_MUTEX_DEFAULT, conf->pool) != APR_SUCCESS) {
+ /* XXX: Do we need to log something here */
+ ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
+ "create_workers_node: Can't create lock for balancer");
+ }
+#endif
+ }
if (balancer) {
create_worker(conf, balancer, server, &worker, node);
} else {
@@ -220,6 +242,8 @@
}
}
}
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
+ "create_workers_node done");
}
}
@@ -453,6 +477,122 @@
}
/*
+ * Check that the request has a sessionid (even invalid)
+ * Use the name of the balancer.
+ */
+static int hassession_byname(request_rec *r, char *balancer_name, proxy_server_conf *conf)
+{
+ proxy_balancer *balancer;
+ char *route;
+ char *uri = r->filename + 6;
+ char *sticky_path, *sticky, *path;
+ int i;
+
+ balancer = (proxy_balancer *)conf->balancers->elts;
+ for (i = 0; i < conf->balancers->nelts; i++) {
+ if (strcasecmp(balancer->name, uri) == 0)
+ break;
+ }
+
+ /* XXX: We don't find the balancer, that is BAD */
+ if (i == conf->balancers->nelts)
+ return 0;
+
+ if (balancer->sticky == NULL)
+ return 0;
+
+ /* for 2.2.x the sticky parameter may contain 2 values */
+ sticky = sticky_path = apr_pstrdup(r->pool, balancer->sticky);
+ if ((path = strchr(sticky, '|'))) {
+ *path++ = '\0';
+ sticky_path = path;
+ }
+ route = get_path_param(r->pool, uri , sticky_path);
+ if (route == NULL)
+ route = get_cookie_param(r, sticky);
+ if (route) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "mod_proxy_cluster: found route %s", route);
+ return 1;
+ }
+ return 0;
+}
+/*
+ * Search the balancer that corresponds to the pair context/host
+ */
+static char *get_context_host_balancer(request_rec *r)
+{
+ void *sconf = r->server->module_config;
+ proxy_server_conf *conf = (proxy_server_conf *)
+ ap_get_module_config(sconf, &proxy_module);
+
+ int sizenode = node_storage->get_max_size_node();
+ int n;
+ int *nodes = apr_palloc(r->pool, sizeof(int)*sizenode);
+ sizenode = node_storage->get_ids_used_node(nodes);
+ for (n=0; n<sizenode; n++) {
+ nodeinfo_t *node;
+ node_storage->read_node(nodes[n], &node);
+
+ /*
+ * check the hosts and contexts
+ * A node may have several virtual hosts and
+ * each virtual hosts may have several context
+ */
+ int sizevhost = host_storage->get_max_size_host();
+ int *vhosts = apr_palloc(r->pool, sizeof(int)*sizevhost);
+ sizevhost = host_storage->get_ids_used_host(vhosts);
+ int i;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_context_host_balancer testing node %s", node->mess.JVMRoute);
+ for (i=0; i<sizevhost; i++) {
+ hostinfo_t *vhost;
+ host_storage->read_host(vhosts[i], &vhost);
+ if (vhost->node == node->mess.id) {
+ /* XXX Check the virtual host */
+
+ /* Check the contexts */
+ int sizecontext = context_storage->get_max_size_context();
+ int *contexts = apr_palloc(r->pool, sizeof(int)*sizecontext);
+ sizecontext = context_storage->get_ids_used_context(contexts);
+ int j;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_context_host_balancer testing host %s", vhost->host);
+ for (j=0; j<sizecontext; j++) {
+ contextinfo_t *context;
+ context_storage->read_context(contexts[j], &context);
+ if (context->vhost != vhost->vhost)
+ continue;
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "get_context_host_balancer testing context %s", context->context);
+
+ /* check for /context[/] in the URL */
+ int len = strlen(context->context);
+ if (strncmp(r->uri, context->context, len) == 0) {
+ if (r->uri[len] == '\0' || r->uri[len] == '/') {
+ /* Check status */
+ switch (context->status)
+ {
+ case ENABLED:
+ return node->balancer;
+ break;
+ case DISABLED:
+ /* Only the request with sessionid ok for it */
+ if (hassession_byname(r, node->balancer, conf))
+ return node->balancer;
+ break;
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ return NULL;
+}
+
+/*
* The ModClusterService from the cluster fills the lbfactor values.
* Our logic is a bit different the mod_balancer one. We check the
* context and host to prevent to route to application beeing redeploy or
@@ -528,7 +668,14 @@
return mycandidate;
}
+static const proxy_balancer_method bytraffic =
+{
+ "bytraffic",
+ &find_best_bytraffic,
+ NULL
+};
+
/*
* Check if the socket is still connected
* XXX: Should use the mod_proxy_balancer ones.
@@ -943,22 +1090,47 @@
"proxy_cluster_post_config: Can't find mod_manager for contexts");
return !OK;
}
+ balancer_storage = ap_lookup_provider("manager" , "shared", "3");
+ if (balancer_storage == NULL) {
+ ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s,
+ "proxy_cluster_post_config: Can't find mod_manager for balancers");
+ return !OK;
+ }
return OK;
}
-static const proxy_balancer_method bytraffic =
+/*
+ * See if we could map the request.
+ */
+static int proxy_cluster_trans(request_rec *r)
{
- "bytraffic",
- &find_best_bytraffic,
- NULL
-};
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
+ "proxy_cluster_trans for %d %s %s uri: %s",
+ r->proxyreq, r->filename, r->handler, r->uri);
+ char *balancer = get_context_host_balancer(r);
+ if (balancer) {
+ r->filename = apr_pstrcat(r->pool, "proxy:balancer://", balancer, r->uri, NULL);
+ r->handler = "proxy-server";
+ r->proxyreq = PROXYREQ_REVERSE;
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, r->server,
+ "proxy_cluster_trans using %s uri: %s",
+ balancer, r->filename);
+ return OK; /* Mod_proxy will process it */
+ }
+
+ return DECLINED;
+}
+
/*
* Register the hooks on our module.
*/
static void proxy_cluster_hooks(apr_pool_t *p)
{
+ static const char * const aszPre[]={ "mod_manager.c", NULL };
+ static const char * const aszSucc[]={ "mod_proxy.c", NULL };
+
ap_hook_post_config(proxy_cluster_post_config, NULL, NULL, APR_HOOK_MIDDLE);
/* create the provider for the proxy logic */
@@ -967,6 +1139,8 @@
/* create the "maintenance" thread */
ap_hook_child_init(proxy_cluster_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+ /* check the url and give the mapping to mod_proxy */
+ ap_hook_translate_name(proxy_cluster_trans, aszPre, aszSucc, APR_HOOK_FIRST);
}
static void *create_proxy_cluster_dir_config(apr_pool_t *p, char *dir)
16 years, 8 months
JBoss Native SVN: r1593 - sandbox/httpd/src/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-06 11:24:35 -0400 (Tue, 06 May 2008)
New Revision: 1593
Modified:
sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Cleaning.
Modified: sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-05 14:43:08 UTC (rev 1592)
+++ sandbox/httpd/src/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-05-06 15:24:35 UTC (rev 1593)
@@ -40,8 +40,6 @@
#include "host.h"
#include "context.h"
-static proxy_balancer_method *lbrprovider = NULL;
-static proxy_balancer_method *lbtprovider = NULL;
static struct node_storage_method *node_storage = NULL;
static struct host_storage_method *host_storage = NULL;
static struct context_storage_method *context_storage = NULL;
16 years, 8 months
JBoss Native SVN: r1592 - sandbox/httpd/src/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-05-05 10:43:08 -0400 (Mon, 05 May 2008)
New Revision: 1592
Modified:
sandbox/httpd/src/native/mod_manager/mod_manager.c
Log:
Clean useless code.
Modified: sandbox/httpd/src/native/mod_manager/mod_manager.c
===================================================================
--- sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-05-02 12:33:30 UTC (rev 1591)
+++ sandbox/httpd/src/native/mod_manager/mod_manager.c 2008-05-05 14:43:08 UTC (rev 1592)
@@ -39,12 +39,6 @@
module AP_MODULE_DECLARE_DATA manager_module;
-struct baldata {
- char *balancer;
- int port;
- struct baldata *next;
-};
-
typedef struct mod_manager_config
{
/* base name for the shared memory */
@@ -56,11 +50,7 @@
/* max munber of host supported */
int maxhost;
/* Balancer name */
- /* Balancer name */
char *balancername;
- /* store the balancer names */
- struct baldata *baldata;
-
} mod_manager_config;
/*
@@ -137,29 +127,6 @@
};
/*
- * read the balancer name from the conf and the port of client address
- */
-char * getbalancer(server_rec *s, struct baldata *baldata, apr_sockaddr_t *local_addr)
-{
- char a[128];
- char *ptr;
- int port;
- apr_snprintf(a, sizeof(a), "%pI", local_addr);
- ptr = &a[strlen(a)];
- while (*ptr != ':')
- ptr--;
- port = atoi(ptr+1);
-
- while (baldata && baldata->port != port) {
- baldata = baldata->next;
- }
- if (baldata) {
- return baldata->balancer;
- } else
- return NULL;
-}
-
-/*
* call after parser the configuration.
* create the shared memory.
* XXX: add some code there
@@ -807,7 +774,6 @@
mconf->maxnode = DEFMAXNODE;
mconf->maxhost = DEFMAXHOST;
mconf->balancername = NULL;
- mconf->baldata = NULL;
return mconf;
}
/* XXX: Not needed
@@ -832,7 +798,6 @@
mconf->maxcontext = DEFMAXCONTEXT;
mconf->maxnode = DEFMAXNODE;
mconf->balancername = NULL;
- mconf->baldata = NULL;
if (mconf2->basefilename)
mconf->basefilename = apr_pstrdup(p, mconf2->basefilename);
@@ -859,12 +824,6 @@
else if (mconf1->balancername)
mconf->balancername = mconf1->balancername;
- /* XXX: Shouldn't be the baldata chains duplicated */
- if (mconf2->baldata)
- mconf->baldata = mconf2->baldata;
- else if (mconf1->baldata)
- mconf->baldata = mconf1->baldata;
-
return mconf;
}
16 years, 8 months
JBoss Native SVN: r1591 - in trunk/httpd/httpd-2.2/srclib: iconv and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 08:33:30 -0400 (Fri, 02 May 2008)
New Revision: 1591
Added:
trunk/httpd/httpd-2.2/srclib/iconv/
trunk/httpd/httpd-2.2/srclib/iconv/NMAKEmakefile
Log:
Added httpd iconv makefile
Added: trunk/httpd/httpd-2.2/srclib/iconv/NMAKEmakefile
===================================================================
--- trunk/httpd/httpd-2.2/srclib/iconv/NMAKEmakefile (rev 0)
+++ trunk/httpd/httpd-2.2/srclib/iconv/NMAKEmakefile 2008-05-02 12:33:30 UTC (rev 1591)
@@ -0,0 +1,118 @@
+# Copyright 2001-2007 The Apache Software Foundation or its licensors, as
+# applicable.
+#
+# 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,
+# 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.
+#
+# ====================================================================
+#
+# NMAKEmakefile Master LIBICONV makefile.
+# Usage:
+# DLL=1 Build DLL version
+# DEBUG=1 Build DEBUG version of LIBICONV
+#
+# Originally contributed by Mladen Turk <mturk redhat.com>
+#
+# ====================================================================
+#
+
+!IF !DEFINED(ICONV_DECLARE_STATIC) || "$(ICONV_DECLARE_STATIC)" == ""
+TARGET=DLL
+CFLAGS = -DICONV_DECLARE_EXPORT -DHAVE_CONFIG_H -DNO_XMALLOC -DBUILDING_DLL
+PROJECT = libiconv-1
+!ELSE
+TARGET=LIB
+CFLAGS = -DICONV_DECLARE_STATIC -DHAVE_CONFIG_H -DNO_XMALLOC
+PROJECT = iconv-1
+!ENDIF
+
+VMAJOR = 1
+VMINOR = 12
+VPATCH = 0
+VSTRING= "$(VMAJOR).$(VMINOR).$(VPATCH)"
+
+!IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
+SRCDIR = .
+!ENDIF
+
+!include <..\..\NMAKEcommon.inc>
+!include <..\..\NMAKEhttpd.inc>
+
+INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\lib -I$(SRCDIR)\libcharset\include
+PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)-src
+OBJECTS = \
+ $(WORKDIR)\localcharset.obj \
+ $(WORKDIR)\relocatable.obj \
+ $(WORKDIR)\iconv.obj
+
+HEADERS = \
+ $(SRCDIR)\include\iconv.h \
+ $(SRCDIR)\lib\config.h \
+ $(SRCDIR)\libcharset\include\libcharset.h \
+ $(SRCDIR)\libcharset\include\localcharset.h
+
+!IF "$(TARGET)" == "DLL"
+BUILDBIN = $(WORKDIR)\$(PROJECT).dll
+BUILDPDB = $(WORKDIR)\$(PROJECT).pdb
+BUILDRES = $(WORKDIR)\$(PROJECT).res
+BUILDMFT = $(BUILDBIN).manifest
+!ELSE
+BUILDBIN = $(WORKDIR)\$(PROJECT).lib
+!ENDIF
+
+all : $(BUILDINS) $(WORKDIR) $(HEADERS) $(BUILDBIN)
+
+$(WORKDIR) :
+ @$(MAKEWORKDIR)
+
+.SUFFIXES : .hw
+
+{$(SRCDIR)\lib}.hw{$(SRCDIR)\lib}.h:
+ @copy /Y $< $@ >NUL
+
+{$(SRCDIR)\include}.hw{$(SRCDIR)\include}.h:
+ @copy /Y $< $@ >NUL
+
+{$(SRCDIR)\libcharset}.hw{$(SRCDIR)\libcharset}.h:
+ @copy /Y $< $@ >NUL
+
+{$(SRCDIR)\libcharset\include}.hw{$(SRCDIR)\libcharset\include}.h:
+ @copy /Y $< $@ >NUL
+
+{$(SRCDIR)\lib}.c{$(WORKDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+{$(SRCDIR)\libcharset\lib}.c{$(WORKDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+
+$(OBJECTS): $(SRCDIR)\include\*.h $(SRCDIR)\libcharset\include\*.h
+
+!IF "$(TARGET)" == "DLL"
+$(BUILDRES): $(SRCDIR)\windows\libiconv.rc $(HEADERS) $(SRCDIR)\include\*.h
+ $(RC) $(RCFLAGS) /i "$(SRCDIR)\include" /d PACKAGE_VERSION_MAJOR=$(VMAJOR) /d PACKAGE_VERSION_MINOR=$(VMINOR) /d PACKAGE_VERSION_SUBMINOR=$(VPATCH) /d PACKAGE_VERSION_STRING=$(VSTRING) /fo $(BUILDRES) $(SRCDIR)\windows\libiconv.rc
+$(BUILDBIN): $(WORKDIR) $(HEADERS) $(OBJECTS) $(BUILDRES)
+ $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) /pdb:$(BUILDPDB) /out:$(BUILDBIN)
+ IF EXIST $(BUILDMFT) \
+ mt -nologo -manifest $(BUILDMFT) -outputresource:$(BUILDBIN);2
+!ELSE
+$(BUILDBIN): $(WORKDIR) $(OBJECTS)
+ $(LINK) $(LFLAGS) $(OBJECTS) /out:$(BUILDBIN)
+!ENDIF
+
+clean:
+ @$(CLEANTARGET)
+
+install: $(BUILDINS) $(WORKDIR) $(HEADERS) $(BUILDBIN)
+ @xcopy "$(SRCDIR)\include\iconv.h" "$(BUILDINC)" /Y /Q
+ @xcopy "$(WORKDIR)\*.lib" "$(BUILDLIB)" /Y /Q
+ @xcopy "$(WORKDIR)\*.dll" "$(BUILDOUT)" /Y /Q 2>NUL
Property changes on: trunk/httpd/httpd-2.2/srclib/iconv/NMAKEmakefile
___________________________________________________________________
Name: svn:eol-style
+ native
16 years, 8 months
JBoss Native SVN: r1590 - trunk/httpd/httpd-2.2.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 08:14:40 -0400 (Fri, 02 May 2008)
New Revision: 1590
Modified:
trunk/httpd/httpd-2.2/NMAKEhttpd.inc
Log:
Ooop, faulty commit
Modified: trunk/httpd/httpd-2.2/NMAKEhttpd.inc
===================================================================
--- trunk/httpd/httpd-2.2/NMAKEhttpd.inc 2008-05-02 12:13:01 UTC (rev 1589)
+++ trunk/httpd/httpd-2.2/NMAKEhttpd.inc 2008-05-02 12:14:40 UTC (rev 1590)
@@ -71,7 +71,6 @@
$(PREFIX)\error\include\~ \
$(PREFIX)\conf\extra\~ \
$(PREFIX)\conf\default\extra\~
- $(PREFIX)\conf\default\extra\~
$(DISTSUBDIRS):
@if not exist "$(@D)\$(NULL)" mkdir $(@D)
16 years, 8 months
JBoss Native SVN: r1589 - in trunk/httpd/httpd-2.2: installer and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 08:13:01 -0400 (Fri, 02 May 2008)
New Revision: 1589
Modified:
trunk/httpd/httpd-2.2/NMAKEhttpd.inc
trunk/httpd/httpd-2.2/installer/installconf.awk
trunk/httpd/httpd-2.2/installer/installconf.bat
Log:
Allow installconf to be run by dbl-click
Modified: trunk/httpd/httpd-2.2/NMAKEhttpd.inc
===================================================================
--- trunk/httpd/httpd-2.2/NMAKEhttpd.inc 2008-05-02 11:59:28 UTC (rev 1588)
+++ trunk/httpd/httpd-2.2/NMAKEhttpd.inc 2008-05-02 12:13:01 UTC (rev 1589)
@@ -71,6 +71,7 @@
$(PREFIX)\error\include\~ \
$(PREFIX)\conf\extra\~ \
$(PREFIX)\conf\default\extra\~
+ $(PREFIX)\conf\default\extra\~
$(DISTSUBDIRS):
@if not exist "$(@D)\$(NULL)" mkdir $(@D)
Modified: trunk/httpd/httpd-2.2/installer/installconf.awk
===================================================================
--- trunk/httpd/httpd-2.2/installer/installconf.awk 2008-05-02 11:59:28 UTC (rev 1588)
+++ trunk/httpd/httpd-2.2/installer/installconf.awk 2008-05-02 12:13:01 UTC (rev 1589)
@@ -33,17 +33,16 @@
gsub( /\\/, "/", serverroot );
gsub( /[ \/]+$/, "", serverroot );
- tstfl = serverroot "/logs/install.log"
confroot = serverroot "/conf/";
confdefault = confroot "default/";
- print "Installing Apache HTTP 2.2 server with" >tstfl;
- print " DomainName : " domainname >tstfl;
- print " ServerName : " servername >tstfl;
- print " ServerAdmin : " serveradmin >tstfl;
- print " ServerPort : " serverport >tstfl;
- print " ServerSslPort : " serverport >tstfl;
- print " ServerRoot : " serverroot >tstfl;
+ print "Installing Apache HTTP 2.2 server with";
+ print " DomainName : " domainname;
+ print " ServerName : " servername;
+ print " ServerAdmin : " serveradmin;
+ print " ServerPort : " serverport;
+ print " ServerSslPort : " serverport;
+ print " ServerRoot : " serverroot;
filelist["httpd.conf"] = "httpd.conf.in";
filelist["extra/httpd-autoindex.conf"] = "extra/httpd-autoindex.conf.in";
@@ -168,17 +167,17 @@
close(srcfl);
if ( close(dstfl) >= 0 ) {
- print "Rewrote " srcfl "\n to " dstfl > tstfl;
+ print "Rewrote " srcfl "\n to " dstfl;
if (WINDOWS) {
gsub(/\//, "\\", srcfl);
}
if (system(delcmd " \"" srcfl "\"")) {
- print "Failed to remove " srcfl > tstfl;
+ print "Failed to remove " srcfl;
} else {
- print "Successfully removed " srcfl > tstfl;
+ print "Successfully removed " srcfl;
}
} else {
- print "Failed to rewrite " srcfl "\n to " dstfl > tstfl;
+ print "Failed to rewrite " srcfl "\n to " dstfl;
}
}
@@ -193,9 +192,9 @@
while ( ( getline < srcfl ) > 0 ) {
print $0 > dstfl;
}
- print "Duplicated " srcfl "\n to " dstfl > tstfl;
+ print "Duplicated " srcfl "\n to " dstfl;
} else {
- print "Existing file " dstfl " preserved" > tstfl;
+ print "Existing file " dstfl " preserved";
}
close(srcfl);
close(dstfl);
Modified: trunk/httpd/httpd-2.2/installer/installconf.bat
===================================================================
--- trunk/httpd/httpd-2.2/installer/installconf.bat 2008-05-02 11:59:28 UTC (rev 1588)
+++ trunk/httpd/httpd-2.2/installer/installconf.bat 2008-05-02 12:13:01 UTC (rev 1589)
@@ -56,4 +56,5 @@
nawk.exe -f installconf.awk -v WINDOWS=1 %HTTPD_DOMAINNAME% %HTTPD_SERVERNAME% %HTTPD_ADMIN% %HTTPD_PORT% %HTTPD_SSLPORT% "%HTTPD_ROOT%"
+if "x%NOPAUSE%" == "x" pause
:cmdEnd
16 years, 8 months
JBoss Native SVN: r1588 - trunk/httpd/httpd-2.2.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 07:59:28 -0400 (Fri, 02 May 2008)
New Revision: 1588
Modified:
trunk/httpd/httpd-2.2/NMAKEmakefile
Log:
Distribute nawk.exe as well
Modified: trunk/httpd/httpd-2.2/NMAKEmakefile
===================================================================
--- trunk/httpd/httpd-2.2/NMAKEmakefile 2008-05-02 11:58:34 UTC (rev 1587)
+++ trunk/httpd/httpd-2.2/NMAKEmakefile 2008-05-02 11:59:28 UTC (rev 1588)
@@ -116,3 +116,4 @@
-@copy /Y "$(SRCDIR)\docs\cgi-examples\printenv" "$(BUILDCGI)\printenv.pl" >NUL
-@copy /Y "$(SRCDIR)\installer\installconf.awk" "$(BUILDOUT)" >NUL
-@copy /Y "$(SRCDIR)\installer\installconf.bat" "$(BUILDOUT)" >NUL
+ -@copy /Y "$(SRCDIR)\installer\nawk.exe" "$(BUILDOUT)" >NUL
16 years, 8 months
JBoss Native SVN: r1587 - trunk/httpd/httpd-2.2/installer.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 07:58:34 -0400 (Fri, 02 May 2008)
New Revision: 1587
Added:
trunk/httpd/httpd-2.2/installer/nawk.exe
Log:
For now add nawk.exe directly here
Added: trunk/httpd/httpd-2.2/installer/nawk.exe
===================================================================
(Binary files differ)
Property changes on: trunk/httpd/httpd-2.2/installer/nawk.exe
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 8 months
JBoss Native SVN: r1586 - trunk/httpd/httpd-2.2/installer.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-05-02 07:55:40 -0400 (Fri, 02 May 2008)
New Revision: 1586
Added:
trunk/httpd/httpd-2.2/installer/installconf.bat
Removed:
trunk/httpd/httpd-2.2/installer/install.bat
Log:
Use correct name
Deleted: trunk/httpd/httpd-2.2/installer/install.bat
===================================================================
--- trunk/httpd/httpd-2.2/installer/install.bat 2008-05-02 11:54:56 UTC (rev 1585)
+++ trunk/httpd/httpd-2.2/installer/install.bat 2008-05-02 11:55:40 UTC (rev 1586)
@@ -1,59 +0,0 @@
-@echo off
-REM Copyright(c) 2007 Red Hat Middleware, LLC,
-REM and individual contributors as indicated by the @authors tag.
-REM See the copyright.txt in the distribution for a
-REM full listing of individual contributors.
-REM
-REM This library is free software; you can redistribute it and/or
-REM modify it under the terms of the GNU Lesser General Public
-REM License as published by the Free Software Foundation; either
-REM version 2 of the License, or (at your option) any later version.
-REM
-REM This library is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-REM Lesser General Public License for more details.
-REM
-REM You should have received a copy of the GNU Lesser General Public
-REM License along with this library in the file COPYING.LIB;
-REM if not, write to the Free Software Foundation, Inc.,
-REM 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-REM
-REM @author Mladen Turk
-REM
-
-
-@if not "%ECHO%" == "" echo %ECHO%
-@if "%OS%" == "Windows_NT" setlocal
-
-if "%OS%" == "Windows_NT" (
-set "DIRNAME=%~dp0%"
-set "PROGNAME=%~nx0%"
-) else (
-echo Detected uncompatible Windows version.
-goto cmdEnd
-)
-
-set LOCAL_DIR=%CD%
-pushd %DIRNAME%..
-set INSTALL_HOME=%CD%
-popd
-
-echo.
-echo Running : %PROGNAME% $LastChangedDate: 2008-04-21 11:25:11 +0200 (Mon, 21 Apr 2008) $
-echo.
-echo Started : %DATE% %TIME%
-echo Params : %*
-echo.
-
-set HTTPD_SERVERNAME=localhost
-set HTTPD_DOMAINNAME=localdomain
-set HTTPD_PORT=8080
-set HTTPD_SSLPORT=8443
-
-set HTTPD_ADMIN=%USERNAME%(a)%HTTPD_SERVERNAME%.%HTTPD_DOMAINNAME%
-set HTTPD_ROOT=%INSTALL_HOME%
-
-
-nawk.exe -f installconf.awk -v WINDOWS=1 %HTTPD_DOMAINNAME% %HTTPD_SERVERNAME% %HTTPD_ADMIN% %HTTPD_PORT% %HTTPD_SSLPORT% "%HTTPD_ROOT%"
-:cmdEnd
Copied: trunk/httpd/httpd-2.2/installer/installconf.bat (from rev 1582, trunk/httpd/httpd-2.2/installer/install.bat)
===================================================================
--- trunk/httpd/httpd-2.2/installer/installconf.bat (rev 0)
+++ trunk/httpd/httpd-2.2/installer/installconf.bat 2008-05-02 11:55:40 UTC (rev 1586)
@@ -0,0 +1,59 @@
+@echo off
+REM Copyright(c) 2007 Red Hat Middleware, LLC,
+REM and individual contributors as indicated by the @authors tag.
+REM See the copyright.txt in the distribution for a
+REM full listing of individual contributors.
+REM
+REM This library is free software; you can redistribute it and/or
+REM modify it under the terms of the GNU Lesser General Public
+REM License as published by the Free Software Foundation; either
+REM version 2 of the License, or (at your option) any later version.
+REM
+REM This library is distributed in the hope that it will be useful,
+REM but WITHOUT ANY WARRANTY; without even the implied warranty of
+REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+REM Lesser General Public License for more details.
+REM
+REM You should have received a copy of the GNU Lesser General Public
+REM License along with this library in the file COPYING.LIB;
+REM if not, write to the Free Software Foundation, Inc.,
+REM 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+REM
+REM @author Mladen Turk
+REM
+
+
+@if not "%ECHO%" == "" echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+if "%OS%" == "Windows_NT" (
+set "DIRNAME=%~dp0%"
+set "PROGNAME=%~nx0%"
+) else (
+echo Detected uncompatible Windows version.
+goto cmdEnd
+)
+
+set LOCAL_DIR=%CD%
+pushd %DIRNAME%..
+set INSTALL_HOME=%CD%
+popd
+
+echo.
+echo Running : %PROGNAME% $LastChangedDate: 2008-04-21 11:25:11 +0200 (Mon, 21 Apr 2008) $
+echo.
+echo Started : %DATE% %TIME%
+echo Params : %*
+echo.
+
+set HTTPD_SERVERNAME=localhost
+set HTTPD_DOMAINNAME=localdomain
+set HTTPD_PORT=8080
+set HTTPD_SSLPORT=8443
+
+set HTTPD_ADMIN=%USERNAME%(a)%HTTPD_SERVERNAME%.%HTTPD_DOMAINNAME%
+set HTTPD_ROOT=%INSTALL_HOME%
+
+
+nawk.exe -f installconf.awk -v WINDOWS=1 %HTTPD_DOMAINNAME% %HTTPD_SERVERNAME% %HTTPD_ADMIN% %HTTPD_PORT% %HTTPD_SSLPORT% "%HTTPD_ROOT%"
+:cmdEnd
16 years, 8 months