billbarker 2004/07/27 22:59:44
Modified: jk/native/common jk_lb_worker.c
Log:
Check all JSESSIONID cookies for a valid jvmRoute.
If you have multiple Tomcats with overlapping domains, then you can get multiple
cookies without a defined order. This will route correctly as long as the different
domains don't have any Tomcats in common.
Based on patch
Submitted By: Sandy McArthur <[EMAIL PROTECTED]>
Revision Changes Path
1.23 +42 -39 jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c
Index: jk_lb_worker.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- jk_lb_worker.c 21 Jul 2004 02:18:46 -0000 1.22
+++ jk_lb_worker.c 28 Jul 2004 05:59:44 -0000 1.23
@@ -100,6 +100,12 @@
if(id_end = strchr(id_start, '?')) {
*id_end = '\0';
}
+ /*
+ * Remove any trailing path element.
+ */
+ if((id_end = strchr(id_start, ';')) != NULL) {
+ *id_end = '\0';
+ }
return id_start;
}
}
@@ -114,6 +120,7 @@
const char *name)
{
unsigned i;
+ char *result = NULL;
for(i = 0 ; i < s->num_headers ; i++) {
if(0 == strcasecmp(s->headers_names[i], "cookie")) {
@@ -142,14 +149,22 @@
if((id_end = strchr(id_start, ',')) != NULL) {
*id_end = '\0';
}
- return id_start;
+ if(result == NULL) {
+ result = id_start;
+ } else {
+ int osz = strlen(result)+1;
+ int sz = osz + strlen(id_start)+1;
+ result = jk_pool_realloc(s->pool, sz, result, osz);
+ strcat(result,";");
+ strcat(result, id_start);
+ }
}
}
}
}
}
- return NULL;
+ return result;
}
@@ -166,29 +181,6 @@
return val;
}
-static char *get_session_route(jk_ws_service_t *s)
-{
- char *sessionid = get_sessionid(s);
- char *ch;
-
- if(!sessionid) {
- return NULL;
- }
-
- /*
- * Balance parameter is appended to the end
- */
- ch = strrchr(sessionid, '.');
- if(!ch) {
- return 0;
- }
- ch++;
- if(*ch == '\0') {
- return NULL;
- }
- return ch;
-}
-
static void close_workers(lb_worker_t *p,
int num_of_workers,
jk_logger_t *l)
@@ -223,26 +215,37 @@
worker_record_t *rc = NULL;
double lb_min = 0.0;
unsigned i;
- char *session_route = NULL;
+ char *sessionid = NULL;
if (p->sticky_session) {
- session_route = get_session_route(s);
+ sessionid = get_sessionid(s);
}
- if(session_route) {
- for(i = 0 ; i < p->num_of_workers ; i++) {
+ while(sessionid) {
+ char *next = strchr(sessionid, ';');
+ char *session_route;
+ if(next) {
+ *next++ = '\0';
+ }
+ session_route = strchr(sessionid, '.');
+ if(session_route) {
+ ++session_route;
+ for(i = 0 ; i < p->num_of_workers ; i++) {
if(0 == strcmp(session_route, p->lb_workers[i].name)) {
- /* First attempt will allways be to the
- correct host. If this is indeed down and no
- hope of recovery, we'll go to fail-over
- */
- if(attempt>0 && p->lb_workers[i].in_error_state) {
- break;
- } else {
- return &(p->lb_workers[i]);
- }
+ /* First attempt will allways be to the
+ correct host. If this is indeed down and no
+ hope of recovery, we'll go to fail-over
+ */
+ if(attempt>0 && p->lb_workers[i].in_error_state) {
+ next = NULL; /* Double break; */
+ break;
+ } else {
+ return &(p->lb_workers[i]);
+ }
}
+ }
}
+ sessionid = next;
}
for(i = 0 ; i < p->num_of_workers ; i++) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]