Author: rjung
Date: Fri Mar 13 11:44:35 2009
New Revision: 753212
URL: http://svn.apache.org/viewvc?rev=753212&view=rev
Log:
Addition to r753147:
Use strlen to compare for identity without patching
the string to make it zero-terminated.
This avoids having a side effect on the argument.
For instance we call find_bysession_route() with
the configured redirect route, which might not be safe.
This change allows us to switch back the arguments
to const char*.
Modified:
tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=753212&r1=753211&r2=753212&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Fri Mar 13 11:44:35
2009
@@ -718,17 +718,21 @@
int activation;
lb_sub_worker_t wr;
char *idpart = strchr(sessionid, '.');
- char *domain = sessionid;
+ size_t domain_len = 0;
if (idpart) {
- *idpart = '\0';
+ domain_len = idpart - sessionid;
+ }
+ else {
+ domain_len = strlen(sessionid);
}
/* First try to see if we have available candidate */
for (i = 0; i < p->num_of_workers; i++) {
/* Skip all workers that are not member of domain */
wr = p->lb_workers[i];
if (strlen(wr.domain) == 0 ||
- strcmp(wr.domain, domain))
+ strlen(wr.domain) != domain_len ||
+ strncmp(wr.domain, sessionid, domain_len))
continue;
/* Take into calculation only the workers that are
* not in error state, stopped, disabled or busy.
@@ -748,10 +752,6 @@
}
}
}
- if (idpart) {
- /* Restore original char */
- *idpart = '.';
- }
return candidate;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]