Author: jfrederic.clere(a)jboss.com
Date: 2008-10-23 09:18:58 -0400 (Thu, 23 Oct 2008)
New Revision: 1992
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Use the information read in the trans().
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 08:56:12 UTC
(rev 1991)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-10-23 13:18:58 UTC
(rev 1992)
@@ -777,7 +777,7 @@
* We also try the domain.
*/
static proxy_worker *internal_find_best_byrequests(proxy_balancer *balancer,
- request_rec *r, char *domain, int
failoverdomain)
+ request_rec *r, const char *domain, int
failoverdomain)
{
int i;
proxy_worker *worker;
@@ -1279,6 +1279,7 @@
"cluster: Found balancer %s for %s",
ou->mess.balancer, route);
/* here we have the route and domain for find_session_route ...
*/
apr_table_setn(r->notes, "CLUSTER_ROUTE", route);
+ apr_table_setn(r->notes, "CLUSTER_STICKY_USED",
sticky_used);
if (ou->mess.Domain[0] != '\0') {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"cluster: Found domain %s for %s",
ou->mess.Domain, route);
@@ -1410,10 +1411,10 @@
*/
static proxy_worker *find_session_route(proxy_balancer *balancer,
request_rec *r,
- char **route,
- char **sticky_used,
+ const char **route,
+ const char **sticky_used,
char **url,
- char **domain)
+ const char **domain)
{
proxy_worker *worker = NULL;
char *sticky, *sticky_path, *path;
@@ -1423,59 +1424,38 @@
if (! (balancer->sticky_force & STSESSION))
return NULL;
- *route = get_route(r, balancer->sticky, *url, sticky_used);
- if (*route) {
+ /* We already should have the route in the notes for the trans() */
+ *route = apr_table_get(r->notes, "CLUSTER_ROUTE");
+ if (*route && (**route)) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Found value %s for "
- "stickysession %s", *route, balancer->sticky);
- }
+ "cluster: Using route %s", *route);
+ } else
+ return NULL;
- /*
- * If we found a value for sticksession, find the first '.' within.
- * Everything after '.' (if present) is our route.
+ *sticky_used = apr_table_get(r->notes, "CLUSTER_STICKY_USED");
+
+ if (domain)
+ *domain = apr_table_get(r->notes, "CLUSTER_DOMAIN");
+
+ /* We have a route in path or in cookie
+ * Find the worker that has this route defined.
*/
- if ((*route) && ((*route = strchr(*route, '.')) != NULL ))
- (*route)++;
- if ((*route) && (**route)) {
- nodeinfo_t *ou;
- apr_status_t rv;
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: CLUSTER: Found route %s", *route);
- /* Read the domain in case we have to make a failover */
- rv = node_storage->find_node(&ou, *route);
- if (rv == APR_SUCCESS) {
- if (ou->mess.Domain[0] != '\0') {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "proxy: Found domain %s for %s",
ou->mess.Domain, *route);
- if (domain)
- *domain = ou->mess.Domain;
- } else {
- if (domain)
- *domain = NULL;
- }
- }
- /* We have a route in path or in cookie
- * Find the worker that has this route defined.
+ worker = find_route_worker(r, balancer, *route);
+ if (worker && strcmp(*route, worker->s->route)) {
+ /*
+ * Notice that the route of the worker chosen is different from
+ * the route supplied by the client. (mod_proxy compatibility).
*/
- worker = find_route_worker(r, balancer, *route);
- if (worker && strcmp(*route, worker->s->route)) {
- /*
- * Notice that the route of the worker chosen is different from
- * the route supplied by the client. (mod_proxy compatibility).
- */
- 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;
+ 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);
}
- else
- return NULL;
+ return worker;
}
static proxy_worker *find_best_worker(proxy_balancer *balancer,
- request_rec *r, char *domain, int failoverdomain)
+ request_rec *r, const char *domain, int
failoverdomain)
{
proxy_worker *candidate = NULL;
apr_status_t rv;
@@ -1638,9 +1618,9 @@
{
int access_status;
proxy_worker *runtime;
- char *route = NULL;
- char *sticky = NULL;
- char *domain = NULL;
+ const char *route = NULL;
+ const char *sticky = NULL;
+ const char *domain = NULL;
int failoverdomain = 0;
apr_status_t rv;