Author: mturk Date: Thu Mar 16 00:10:18 2006 New Revision: 386282 URL: http://svn.apache.org/viewcvs?rev=386282&view=rev Log: Fix #38889 by sorting worker map depending on the path elements, to comply with Servlet spec. Patch provided by Steve Revilak.
Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c tomcat/connectors/trunk/jk/xdocs/changelog.xml Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c?rev=386282&r1=386281&r2=386282&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c Thu Mar 16 00:10:18 2006 @@ -36,10 +36,48 @@ #define JK_STRNCMP strncmp #endif + +/* + * Given context uri, count the number of path tokens. + * + * Servlet specification 2.4, SRV.11.1 says + + * The container will recursively try tomatch the longest + * path-prefix. This is done by stepping down the path tree a + * directory at a time, using the / character as a path + * separator. The longest match determines the servlet selected. + * + * The implication seems to be `most uri path elements is most exact'. + * This is a little helper function to count uri tokens, so we can + * keep the worker map sorted with most specific first. + */ +static int worker_count_context_uri_tokens(const char * context) +{ + const char * c = context; + int count = 0; + while (c && *c) { + if ('/' == *c++) + count++; + } + return count; +} + static int worker_compare(const void *elem1, const void *elem2) { uri_worker_record_t *e1 = *(uri_worker_record_t **)elem1; uri_worker_record_t *e2 = *(uri_worker_record_t **)elem2; + int e1_tokens = 0; + int e2_tokens = 0; + + e1_tokens = worker_count_context_uri_tokens(e1->context); + e2_tokens = worker_count_context_uri_tokens(e2->context); + + if (e1_tokens != e2_tokens) { + return (e2_tokens - e1_tokens); + } + /* given the same number of URI tokens, use character + * length as a tie breaker + */ return ((int)e2->context_len - (int)e1->context_len); } Modified: tomcat/connectors/trunk/jk/xdocs/changelog.xml URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/jk/xdocs/changelog.xml?rev=386282&r1=386281&r2=386282&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/xdocs/changelog.xml (original) +++ tomcat/connectors/trunk/jk/xdocs/changelog.xml Thu Mar 16 00:10:18 2006 @@ -25,6 +25,11 @@ <br /> <subsection name="Native"> <changelog> + <fix> + <bug>38889</bug>: Use worker map sorting depending on the path + elements, to comply with Servlet spec. Patch provided by + Steve Revilak. (mturk) + </fix> <update> <bug>36138</bug>: Added Busyness lb method. Patch provided by Chris Lamprecht. (mturk) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]