You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bojan Smojver <bo...@rexursive.com> on 2002/07/19 05:57:22 UTC
[BUGS: 9913, 10789] Re: cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
I've looked through Mark's excellent analysis of the problem
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10789) and I also played with
changing the hook order for mod_jk 1.2.0. Are you sure this actually fixes the
thing?
My experience from 1.2.0 is similar to Mark's with 2.x - the handler never gets
called because the r->handler is DIR_MAGIC_TYPE, not JK_HANDLER. So, I think
Mark's code would be the real fix for both - giving Apache a hint that the
handler is JK_HANDLER.
My original 'fix' (more like a kludge) for 1.2.0 doesn't do that. It waits for
the next round, accepts the DIR_MAGIC_TYPE call, where r->uri isn't the correct
file (i.e. it is not /some/path/index.jsp), but rather a directory
(/some/path/), which then causes havoc down the line in getServletPath(). Tomcat
3.3.x is smart and it corrects that for JSP's. I'm not sure if TC 4.x does that
at all (I have seen at least one other report related to bug 9913 with TC 4.x
where my 'fix' didn't actually fix the problem - some fix :-).
Mladen, what's your take on all this? Do you have a setup handy to verify that
the changing of hook ordering fixed the problem in mod_jk2?
Mark, does the fix in mod_jk2 work in your environment?
Bojan
PS. Sorry guys, this one is *really* bugging me...
Quoting mturk@apache.org:
> mturk 2002/07/18 08:15:00
>
> Modified: jk/native2/server/apache2 mod_jk2.c
> Log:
> Fix the bug 10789 caused by hook order.
>
> Revision Changes Path
> 1.42 +3 -3
> jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c
>
> Index: mod_jk2.c
> ===================================================================
> RCS file:
> /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c,v
> retrieving revision 1.41
> retrieving revision 1.42
> diff -u -r1.41 -r1.42
> --- mod_jk2.c 17 Jul 2002 22:43:58 -0000 1.41
> +++ mod_jk2.c 18 Jul 2002 15:15:00 -0000 1.42
> @@ -724,8 +724,8 @@
> ap_hook_handler(jk2_handler, NULL, NULL, APR_HOOK_MIDDLE);
> ap_hook_post_config(jk2_post_config,NULL,NULL,APR_HOOK_MIDDLE);
> ap_hook_child_init(jk2_child_init,NULL,NULL,APR_HOOK_MIDDLE);
> - ap_hook_translate_name(jk2_translate,NULL,NULL,APR_HOOK_FIRST);
> - ap_hook_map_to_storage(jk2_map_to_storage, NULL, NULL,
> APR_HOOK_MIDDLE);
> +
> ap_hook_translate_name(jk2_translate,NULL,NULL,APR_HOOK_MIDDLE);
> + ap_hook_map_to_storage(jk2_map_to_storage, NULL, NULL,
> APR_HOOK_FIRST);
> }
>
> module AP_MODULE_DECLARE_DATA jk2_module =
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit:
jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sat, 2002-07-20 at 09:36, costinm@covalent.net wrote:
> Hi Bojan,
>
> Sorry, I had a lot of work to do ( and spent some time with some ant
> itches ) - I'll be back on mod_jk2 next week.
>
> Costin
No worries.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2
mod_jk2.c
Posted by co...@covalent.net.
Hi Bojan,
Sorry, I had a lot of work to do ( and spent some time with some ant
itches ) - I'll be back on mod_jk2 next week.
Costin
On 20 Jul 2002, Bojan Smojver wrote:
> On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
> > Quoting Mark Miesfeld <mi...@acm.org>:
> >
> > > I was just getting ready to post something saying the fix seems to
> > > break mod_jk2 altogether for me.
> >
> > Interesting. I haven't actually checked explicit calls to pages with reversed
> > order and mod_jk 1.2.0, so I don't really know if that breaks it or not. Will
> > test tonight (Sydney time).
>
> Just tested 1.2.0 with explicit pages and the reversed order of hooks:
>
> ---------------------
> ap_hook_translate_name(jk_translate,NULL,NULL,APR_HOOK_MIDDLE);
> #if (MODULE_MAGIC_NUMBER_MAJOR > 20010808)
> ap_hook_map_to_storage(jk_map_to_storage, NULL, NULL, APR_HOOK_FIRST);
> #endif
> ---------------------
>
> and it becomes totally broken. So, reverting the order is not a good
> thing to do.
>
> Bojan
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit:
jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
> Quoting Mark Miesfeld <mi...@acm.org>:
>
> > I was just getting ready to post something saying the fix seems to
> > break mod_jk2 altogether for me.
>
> Interesting. I haven't actually checked explicit calls to pages with reversed
> order and mod_jk 1.2.0, so I don't really know if that breaks it or not. Will
> test tonight (Sydney time).
Just tested 1.2.0 with explicit pages and the reversed order of hooks:
---------------------
ap_hook_translate_name(jk_translate,NULL,NULL,APR_HOOK_MIDDLE);
#if (MODULE_MAGIC_NUMBER_MAJOR > 20010808)
ap_hook_map_to_storage(jk_map_to_storage, NULL, NULL, APR_HOOK_FIRST);
#endif
---------------------
and it becomes totally broken. So, reverting the order is not a good
thing to do.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs
commit:jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sat, 2002-07-20 at 13:38, Bojan Smojver wrote:
> The problem is that ap_internal_fast_redirect(rr, r) never gets called
> in mod_dir.c. The code goes like this:
>
> ----------------------
> if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
> ap_internal_fast_redirect(rr, r);
> return OK;
> }
> ----------------------
>
> One of those conditions is false, I'm just about to find out which
> one... Once the condition becomes true (and one of the jk_* hooks needs
> to provide that), ap_internal_fast_redirect will get called, which
> should then trigger jk_handler.
----------------------
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=/var/www/html/dev.dev/service/index.shtml,rr->uri=/service/index.shtml
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=/var/www/html/dev.dev/service/index.html,rr->uri=/service/index.html
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=index.jsp,rr->uri=/service/index.jsp
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=index.vm,rr->uri=/service/index.vm
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=/var/www/html/dev.dev/service/index.php,rr->uri=/service/index.php
Just before..., rr->status=200,
rr->finfo.filetype=0,rr->filename=/var/www/html/dev.dev/service/index.php3,rr->uri=/service/index.php3
----------------------
The above shows what the situation is like before that if: filnames
stored in r->filename by jk_map_to_storage() are not absolute file
names. Which then might translate into into r->finfo.filetype being 0,
since that file does not exist on the file system. Notice how other
filenames, not handled by jk_map_to_storage() are absolute.
And since filetype is 0, not APR_REG, the if() never succeeds and proper
request is never made.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs
commit:jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sat, 2002-07-20 at 13:06, Bill Barker wrote:
> I don't know the 2.0.x API well enough to be able to have an opinion on what
> is the correct way to interact with mod_dir however.
The problem is that ap_internal_fast_redirect(rr, r) never gets called
in mod_dir.c. The code goes like this:
----------------------
if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
ap_internal_fast_redirect(rr, r);
return OK;
}
----------------------
One of those conditions is false, I'm just about to find out which
one... Once the condition becomes true (and one of the jk_* hooks needs
to provide that), ap_internal_fast_redirect will get called, which
should then trigger jk_handler.
In Apache 2.0 there are 'just kidding' sub requests that don't actually
call the handler, but rather just check 'what if'. It is normal that
jk_handler never gets called in such circumstances.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit:jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message -----
From: "Bojan Smojver" <bo...@rexursive.com>
To: "Tomcat Dev List" <to...@jakarta.apache.org>
Sent: Friday, July 19, 2002 6:34 PM
Subject: Re: [BUGS: 9913, 10789] Re: cvs
commit:jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
> On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
>
> > OK. I'll try your solution with mod_jk 1.2.0 and mod_jk2 people might do
the
> > same. I don't really like my fix in 1.2.0 because it's just a cheap hack
and it
> > doesn't address the root cause of the problem.
>
> Just tried your fix from bug report
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10789. It does work
> with mod_jk 1.2.0 and TC 3.3.x.
>
> What I'm worried about is that although the handler is now JK_HANDLER
> (and my original fix is no longer needed) the actual URI is not the page
> (/some/path/index.jsp or /some/path/index.vm) but again the directory
> itself (/some/path/). This then creates the same problem with
> getServletPath() which returns the directory, not the page. I think TC
> 4.x might have problems with that.
TC 4.x (like 3.3.x) will send a 301 (or 302, I can't remember) redirect to
the welcome file if you pass "/some/path/" to Tomcat which has a "index.vm"
file under it. Not pretty, but no worse than Tomcat stand-alone.
>
> The old mod_jk 1.2.0 for Apache 1.3.x does some magic somewhere to make
> sure the actual page gets picked and sent to Tomcat. I'm trying to find
> where and how is that done and then apply that to mod_jk 1.2.0. It seems
> like the proper thing to do.
As I remember, this is because the 1.3.x mod_jk (both 1.2.0 & 1.1) gets to
map the sub-request from mod_dir. It is actually because mod_jk is acting
dumb rather than because of any magic. In Servlet terms, mod_dir does a
forward, and mod_jk say Mine Mine Mine.
I don't know the 2.0.x API well enough to be able to have an opinion on what
is the correct way to interact with mod_dir however.
>
> Bojan
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit:
jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Sat, 2002-07-20 at 11:59, Mark Miesfeld wrote:
> On 20 Jul 2002 11:34:15 +1000, Bojan Smojver wrote:
>
> : On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
> :
> : > OK. I'll try your solution with mod_jk 1.2.0 and mod_jk2 people might do the
> : > same. I don't really like my fix in 1.2.0 because it's just a cheap hack and it
> : > doesn't address the root cause of the problem.
> :
> : Just tried your fix from bug report
> : http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10789. It does work
> : with mod_jk 1.2.0 and TC 3.3.x.
> :
> : What I'm worried about is that although the handler is now JK_HANDLER
> : (and my original fix is no longer needed) the actual URI is not the page
> : (/some/path/index.jsp or /some/path/index.vm) but again the directory
> : itself (/some/path/). This then creates the same problem with
> : getServletPath() which returns the directory, not the page. I think TC
> : 4.x might have problems with that.
>
> Yes. I was not really suggesting the code I put in the bug report as a
> fix; it was more to prove to myself that I was "sort of" on the right
> track.
>
> What really needs to happen is that when the mod_dir processing
> initiates the sub-request for /some/path/index.jsp && mod_jk matches the
> URI && /some/path/index.jsp maps to an actual file, then that JSP page
> is returned to the client browser as the answer to the request for
> /some/path/.
I'm investigating a few other things as well, particularly introduction
of a other hooks which would make sure of that.
In Apache 2, mod_dir.c has a function fixup_dir, which does the actual
work and belongs to fixup hooks. These things basically run
second-to-last to the actual handler, after map_to_storage phase. mod_jk
1.2.0 (and I think mod_jk2) doesn't have a fixup hook. Maybe something
along those lines...
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Mark Miesfeld <mi...@acm.org>.
On 20 Jul 2002 11:34:15 +1000, Bojan Smojver wrote:
: On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
:
: > OK. I'll try your solution with mod_jk 1.2.0 and mod_jk2 people might do the
: > same. I don't really like my fix in 1.2.0 because it's just a cheap hack and it
: > doesn't address the root cause of the problem.
:
: Just tried your fix from bug report
: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10789. It does work
: with mod_jk 1.2.0 and TC 3.3.x.
:
: What I'm worried about is that although the handler is now JK_HANDLER
: (and my original fix is no longer needed) the actual URI is not the page
: (/some/path/index.jsp or /some/path/index.vm) but again the directory
: itself (/some/path/). This then creates the same problem with
: getServletPath() which returns the directory, not the page. I think TC
: 4.x might have problems with that.
Yes. I was not really suggesting the code I put in the bug report as a
fix; it was more to prove to myself that I was "sort of" on the right
track.
What really needs to happen is that when the mod_dir processing
initiates the sub-request for /some/path/index.jsp && mod_jk matches the
URI && /some/path/index.jsp maps to an actual file, then that JSP page
is returned to the client browser as the answer to the request for
/some/path/.
--
Mark Miesfeld
miesfeld@acm.org
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit:
jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
On Fri, 2002-07-19 at 14:45, Bojan Smojver wrote:
> OK. I'll try your solution with mod_jk 1.2.0 and mod_jk2 people might do the
> same. I don't really like my fix in 1.2.0 because it's just a cheap hack and it
> doesn't address the root cause of the problem.
Just tried your fix from bug report
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10789. It does work
with mod_jk 1.2.0 and TC 3.3.x.
What I'm worried about is that although the handler is now JK_HANDLER
(and my original fix is no longer needed) the actual URI is not the page
(/some/path/index.jsp or /some/path/index.vm) but again the directory
itself (/some/path/). This then creates the same problem with
getServletPath() which returns the directory, not the page. I think TC
4.x might have problems with that.
The old mod_jk 1.2.0 for Apache 1.3.x does some magic somewhere to make
sure the actual page gets picked and sent to Tomcat. I'm trying to find
where and how is that done and then apply that to mod_jk 1.2.0. It seems
like the proper thing to do.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Bojan Smojver <bo...@rexursive.com>.
Quoting Mark Miesfeld <mi...@acm.org>:
> I was just getting ready to post something saying the fix seems to
> break mod_jk2 altogether for me.
Interesting. I haven't actually checked explicit calls to pages with reversed
order and mod_jk 1.2.0, so I don't really know if that breaks it or not. Will
test tonight (Sydney time).
> For one thing, I think, if jk2_map_to_storage is invoked before
> jk2_translate then mod_jk2 is going to return DECLINED all the time.
> Which is what I am seeing. Nothing gets sent over to tomcat.
>
> For example:
>
> jk2_map_to_storage( ) ENTER
> Unparsed uri: /tomcat/examples
> request_rec: 009D79A8
> Return DECLINED
> jk2_map_to_storage( ) ENTER
> Unparsed uri: /tomcat/examples/
> request_rec: 009D79A8
> Return DECLINED
> jk2_map_to_storage( ) ENTER
> Unparsed uri: /tomcat/examples/index.html
> request_rec: 009D59A0
> Return DECLINED
> jk2_map_to_storage( ) ENTER
> Unparsed uri: /tomcat/examples/index.jsp
> request_rec: 009D59A0
> Return DECLINED
> jk2_handler( ) ENTER
> Unparsed uri: /tomcat/examples/
> request_rec: 009D79A8
> uriEnv: 00000000
> Return DECLINED
>
> In jk2_map_to_storage the start of the code is:
>
> jk_uriEnv_t *uriEnv=ap_get_module_config( r->request_config,
> &jk2_module );
>
> if( uriEnv != NULL ) {
>
> but the only calls to
>
> ap_set_module_config( r->request_config, &jk2_module, uriEnv );
>
> are in jk2_translate.
>
> So, it seems to me that jk2_translate needs to be invoked before
> jk2_map_to_storage. Which is what I thought the original order was.
> But I have to confess I really do not understand APR_HOOK_MIDDLE,
> APR_HOOK_FIRST, etc.
I don't really understand Apache all that well, but the API documentation talks
about 'Controlling hook calling order'. From 'Apache Hook Functions' document:
"...all modules using HOOK_FIRST will run before the HOOK_MIDDLE which are
before HOOK_LAST." If the order is unimportant, HOOK_MIDDLE is recommended.
> Anyhow, the bottom line is that on my machine doing a clean and then
> rebuilding tomcat and mod_jk2 using the latest
> jakarta-tomcat-connectors
> from cvs, leaves me with mod_jk2 not sending anything on to tomcat.
OK. I'll try your solution with mod_jk 1.2.0 and mod_jk2 people might do the
same. I don't really like my fix in 1.2.0 because it's just a cheap hack and it
doesn't address the root cause of the problem
The reason why it didn't work in mod_jk2 is the fact that the test was wrong. It
should have been:
-----------------------
if((uriEnv==NULL || strcmp(r->handler,JK_HANDLER)) &&
strcmp(r->handler,DIR_MAGIC_TYPE)))
return DECLINED;
-----------------------
But even that probably wouldn't work with TC 4.x because getServletPath() would
start returning strange things. I think your approach is much better.
Bojan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [BUGS: 9913, 10789] Re: cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c
Posted by Mark Miesfeld <mi...@acm.org>.
On Fri, 19 Jul 2002 13:57:22 +1000 (EST), Bojan Smojver wrote:
: My experience from 1.2.0 is similar to Mark's with 2.x - the handler never gets
: called because the r->handler is DIR_MAGIC_TYPE, not JK_HANDLER. So, I think
: Mark's code would be the real fix for both - giving Apache a hint that the
: handler is JK_HANDLER.
:
: ...
:
: Mladen, what's your take on all this? Do you have a setup handy to verify that
: the changing of hook ordering fixed the problem in mod_jk2?
:
: Mark, does the fix in mod_jk2 work in your environment?
I was just getting ready to post something saying the fix seems to break
mod_jk2 altogether for me.
For one thing, I think, if jk2_map_to_storage is invoked before
jk2_translate then mod_jk2 is going to return DECLINED all the time.
Which is what I am seeing. Nothing gets sent over to tomcat.
For example:
jk2_map_to_storage( ) ENTER
Unparsed uri: /tomcat/examples
request_rec: 009D79A8
Return DECLINED
jk2_map_to_storage( ) ENTER
Unparsed uri: /tomcat/examples/
request_rec: 009D79A8
Return DECLINED
jk2_map_to_storage( ) ENTER
Unparsed uri: /tomcat/examples/index.html
request_rec: 009D59A0
Return DECLINED
jk2_map_to_storage( ) ENTER
Unparsed uri: /tomcat/examples/index.jsp
request_rec: 009D59A0
Return DECLINED
jk2_handler( ) ENTER
Unparsed uri: /tomcat/examples/
request_rec: 009D79A8
uriEnv: 00000000
Return DECLINED
In jk2_map_to_storage the start of the code is:
jk_uriEnv_t *uriEnv=ap_get_module_config( r->request_config, &jk2_module );
if( uriEnv != NULL ) {
but the only calls to
ap_set_module_config( r->request_config, &jk2_module, uriEnv );
are in jk2_translate.
So, it seems to me that jk2_translate needs to be invoked before
jk2_map_to_storage. Which is what I thought the original order was.
But I have to confess I really do not understand APR_HOOK_MIDDLE,
APR_HOOK_FIRST, etc..
Anyhow, the bottom line is that on my machine doing a clean and then
rebuilding tomcat and mod_jk2 using the latest jakarta-tomcat-connectors
from cvs, leaves me with mod_jk2 not sending anything on to tomcat.
--
Mark Miesfeld
miesfeld@acm.org
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>