You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by da...@apache.org on 2001/01/23 04:23:03 UTC

cvs commit: jakarta-tomcat/src/native/mod_jk/common jk_uri_worker_map.c

danmil      01/01/22 19:23:03

  Modified:    src/native/mod_jk/common jk_uri_worker_map.c
  Log:
  Adding more thorough DEBUG-level to describe what mapping the module is
  using for a given request.
  
  Submitted by: James Courtney
  
  Revision  Changes    Path
  1.3       +18 -6     jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_uri_worker_map.c	2000/11/10 18:48:50	1.2
  +++ jk_uri_worker_map.c	2001/01/23 03:23:03	1.3
  @@ -65,7 +65,7 @@
    * servlet container.                                                      *
    *                                                                         *
    * Author:      Gal Shachor <sh...@il.ibm.com>                           *
  - * Version:     $Revision: 1.2 $                                               *
  + * Version:     $Revision: 1.3 $                                               *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -358,6 +358,7 @@
               uri = clean_uri;
           }
   
  +		jk_log(l, JK_LOG_DEBUG, "Attempting to map URI %s\n", uri);
           for(i = 0 ; i < uw_map->size ; i++) {
   
               if(uw_map->maps[i].ctxt_len < longest_match) {
  @@ -369,10 +370,20 @@
                               uw_map->maps[i].ctxt_len)) {
                   if(MATCH_TYPE_EXACT == uw_map->maps[i].match_type) {
                       if(strlen(uri) == uw_map->maps[i].ctxt_len) {
  +			jk_log(l,
  +			       JK_LOG_DEBUG,
  +			       "jk_uri_worker_map_t::map_uri_to_worker, Found an exact match %s ->%s\n",
  +			       uw_map->maps[i].worker_name,
  +			       uw_map->maps[i].context );
                           return uw_map->maps[i].worker_name;
                       }
                   } else if(MATCH_TYPE_CONTEXT == uw_map->maps[i].match_type) {
                       if(uw_map->maps[i].ctxt_len > longest_match) {
  +			jk_log(l,
  +			       JK_LOG_DEBUG,
  +			       "jk_uri_worker_map_t::map_uri_to_worker, Found a context match %s -> %s\n",
  +			       uw_map->maps[i].worker_name,
  +			       uw_map->maps[i].context );
                           longest_match = uw_map->maps[i].ctxt_len;
                           best_match = i;
                       }
  @@ -393,6 +404,11 @@
                           if(0 == strcmp(suffix, uw_map->maps[i].suffix)) {
   #endif
                               if(uw_map->maps[i].ctxt_len >= longest_match) {
  +				jk_log(l,
  +				       JK_LOG_DEBUG,
  +				       "jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match %s -> *.%s\n",
  +				       uw_map->maps[i].worker_name,
  +				       uw_map->maps[i].suffix );
                                   longest_match = uw_map->maps[i].ctxt_len;
                                   best_match = i;
                               }
  @@ -403,10 +419,6 @@
           }
   
           if(-1 != best_match) {
  -            jk_log(l, JK_LOG_DEBUG, 
  -                   "jk_uri_worker_map_t::map_uri_to_worker, Found a match %s\n",
  -                   uw_map->maps[best_match].worker_name); 
  -
               return uw_map->maps[best_match].worker_name;
           } else {
               /*
  @@ -435,4 +447,4 @@
              "jk_uri_worker_map_t::map_uri_to_worker, done without a match\n"); 
   
       return NULL;
  -}
  \ No newline at end of file
  +}
  
  
  

Re: cvs commit: jakarta-tomcat/src/native/mod_jk/common jk_uri_worker_map.c

Posted by Geoff Soutter <ge...@whitewolf.com.au>.
James

I'm no expert on this matter (I don't use Apache), but here's my 2c.

The problem is you have two apps "competing" for mapping of URLs. We wish to
centralise it inside tomcat (in web.xml), and have the minimum amount of
config in the apache.conf as possible. Thus, we avoid the solution you are
proposing.

Check the 2.2 servlet spec to understand how mapping is done in a servlet
container.

geoff

----- Original Message -----
From: "James Courtney" <ja...@yahoo.com>
To: <to...@jakarta.apache.org>
Cc: <da...@apache.org>
Sent: Tuesday, January 23, 2001 5:43 PM
Subject: RE: cvs commit: jakarta-tomcat/src/native/mod_jk/common
jk_uri_worker_map.c


> Many thanks,
> I was wondering why both the mod_jk module and IIS isapi act as filters
> instead of an Apache handler or an IIS application respectively.  In their
> current implementation they scan all request URIs for ones that they are
> responsible for and then, in the case of Apache anyway, register a call
back
> to a handler to handle the actual request.  I have had this cause problems
> for me with Apache in the case where I have a servlet named foo and
another
> file named foo.xxx.  mod_jk correctly maps /foo to the servlet and
registers
> the callback but Apache never calls the callback and instead some other
> module or the Apache core make a best guess that the request really meant
> foo.xxx since no /foo exists as far as Apache is concerned.  By adding
> handler entries to Apache's httpd.conf file like the following (pardon my
> syntax if it is somewhat off)
>
> <location path="/login">
> <handler name="jakarta-servlet">
> </location>
>
> Apache then automatically sends that URI to mod_jk without any filtering
> needed.  All mod_jk need now do is determine which Tomcat handler to use
> (ajp12, ajp13, lb, etc...).  Filtering is also more expensive because all
> modules get a chance to act on the URI before the callback handler.  By
> registering mod_jk as a handler directly, Apache maps the URI directly to
> mod_jk with basically no overhead or searching.  I've made some code
changes
> (about four changed lines) to mod_jk that make it behave as a pure handler
> with no filtering and it seems to run great but I'd like to know before
> proposing a change if there were specific reasons for the filter
> implementation.  Many thanks to anyone who can help:)
> -Jamey
>
> -----Original Message-----
> From: danmil@apache.org [mailto:danmil@apache.org]
> Sent: Monday, January 22, 2001 7:23 PM
> To: jakarta-tomcat-cvs@apache.org
> Subject: cvs commit: jakarta-tomcat/src/native/mod_jk/common
> jk_uri_worker_map.c
>
>
> danmil      01/01/22 19:23:03
>
>   Modified:    src/native/mod_jk/common jk_uri_worker_map.c
>   Log:
>   Adding more thorough DEBUG-level to describe what mapping the module is
>   using for a given request.
>
>   Submitted by: James Courtney
>
>   Revision  Changes    Path
>   1.3       +18 -6
> jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c
>
>   Index: jk_uri_worker_map.c
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- jk_uri_worker_map.c 2000/11/10 18:48:50 1.2
>   +++ jk_uri_worker_map.c 2001/01/23 03:23:03 1.3
>   @@ -65,7 +65,7 @@
>     * servlet container.
> *
>     *
> *
>     * Author:      Gal Shachor <sh...@il.ibm.com>
> *
>   - * Version:     $Revision: 1.2 $
> *
>   + * Version:     $Revision: 1.3 $
> *
>
>
***************************************************************************/
>
>    #include "jk_pool.h"
>   @@ -358,6 +358,7 @@
>                uri = clean_uri;
>            }
>
>   + jk_log(l, JK_LOG_DEBUG, "Attempting to map URI %s\n", uri);
>            for(i = 0 ; i < uw_map->size ; i++) {
>
>                if(uw_map->maps[i].ctxt_len < longest_match) {
>   @@ -369,10 +370,20 @@
>                                uw_map->maps[i].ctxt_len)) {
>                    if(MATCH_TYPE_EXACT == uw_map->maps[i].match_type) {
>                        if(strlen(uri) == uw_map->maps[i].ctxt_len) {
>   + jk_log(l,
>   +        JK_LOG_DEBUG,
>   +        "jk_uri_worker_map_t::map_uri_to_worker, Found an exact match
> %s ->%s\n",
>   +        uw_map->maps[i].worker_name,
>   +        uw_map->maps[i].context );
>                            return uw_map->maps[i].worker_name;
>                        }
>                    } else if(MATCH_TYPE_CONTEXT ==
> uw_map->maps[i].match_type) {
>                        if(uw_map->maps[i].ctxt_len > longest_match) {
>   + jk_log(l,
>   +        JK_LOG_DEBUG,
>   +        "jk_uri_worker_map_t::map_uri_to_worker, Found a context match
> %s -> %s\n",
>   +        uw_map->maps[i].worker_name,
>   +        uw_map->maps[i].context );
>                            longest_match = uw_map->maps[i].ctxt_len;
>                            best_match = i;
>                        }
>   @@ -393,6 +404,11 @@
>                            if(0 == strcmp(suffix, uw_map->maps[i].suffix))
{
>    #endif
>                                if(uw_map->maps[i].ctxt_len >=
longest_match)
> {
>   + jk_log(l,
>   +        JK_LOG_DEBUG,
>   +        "jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match
> %s -> *.%s\n",
>   +        uw_map->maps[i].worker_name,
>   +        uw_map->maps[i].suffix );
>                                    longest_match =
uw_map->maps[i].ctxt_len;
>                                    best_match = i;
>                                }
>   @@ -403,10 +419,6 @@
>            }
>
>            if(-1 != best_match) {
>   -            jk_log(l, JK_LOG_DEBUG,
>   -                   "jk_uri_worker_map_t::map_uri_to_worker, Found a
match
> %s\n",
>   -                   uw_map->maps[best_match].worker_name);
>   -
>                return uw_map->maps[best_match].worker_name;
>            } else {
>                /*
>   @@ -435,4 +447,4 @@
>               "jk_uri_worker_map_t::map_uri_to_worker, done without a
> match\n");
>
>        return NULL;
>   -}
>   \ No newline at end of file
>   +}
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>


RE: cvs commit: jakarta-tomcat/src/native/mod_jk/common jk_uri_worker_map.c

Posted by James Courtney <ja...@yahoo.com>.
Costin and Geoff,
	Thanks very much for your help and interest.  I don't think that doing the
"right thing" is as hard as you think though:)  I've got the 2.2 servlet
spec and I reread the servlet mapping functionality.  I believe Apache does
path matching in the same way so that any patterns specified in Apache have
the same context when passed to Tomcat, thus a direct mapping is still
feasible.  In actuallity, Apache will map "*.jsp" as in the servlet 2.2.
spec and mod_jk requires "/*.jsp".  I've attached a segment of an Apache
httpd.conf file containing the Tomcat configuration as I've modified it, a
sample WEB-INF/web.xml file, a sample workers.properties file, a sample
server.xml, and both the current mod_jk.c and my mod_jk.c files and a diff
between them.  If you'll notice, the only configuration changes that differ
from the current way of doing things are in httpd.conf.  The web.xml,
workers.properties, and server.xml files are nothing out of the ordinary.
Please let me know what you think of the differences and how they would
impact usability.  Please note in particular the architectural changes I
made to mod_jk.c by unregistering it as a filter and changing the entry
point for the handler to allow URI resolution to determine the appropriate
Tomcat worker.  I agree that the existing performance hit is minimal but I
just don't see an advantage to paying that price and risking URI
misinterpretation by other installed modules.  Additionally, I'm fairly
confident that tomcat could be set up to produce the appropriate sample
httpd.conf file fairly easily too.  Many thanks for your time and insight
and please let me know what you think.
Cheers,
	Jamey



-----Original Message-----
From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
Sent: Tuesday, January 23, 2001 8:52 AM
To: tomcat-dev@jakarta.apache.org; jamescourtney_1999@yahoo.com
Cc: danmil@apache.org
Subject: RE: cvs commit: jakarta-tomcat/src/native/mod_jk/common
jk_uri_worker_map.c


Hi Jamey,

You are touching a very important subject in the mod_jk
implementation. And YES, you are absolutely right ( IMHO ) - Apache, IIS,
NES, AOLServer are pretty good at processing requests - after all that's
their main business.
Each requests is mapped by the ( optimized ) mappers of
the native web server, and then the same operation is duplicated in
mod_jk - adding a performance hit on all served requests.

Unfortunately, doing the "right thing" is hard and tricky - the current
solution works and the overhead it adds is acceptable.

The problem is that configuring the server is tricky and few people know
how to do it. An attempt has been made to generate server config file
automatically, but web.xml is quite complex and a lot is missing.

mod_jk has a lot of flexibility - it can send all the requests for a
particular context to tomcat ( where all web.xml settings will be
respected ).
Or you can translate the mapping from web.xml in server configs - and
operate in the most efficient way.

The translation is not easy and requires knowledge of the server. All
settings in web.xml have equivalent in the server settings - but not too
many people know how to do it. And it's even harder to do it
automatically. But what you get is maximum flexibility, you can authorize
using any of the server modules, etc.

That's why forwarding the whole context is sometimes an acceptable
solution ( and it automatically respects all settings in web.xml :-). The
only problem - static files in webapps will still be served by tomcat, and
the server is just a proxy.

I have serious doubts that an automated solution is the best for all
cases, but improvements to the current "forward all" are needed. On the
other side, I think it is very important to support/enhance the flexible
aproach where a server admin has the chance to tune the settings.

Case: authentication. There is no easy way to guess what mod_auth is used
by the server ( you may have multiple modules doing that ). A "manual
tunning" would allow the deployer to do implement his site policies and
tune the deployment. A "automated" deployment should be possible, but I
doubt it is the best for big production sites.

(thanks for reviewing the code, any enhancements in this area are
wellcomed )

Costin




> Many thanks,
> 	I was wondering why both the mod_jk module and IIS isapi act as filters
> instead of an Apache handler or an IIS application respectively.  In their
> current implementation they scan all request URIs for ones that they are
> responsible for and then, in the case of Apache anyway, register a call
back
> to a handler to handle the actual request.  I have had this cause problems
> for me with Apache in the case where I have a servlet named foo and
another
> file named foo.xxx.  mod_jk correctly maps /foo to the servlet and
registers
> the callback but Apache never calls the callback and instead some other
> module or the Apache core make a best guess that the request really meant
> foo.xxx since no /foo exists as far as Apache is concerned.  By adding
> handler entries to Apache's httpd.conf file like the following (pardon my
> syntax if it is somewhat off)
>
> <location path="/login">
> 	<handler name="jakarta-servlet">
> </location>
>
> Apache then automatically sends that URI to mod_jk without any filtering
> needed.  All mod_jk need now do is determine which Tomcat handler to use
> (ajp12, ajp13, lb, etc...).  Filtering is also more expensive because all
> modules get a chance to act on the URI before the callback handler.  By
> registering mod_jk as a handler directly, Apache maps the URI directly to
> mod_jk with basically no overhead or searching.  I've made some code
changes
> (about four changed lines) to mod_jk that make it behave as a pure handler
> with no filtering and it seems to run great but I'd like to know before
> proposing a change if there were specific reasons for the filter
> implementation.  Many thanks to anyone who can help:)
> -Jamey
>
> -----Original Message-----
> From: danmil@apache.org [mailto:danmil@apache.org]
> Sent: Monday, January 22, 2001 7:23 PM
> To: jakarta-tomcat-cvs@apache.org
> Subject: cvs commit: jakarta-tomcat/src/native/mod_jk/common
> jk_uri_worker_map.c
>
>
> danmil      01/01/22 19:23:03
>
>   Modified:    src/native/mod_jk/common jk_uri_worker_map.c
>   Log:
>   Adding more thorough DEBUG-level to describe what mapping the module is
>   using for a given request.
>
>   Submitted by: James Courtney
>
>   Revision  Changes    Path
>   1.3       +18 -6
> jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c
>
>   Index: jk_uri_worker_map.c
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- jk_uri_worker_map.c	2000/11/10 18:48:50	1.2
>   +++ jk_uri_worker_map.c	2001/01/23 03:23:03	1.3
>   @@ -65,7 +65,7 @@
>     * servlet container.
> *
>     *
> *
>     * Author:      Gal Shachor <sh...@il.ibm.com>
> *
>   - * Version:     $Revision: 1.2 $
> *
>   + * Version:     $Revision: 1.3 $
> *
>
>
***************************************************************************/
>
>    #include "jk_pool.h"
>   @@ -358,6 +358,7 @@
>                uri = clean_uri;
>            }
>
>   +		jk_log(l, JK_LOG_DEBUG, "Attempting to map URI %s\n", uri);
>            for(i = 0 ; i < uw_map->size ; i++) {
>
>                if(uw_map->maps[i].ctxt_len < longest_match) {
>   @@ -369,10 +370,20 @@
>                                uw_map->maps[i].ctxt_len)) {
>                    if(MATCH_TYPE_EXACT == uw_map->maps[i].match_type) {
>                        if(strlen(uri) == uw_map->maps[i].ctxt_len) {
>   +			jk_log(l,
>   +			       JK_LOG_DEBUG,
>   +			       "jk_uri_worker_map_t::map_uri_to_worker, Found an exact match
> %s ->%s\n",
>   +			       uw_map->maps[i].worker_name,
>   +			       uw_map->maps[i].context );
>                            return uw_map->maps[i].worker_name;
>                        }
>                    } else if(MATCH_TYPE_CONTEXT ==
> uw_map->maps[i].match_type) {
>                        if(uw_map->maps[i].ctxt_len > longest_match) {
>   +			jk_log(l,
>   +			       JK_LOG_DEBUG,
>   +			       "jk_uri_worker_map_t::map_uri_to_worker, Found a context
match
> %s -> %s\n",
>   +			       uw_map->maps[i].worker_name,
>   +			       uw_map->maps[i].context );
>                            longest_match = uw_map->maps[i].ctxt_len;
>                            best_match = i;
>                        }
>   @@ -393,6 +404,11 @@
>                            if(0 == strcmp(suffix, uw_map->maps[i].suffix))
{
>    #endif
>                                if(uw_map->maps[i].ctxt_len >=
longest_match)
> {
>   +				jk_log(l,
>   +				       JK_LOG_DEBUG,
>   +				       "jk_uri_worker_map_t::map_uri_to_worker, Found a suffix
match
> %s -> *.%s\n",
>   +				       uw_map->maps[i].worker_name,
>   +				       uw_map->maps[i].suffix );
>                                    longest_match =
uw_map->maps[i].ctxt_len;
>                                    best_match = i;
>                                }
>   @@ -403,10 +419,6 @@
>            }
>
>            if(-1 != best_match) {
>   -            jk_log(l, JK_LOG_DEBUG,
>   -                   "jk_uri_worker_map_t::map_uri_to_worker, Found a
match
> %s\n",
>   -                   uw_map->maps[best_match].worker_name);
>   -
>                return uw_map->maps[best_match].worker_name;
>            } else {
>                /*
>   @@ -435,4 +447,4 @@
>               "jk_uri_worker_map_t::map_uri_to_worker, done without a
> match\n");
>
>        return NULL;
>   -}
>   \ No newline at end of file
>   +}
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>

--
Costin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-dev-help@jakarta.apache.org

RE: cvs commit: jakarta-tomcat/src/native/mod_jk/common jk_uri_worker_map.c

Posted by cm...@yahoo.com.
Hi Jamey,

You are touching a very important subject in the mod_jk
implementation. And YES, you are absolutely right ( IMHO ) - Apache, IIS,
NES, AOLServer are pretty good at processing requests - after all that's
their main business.
Each requests is mapped by the ( optimized ) mappers of
the native web server, and then the same operation is duplicated in
mod_jk - adding a performance hit on all served requests. 

Unfortunately, doing the "right thing" is hard and tricky - the current
solution works and the overhead it adds is acceptable.

The problem is that configuring the server is tricky and few people know
how to do it. An attempt has been made to generate server config file
automatically, but web.xml is quite complex and a lot is missing. 

mod_jk has a lot of flexibility - it can send all the requests for a 
particular context to tomcat ( where all web.xml settings will be
respected ). 
Or you can translate the mapping from web.xml in server configs - and
operate in the most efficient way. 

The translation is not easy and requires knowledge of the server. All
settings in web.xml have equivalent in the server settings - but not too
many people know how to do it. And it's even harder to do it
automatically. But what you get is maximum flexibility, you can authorize
using any of the server modules, etc. 

That's why forwarding the whole context is sometimes an acceptable
solution ( and it automatically respects all settings in web.xml :-). The
only problem - static files in webapps will still be served by tomcat, and
the server is just a proxy.

I have serious doubts that an automated solution is the best for all
cases, but improvements to the current "forward all" are needed. On the
other side, I think it is very important to support/enhance the flexible
aproach where a server admin has the chance to tune the settings.

Case: authentication. There is no easy way to guess what mod_auth is used
by the server ( you may have multiple modules doing that ). A "manual
tunning" would allow the deployer to do implement his site policies and
tune the deployment. A "automated" deployment should be possible, but I
doubt it is the best for big production sites. 

(thanks for reviewing the code, any enhancements in this area are
wellcomed )

Costin




> Many thanks,
> 	I was wondering why both the mod_jk module and IIS isapi act as filters
> instead of an Apache handler or an IIS application respectively.  In their
> current implementation they scan all request URIs for ones that they are
> responsible for and then, in the case of Apache anyway, register a call back
> to a handler to handle the actual request.  I have had this cause problems
> for me with Apache in the case where I have a servlet named foo and another
> file named foo.xxx.  mod_jk correctly maps /foo to the servlet and registers
> the callback but Apache never calls the callback and instead some other
> module or the Apache core make a best guess that the request really meant
> foo.xxx since no /foo exists as far as Apache is concerned.  By adding
> handler entries to Apache's httpd.conf file like the following (pardon my
> syntax if it is somewhat off)
> 
> <location path="/login">
> 	<handler name="jakarta-servlet">
> </location>
> 
> Apache then automatically sends that URI to mod_jk without any filtering
> needed.  All mod_jk need now do is determine which Tomcat handler to use
> (ajp12, ajp13, lb, etc...).  Filtering is also more expensive because all
> modules get a chance to act on the URI before the callback handler.  By
> registering mod_jk as a handler directly, Apache maps the URI directly to
> mod_jk with basically no overhead or searching.  I've made some code changes
> (about four changed lines) to mod_jk that make it behave as a pure handler
> with no filtering and it seems to run great but I'd like to know before
> proposing a change if there were specific reasons for the filter
> implementation.  Many thanks to anyone who can help:)
> -Jamey
> 
> -----Original Message-----
> From: danmil@apache.org [mailto:danmil@apache.org]
> Sent: Monday, January 22, 2001 7:23 PM
> To: jakarta-tomcat-cvs@apache.org
> Subject: cvs commit: jakarta-tomcat/src/native/mod_jk/common
> jk_uri_worker_map.c
> 
> 
> danmil      01/01/22 19:23:03
> 
>   Modified:    src/native/mod_jk/common jk_uri_worker_map.c
>   Log:
>   Adding more thorough DEBUG-level to describe what mapping the module is
>   using for a given request.
> 
>   Submitted by: James Courtney
> 
>   Revision  Changes    Path
>   1.3       +18 -6
> jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c
> 
>   Index: jk_uri_worker_map.c
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- jk_uri_worker_map.c	2000/11/10 18:48:50	1.2
>   +++ jk_uri_worker_map.c	2001/01/23 03:23:03	1.3
>   @@ -65,7 +65,7 @@
>     * servlet container.
> *
>     *
> *
>     * Author:      Gal Shachor <sh...@il.ibm.com>
> *
>   - * Version:     $Revision: 1.2 $
> *
>   + * Version:     $Revision: 1.3 $
> *
> 
> ***************************************************************************/
> 
>    #include "jk_pool.h"
>   @@ -358,6 +358,7 @@
>                uri = clean_uri;
>            }
> 
>   +		jk_log(l, JK_LOG_DEBUG, "Attempting to map URI %s\n", uri);
>            for(i = 0 ; i < uw_map->size ; i++) {
> 
>                if(uw_map->maps[i].ctxt_len < longest_match) {
>   @@ -369,10 +370,20 @@
>                                uw_map->maps[i].ctxt_len)) {
>                    if(MATCH_TYPE_EXACT == uw_map->maps[i].match_type) {
>                        if(strlen(uri) == uw_map->maps[i].ctxt_len) {
>   +			jk_log(l,
>   +			       JK_LOG_DEBUG,
>   +			       "jk_uri_worker_map_t::map_uri_to_worker, Found an exact match
> %s ->%s\n",
>   +			       uw_map->maps[i].worker_name,
>   +			       uw_map->maps[i].context );
>                            return uw_map->maps[i].worker_name;
>                        }
>                    } else if(MATCH_TYPE_CONTEXT ==
> uw_map->maps[i].match_type) {
>                        if(uw_map->maps[i].ctxt_len > longest_match) {
>   +			jk_log(l,
>   +			       JK_LOG_DEBUG,
>   +			       "jk_uri_worker_map_t::map_uri_to_worker, Found a context match
> %s -> %s\n",
>   +			       uw_map->maps[i].worker_name,
>   +			       uw_map->maps[i].context );
>                            longest_match = uw_map->maps[i].ctxt_len;
>                            best_match = i;
>                        }
>   @@ -393,6 +404,11 @@
>                            if(0 == strcmp(suffix, uw_map->maps[i].suffix)) {
>    #endif
>                                if(uw_map->maps[i].ctxt_len >= longest_match)
> {
>   +				jk_log(l,
>   +				       JK_LOG_DEBUG,
>   +				       "jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match
> %s -> *.%s\n",
>   +				       uw_map->maps[i].worker_name,
>   +				       uw_map->maps[i].suffix );
>                                    longest_match = uw_map->maps[i].ctxt_len;
>                                    best_match = i;
>                                }
>   @@ -403,10 +419,6 @@
>            }
> 
>            if(-1 != best_match) {
>   -            jk_log(l, JK_LOG_DEBUG,
>   -                   "jk_uri_worker_map_t::map_uri_to_worker, Found a match
> %s\n",
>   -                   uw_map->maps[best_match].worker_name);
>   -
>                return uw_map->maps[best_match].worker_name;
>            } else {
>                /*
>   @@ -435,4 +447,4 @@
>               "jk_uri_worker_map_t::map_uri_to_worker, done without a
> match\n");
> 
>        return NULL;
>   -}
>   \ No newline at end of file
>   +}
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
> 

-- 
Costin


RE: cvs commit: jakarta-tomcat/src/native/mod_jk/common jk_uri_worker_map.c

Posted by James Courtney <ja...@yahoo.com>.
Many thanks,
	I was wondering why both the mod_jk module and IIS isapi act as filters
instead of an Apache handler or an IIS application respectively.  In their
current implementation they scan all request URIs for ones that they are
responsible for and then, in the case of Apache anyway, register a call back
to a handler to handle the actual request.  I have had this cause problems
for me with Apache in the case where I have a servlet named foo and another
file named foo.xxx.  mod_jk correctly maps /foo to the servlet and registers
the callback but Apache never calls the callback and instead some other
module or the Apache core make a best guess that the request really meant
foo.xxx since no /foo exists as far as Apache is concerned.  By adding
handler entries to Apache's httpd.conf file like the following (pardon my
syntax if it is somewhat off)

<location path="/login">
	<handler name="jakarta-servlet">
</location>

Apache then automatically sends that URI to mod_jk without any filtering
needed.  All mod_jk need now do is determine which Tomcat handler to use
(ajp12, ajp13, lb, etc...).  Filtering is also more expensive because all
modules get a chance to act on the URI before the callback handler.  By
registering mod_jk as a handler directly, Apache maps the URI directly to
mod_jk with basically no overhead or searching.  I've made some code changes
(about four changed lines) to mod_jk that make it behave as a pure handler
with no filtering and it seems to run great but I'd like to know before
proposing a change if there were specific reasons for the filter
implementation.  Many thanks to anyone who can help:)
-Jamey

-----Original Message-----
From: danmil@apache.org [mailto:danmil@apache.org]
Sent: Monday, January 22, 2001 7:23 PM
To: jakarta-tomcat-cvs@apache.org
Subject: cvs commit: jakarta-tomcat/src/native/mod_jk/common
jk_uri_worker_map.c


danmil      01/01/22 19:23:03

  Modified:    src/native/mod_jk/common jk_uri_worker_map.c
  Log:
  Adding more thorough DEBUG-level to describe what mapping the module is
  using for a given request.

  Submitted by: James Courtney

  Revision  Changes    Path
  1.3       +18 -6
jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c

  Index: jk_uri_worker_map.c
  ===================================================================
  RCS file:
/home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_uri_worker_map.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_uri_worker_map.c	2000/11/10 18:48:50	1.2
  +++ jk_uri_worker_map.c	2001/01/23 03:23:03	1.3
  @@ -65,7 +65,7 @@
    * servlet container.
*
    *
*
    * Author:      Gal Shachor <sh...@il.ibm.com>
*
  - * Version:     $Revision: 1.2 $
*
  + * Version:     $Revision: 1.3 $
*

***************************************************************************/

   #include "jk_pool.h"
  @@ -358,6 +358,7 @@
               uri = clean_uri;
           }

  +		jk_log(l, JK_LOG_DEBUG, "Attempting to map URI %s\n", uri);
           for(i = 0 ; i < uw_map->size ; i++) {

               if(uw_map->maps[i].ctxt_len < longest_match) {
  @@ -369,10 +370,20 @@
                               uw_map->maps[i].ctxt_len)) {
                   if(MATCH_TYPE_EXACT == uw_map->maps[i].match_type) {
                       if(strlen(uri) == uw_map->maps[i].ctxt_len) {
  +			jk_log(l,
  +			       JK_LOG_DEBUG,
  +			       "jk_uri_worker_map_t::map_uri_to_worker, Found an exact match
%s ->%s\n",
  +			       uw_map->maps[i].worker_name,
  +			       uw_map->maps[i].context );
                           return uw_map->maps[i].worker_name;
                       }
                   } else if(MATCH_TYPE_CONTEXT ==
uw_map->maps[i].match_type) {
                       if(uw_map->maps[i].ctxt_len > longest_match) {
  +			jk_log(l,
  +			       JK_LOG_DEBUG,
  +			       "jk_uri_worker_map_t::map_uri_to_worker, Found a context match
%s -> %s\n",
  +			       uw_map->maps[i].worker_name,
  +			       uw_map->maps[i].context );
                           longest_match = uw_map->maps[i].ctxt_len;
                           best_match = i;
                       }
  @@ -393,6 +404,11 @@
                           if(0 == strcmp(suffix, uw_map->maps[i].suffix)) {
   #endif
                               if(uw_map->maps[i].ctxt_len >= longest_match)
{
  +				jk_log(l,
  +				       JK_LOG_DEBUG,
  +				       "jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match
%s -> *.%s\n",
  +				       uw_map->maps[i].worker_name,
  +				       uw_map->maps[i].suffix );
                                   longest_match = uw_map->maps[i].ctxt_len;
                                   best_match = i;
                               }
  @@ -403,10 +419,6 @@
           }

           if(-1 != best_match) {
  -            jk_log(l, JK_LOG_DEBUG,
  -                   "jk_uri_worker_map_t::map_uri_to_worker, Found a match
%s\n",
  -                   uw_map->maps[best_match].worker_name);
  -
               return uw_map->maps[best_match].worker_name;
           } else {
               /*
  @@ -435,4 +447,4 @@
              "jk_uri_worker_map_t::map_uri_to_worker, done without a
match\n");

       return NULL;
  -}
  \ No newline at end of file
  +}




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-dev-help@jakarta.apache.org


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com