Author: jfrederic.clere(a)jboss.com
Date: 2008-06-16 10:33:38 -0400 (Mon, 16 Jun 2008)
New Revision: 1701
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add a mutex and don't retry a broken node.
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-16 13:01:50 UTC
(rev 1700)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-16 14:33:38 UTC
(rev 1701)
@@ -55,6 +55,8 @@
static struct context_storage_method *context_storage = NULL;
static struct balancer_storage_method *balancer_storage = NULL;
+static apr_thread_mutex_t *lock = NULL;
+
/*
* Create/Get the worker before using it
*/
@@ -256,12 +258,16 @@
apr_time_t last;
int notok = 0;
+ apr_thread_mutex_lock(lock);
+
/* Check if we have to do something */
last = node_storage->worker_nodes_need_update(server, pool);
/* nodes_need_update will return 1 if last_updated is zero: first time we are called
*/
- if (last == 0)
+ if (last == 0) {
+ apr_thread_mutex_unlock(lock);
return;
+ }
/* read the ident of the nodes */
id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
@@ -286,6 +292,8 @@
}
if (! notok)
node_storage->worker_nodes_are_updated(server);
+
+ apr_thread_mutex_unlock(lock);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
"update_workers_node done");
}
@@ -704,14 +712,10 @@
if (worker->s->lbfactor < 0 || (worker->s->lbfactor == 0
&& !checking_standby))
continue;
- /* 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.
- */
- if (!PROXY_WORKER_IS_USABLE(worker))
- ap_proxy_retry_worker("BALANCER", worker, r->server);
+ /* If the worker is in error state the STATUS logic will retry it */
+ if (!PROXY_WORKER_IS_USABLE(worker)) {
+ continue;
+ }
/* Take into calculation only the workers that are
* not in error state or not disabled.
@@ -1027,17 +1031,21 @@
/*
* Create a thread per process to make maintenance task.
+ * and the mutex of the node creation.
*/
static void proxy_cluster_child_init(apr_pool_t *p, server_rec *s)
{
apr_status_t rv;
apr_thread_t *wdt;
+ apr_thread_mutex_create(&lock, APR_THREAD_MUTEX_DEFAULT, p);
+
rv = apr_thread_create(&wdt, NULL, proxy_cluster_watchdog_func, s, p);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s,
"proxy_cluster_child_init: apr_thread_create failed");
}
+
}
static int proxy_cluster_post_config(apr_pool_t *p, apr_pool_t *plog,