Author: jfrederic.clere(a)jboss.com
Date: 2008-06-03 09:19:34 -0400 (Tue, 03 Jun 2008)
New Revision: 1649
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
cleanup and remove my_ap_proxy_add_worker_to_balancer().
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-02 16:45:07 UTC
(rev 1648)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-03 13:19:34 UTC
(rev 1649)
@@ -51,28 +51,13 @@
static struct balancer_storage_method *balancer_storage = NULL;
/*
- * XXX: Should use the proxy_util.c one?.
- */
-static void my_ap_proxy_add_worker_to_balancer(apr_pool_t *pool, proxy_balancer
*balancer,
- proxy_worker *worker)
-{
- proxy_worker *runtime;
-
- runtime = apr_array_push(balancer->workers);
- memcpy(runtime, worker, sizeof(proxy_worker));
- /* Increase the total runtime count */
- proxy_lb_workers++;
-
-}
-
-/*
* Create/Get the worker before using it
*/
static void create_worker(proxy_server_conf *conf, proxy_balancer *balancer,
server_rec *server, proxy_worker **worker,
nodeinfo_t *node)
{
- char url[6+64+7+4]; /* Type :// Host : Port */
+ char url[SCHEMENDSZ+HOSTNODESZ+PORTNODESZ+5]; /* Type :// Host : Port */
char *ptr;
int reuse = 0;
@@ -136,8 +121,31 @@
(*worker)->s->redirect[0] = '\0';
}
- if (!reuse)
- my_ap_proxy_add_worker_to_balancer(conf->pool, balancer, *worker);
+ if (!reuse) {
+ /*
+ * Create the corresponding balancer worker information
+ * copying for proxy_util.c ap_proxy_add_worker_to_balancer
+ */
+ proxy_worker *runtime;
+ runtime = apr_array_push(balancer->workers);
+ memcpy(runtime, (*worker), sizeof(proxy_worker));
+ } else {
+ /* Update the corresponding balancer worker information */
+ proxy_worker *runtime;
+ int i;
+ char name[HOSTNODESZ+PORTNODESZ+2];
+ runtime = (proxy_worker *)balancer->workers->elts;
+ strcpy(name, node->mess.Host);
+ strcat(name, ":");
+ strcat(name, node->mess.Port);
+ for (i = 0; i < balancer->workers->nelts; i++, runtime++) {
+ if (runtime->name) {
+ if (strcmp(name, runtime->name) == 0) {
+ memcpy(runtime, (*worker), sizeof(proxy_worker));
+ }
+ }
+ }
+ }
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
"Created: worker for %s %d (status): %d", url,
(*worker)->id, (*worker)->s->status);
}
@@ -206,8 +214,10 @@
"remove_workers_node %d", i);
if (i == 0) {
/* No connection in use: clean the worker */
- apr_pool_destroy(worker->cp->pool);
- worker->cp->pool = NULL;
+ if (worker->cp->pool) {
+ apr_pool_destroy(worker->cp->pool);
+ worker->cp->pool = NULL;
+ }
worker->id = 0;
/* XXX: How to remove the worker from the apr_array of the balancer */
Show replies by date