You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by simran <si...@reflectit.com> on 2003/10/17 03:16:36 UTC
PerlTransHandler, PerlHanlder and document_root
Hi All,
I have a PerlTransHandler where i am doing something to the effect of:
my $request = instance Apache::Request(shift);
$request->document_root("/home/testuser/www");
$request->pnotes("test_key" => "test_value");
warn "Set document root to /home/testuser/www\n";
Then later in a PerlHandler (in the same request) i am doing:
my $request = instance Apache::Request(shift)
my $root = $request->document_root();
warn "DocRoot=$root\n";
my $value = $request->pnotes("test_key");
warn "TEST VALUE = $value\n";
=====================================================================
In my apache error log i get:
*** Set document root to /home/testuser/www
*** DocRoot=/home/simran/www
*** TEST VALUE = test_value
(/home/simran/www was the document root before i changed it in my
PerlTransHandler).
I'm fairly sure that i am looking at the same request object across the
PerlTransHandler and PerlHandler as the $r->pnotes has the key/value i
set (in the PerlTransHandler) still set in the PerlHandler...
Can anyone advise on how i can debug this further to see what might be
happening... there is no other handlers between the above two (so no
chance of another handler changing the document root back to the
original again).
I am using: Apache/1.3.27 (Unix) mod_ssl/2.8.14 OpenSSL/0.9.6c DAV/1.0.3
mod_perl/1.28, perl 5.8.0
Any help greatly appreciated.
simran.
ps: I believe (if my memory serves me right) that the above used to work
okay under an older version of mod_perl/apache/perl... (and have not got
the environment to test it in again!).
Re: PerlTransHandler, PerlHanlder and document_root
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
simran wrote:
> Further to my previous email (as below), i have noticed that
> if i set the document_root to something that does not exist
> (eg. "/blahblah") - then in the PerlCleanupHandler, the document root (before reset) is
> set to "/blahblah" - if i had set it to something that existed, then was i set it to is not maintained!!!
>
> I have also tried to putting in handlers of every sort and logging what they see, and
> PerlAccessHandler, PerlTypeHandler and PerlFixupHandler all see the correct document root (the one i have set), the PerlHandler
> invoked after the PerlFixupHandler and everything thereafter, do not see the document root i had set.
>
the best thing you can do for us at this point is to reduce the situation
down as far as possible so others can easily reproduce it.
my suggestion is to use Apache-Test to create a self-contained tarball that
exhibits the behavior you describe. you can use this as a starting point:
http://www.modperlcookbook.org/~geoff/bug-mp2.tar.gz
although geared toward mod_perl 2.0, Apache-Test can be used with mp1 as
well. see the following for more examples
http://www.modperlcookbook.org/~geoff/perl.com/Apache-Clean-1.0.tar.gz
http://www.perl.com/pub/a/2003/05/22/testing.html
http://perl.apache.org/docs/general/testing/testing.html
http://www.modperlcookbook.org/~geoff/slides/OSCon/2003/OSCon2003-test-printable.ppt
basically, if you create a tarball that others can use to reproduce the
problem, it's more likely to get pinpointed and addressed. you might even
"fix" the bug in the process (by removing something that was interfering),
or even learn something both useful and fun :)
oh, and please post a link to the tarball, rather than including it in an
email to the list ;)
--Geoff
RE: PerlTransHandler, PerlHanlder and document_root
Posted by simran <si...@reflectit.com>.
Further to my previous email (as below), i have noticed that
if i set the document_root to something that does not exist
(eg. "/blahblah") - then in the PerlCleanupHandler, the document root (before reset) is
set to "/blahblah" - if i had set it to something that existed, then was i set it to is not maintained!!!
I have also tried to putting in handlers of every sort and logging what they see, and
PerlAccessHandler, PerlTypeHandler and PerlFixupHandler all see the correct document root (the one i have set), the PerlHandler
invoked after the PerlFixupHandler and everything thereafter, do not see the document root i had set.
a very confused,
simran.
On Fri, 2003-10-17 at 22:12, Frank Maas wrote:
> >> Can it be that a subrequest (issued (by chance?) to the same child)
> >> is messing things up? You might try adding a warn to the
> >> CleanupHandler.
> >
> > I guess it could be... what should i be logging for in the
> > CleanupHandler? (aka, what should i print to see if its a subrequest,
> > and if it is, where it was called form?).
>
> I think a simple logmessage would help already, but you might want to
> try
>
> print STDERR 'Cleanup handler called for '.($r->is_initial_req() ?
> 'initial' : 'sub').' request for '.$r->uri().'. Document root was
> '.$r->document_root();
>
> and this before you reset document_root...
Tried the above, and i get the following output:
Cleanup handler called for initial request for /auto/thumbnail/images/fluorescence6.jpg. Document root was /home/simran/netchant/www/simran-sb/docs at /home/simran/netchant/lib/NetChant/Component/SB/Handlers.pm line 157.
The document root should have been: /home/simran/netchant/www/simran-sb/docs.stage
The document root however was : /home/simran/netchant/www/simran-sb/docs
So it looks like the request is "initial" - however, something else is
resetting the document_root. I don't have any place in my code (anywhere) where i touch
the document_root (other than when i am setting it to docs.stage or in the PerlCleanupHandler)
so its a strange one indeed...
simran.
RE: PerlTransHandler, PerlHanlder and document_root
Posted by simran <si...@reflectit.com>.
Thanks Frank,
On Fri, 2003-10-17 at 22:12, Frank Maas wrote:
> >> Can it be that a subrequest (issued (by chance?) to the same child)
> >> is messing things up? You might try adding a warn to the
> >> CleanupHandler.
> >
> > I guess it could be... what should i be logging for in the
> > CleanupHandler? (aka, what should i print to see if its a subrequest,
> > and if it is, where it was called form?).
>
> I think a simple logmessage would help already, but you might want to
> try
>
> print STDERR 'Cleanup handler called for '.($r->is_initial_req() ?
> 'initial' : 'sub').' request for '.$r->uri().'. Document root was
> '.$r->document_root();
>
> and this before you reset document_root...
Tried the above, and i get the following output:
Cleanup handler called for initial request for /auto/thumbnail/images/fluorescence6.jpg. Document root was /home/simran/netchant/www/simran-sb/docs at /home/simran/netchant/lib/NetChant/Component/SB/Handlers.pm line 157.
The document root should have been: /home/simran/netchant/www/simran-sb/docs.stage
The document root however was : /home/simran/netchant/www/simran-sb/docs
So it looks like the request is "initial" - however, something else is
resetting the document_root. I don't have any place in my code (anywhere) where i touch
the document_root (other than when i am setting it to docs.stage or in the PerlCleanupHandler)
so its a strange one indeed...
simran.
RE: PerlTransHandler, PerlHanlder and document_root
Posted by Frank Maas <fr...@cheiron-it.nl>.
> Hi Frank,
[...]
>> Can it be that a subrequest (issued (by chance?) to the same child)
>> is messing things up? You might try adding a warn to the
>> CleanupHandler.
>
> I guess it could be... what should i be logging for in the
> CleanupHandler? (aka, what should i print to see if its a subrequest,
> and if it is, where it was called form?).
I think a simple logmessage would help already, but you might want to
try
print STDERR 'Cleanup handler called for '.($r->is_initial_req() ?
'initial' : 'sub').' request for '.$r->uri().'. Document root was
'.$r->document_root();
and this before you reset document_root...
--Frank
RE: PerlTransHandler, PerlHanlder and document_root
Posted by simran <si...@reflectit.com>.
Hi Frank,
On Fri, 2003-10-17 at 18:21, Frank Maas wrote:
> Simran,
>
> Just trying:
>
> GH> however, any changes made to $r->document_root
> GH> would persist for the entire life of the child, not just the life of
> GH> the current request. for that reason, you were expected to always
> GH> restore the value of $r->document_root to its original state.
> GH>
> GH> see recipe 4.3 in the cookbook
>
> > Thanks for those... those are the exact ones i have followed.
>
> Can it be that a subrequest (issued (by chance?) to the same child) is
> messing things up? You might try adding a warn to the CleanupHandler.
I guess it could be... what should i be logging for in the
CleanupHandler? (aka, what should i print to see if its a subrequest,
and if it is, where it was called form?).
simran.
>
> Just my 1.5c
>
> --Frank
RE: PerlTransHandler, PerlHanlder and document_root
Posted by Frank Maas <fr...@cheiron-it.nl>.
Simran,
Just trying:
GH> however, any changes made to $r->document_root
GH> would persist for the entire life of the child, not just the life of
GH> the current request. for that reason, you were expected to always
GH> restore the value of $r->document_root to its original state.
GH>
GH> see recipe 4.3 in the cookbook
> Thanks for those... those are the exact ones i have followed.
Can it be that a subrequest (issued (by chance?) to the same child) is
messing things up? You might try adding a warn to the CleanupHandler.
Just my 1.5c
--Frank
Re: PerlTransHandler, PerlHanlder and document_root
Posted by simran <si...@reflectit.com>.
On Fri, 2003-10-17 at 13:07, Geoffrey Young wrote:
> simran wrote:
> > Hi All,
> >
> > I have a PerlTransHandler where i am doing something to the effect of:
> >
> > my $request = instance Apache::Request(shift);
> > $request->document_root("/home/testuser/www");
> > $request->pnotes("test_key" => "test_value");
> > warn "Set document root to /home/testuser/www\n";
> >
> > Then later in a PerlHandler (in the same request) i am doing:
> >
> > my $request = instance Apache::Request(shift)
> > my $root = $request->document_root();
> >
> > warn "DocRoot=$root\n";
> > my $value = $request->pnotes("test_key");
> > warn "TEST VALUE = $value\n";
> >
> > =====================================================================
> >
> > In my apache error log i get:
> >
> > *** Set document root to /home/testuser/www
> > *** DocRoot=/home/simran/www
> > *** TEST VALUE = test_value
> >
> > (/home/simran/www was the document root before i changed it in my
> > PerlTransHandler).
> >
> > I'm fairly sure that i am looking at the same request object across the
> > PerlTransHandler and PerlHandler as the $r->pnotes has the key/value i
> > set (in the PerlTransHandler) still set in the PerlHandler...
> >
> > Can anyone advise on how i can debug this further to see what might be
> > happening... there is no other handlers between the above two (so no
> > chance of another handler changing the document root back to the
> > original again).
>
> yike.
>
> try using just the passed in Apache object instead of the cached instance
> object and see what happens. something is definitely amuck.
Tried that... (new Apache::Request(shift)) but same result
unfortunately...
>
> >
> > I am using: Apache/1.3.27 (Unix) mod_ssl/2.8.14 OpenSSL/0.9.6c DAV/1.0.3
> > mod_perl/1.28, perl 5.8.0
> >
> > Any help greatly appreciated.
> >
> > simran.
> >
> > ps: I believe (if my memory serves me right) that the above used to work
> > okay under an older version of mod_perl/apache/perl... (and have not got
> > the environment to test it in again!).
>
> well, sort of. in previous versions of apache it was possible to set
> $r->document_root. however, any changes made to $r->document_root would
> persist for the entire life of the child, not just the life of the current
> request. for that reason, you were expected to always restore the value of
> $r->document_root to its original state.
>
> see recipe 4.3 in the cookbook
>
> http://www.webreference.com/programming/perl/cookbook/chap4/2.html
> http://www.modperlcookbook.org/code/ch04/Cookbook/Userdir.pm
Thanks for those... those are the exact ones i have followed. I had
mailed a question about document_root a few months ago and upon your
advice then, i had followed those exact recipes (and my code for the
most part of my subroutine is a copy/past job from the above URL's -
including the PerlCleanupHandler... )
any other ideas on how i can debug this would be greatly appreciated...
simran.
>
> I'm not aware of any changes in apache that would make this no longer true,
> but you never know...
>
> --Geoff
Re: PerlTransHandler, PerlHanlder and document_root
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
simran wrote:
> Hi All,
>
> I have a PerlTransHandler where i am doing something to the effect of:
>
> my $request = instance Apache::Request(shift);
> $request->document_root("/home/testuser/www");
> $request->pnotes("test_key" => "test_value");
> warn "Set document root to /home/testuser/www\n";
>
> Then later in a PerlHandler (in the same request) i am doing:
>
> my $request = instance Apache::Request(shift)
> my $root = $request->document_root();
>
> warn "DocRoot=$root\n";
> my $value = $request->pnotes("test_key");
> warn "TEST VALUE = $value\n";
>
> =====================================================================
>
> In my apache error log i get:
>
> *** Set document root to /home/testuser/www
> *** DocRoot=/home/simran/www
> *** TEST VALUE = test_value
>
> (/home/simran/www was the document root before i changed it in my
> PerlTransHandler).
>
> I'm fairly sure that i am looking at the same request object across the
> PerlTransHandler and PerlHandler as the $r->pnotes has the key/value i
> set (in the PerlTransHandler) still set in the PerlHandler...
>
> Can anyone advise on how i can debug this further to see what might be
> happening... there is no other handlers between the above two (so no
> chance of another handler changing the document root back to the
> original again).
yike.
try using just the passed in Apache object instead of the cached instance
object and see what happens. something is definitely amuck.
>
> I am using: Apache/1.3.27 (Unix) mod_ssl/2.8.14 OpenSSL/0.9.6c DAV/1.0.3
> mod_perl/1.28, perl 5.8.0
>
> Any help greatly appreciated.
>
> simran.
>
> ps: I believe (if my memory serves me right) that the above used to work
> okay under an older version of mod_perl/apache/perl... (and have not got
> the environment to test it in again!).
well, sort of. in previous versions of apache it was possible to set
$r->document_root. however, any changes made to $r->document_root would
persist for the entire life of the child, not just the life of the current
request. for that reason, you were expected to always restore the value of
$r->document_root to its original state.
see recipe 4.3 in the cookbook
http://www.webreference.com/programming/perl/cookbook/chap4/2.html
http://www.modperlcookbook.org/code/ch04/Cookbook/Userdir.pm
I'm not aware of any changes in apache that would make this no longer true,
but you never know...
--Geoff