You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Marc Lehmann <pc...@goof.com> on 2001/02/11 21:43:10 UTC

problems with %Location inside perl-sections

I have two problems related to setting Location directives from within
perl sections that I don't understand (I've looked at the mod_perl guide
and the archive but a RTFM is certainly welcome ;)

First problem: <Location> works on url space only while $Location
requires existing directories (full httpd.conf atatched):

   DocumentRoot /tmp

   <Location /perl-status>
      SetHandler perl-script
      PerlHandler Apache::Status
   </Location>

   <Perl>
      $Location{'/test'} = {
         SetHandler => 'perl-script',
         PerlHandler => "Apache::Status",
      };
   </Perl>

The first location works fine. The second one doesn't UNTIL I mkdir
/tmp/test (there is no /tmp/perl-status), after which I get the
perl-status page on both urls.

The second problem (which I can't reproduce with a small example) is that,
when using a lot of entries in %Location, they suddenly start to behave
like LocationMatch, i.e.:

   $Location{'/admin'} = { ... };

matches /test/admin, /something/else/admin/jump, /cgi-bin/printenv/admin
and everything else that contains /admin IFF the url does not directly
point to something hat can be displayed (e.g. the printenv is a cgi script
but it doesn't get called).

If I change this to:

   $Location{'^/admin'} = { ... };

it suddenly starts to work as expected, indeed as if LocationMatch was
used. However, this is not deterministic. Sometimes the above simply
matches nothing ;)

Does this ring a bell for somebody? I ahd the same problem with
apache-1.3.14 and mod_perl-1.24 I upgraded to apache-1.3.17 and modperl
from cvs but the symptoms didn't change so I guess it might not be a bug
but rather some misunderstanding on my side :(

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |

Re: problems with %Location inside perl-sections

Posted by Stas Bekman <st...@stason.org>.
On Mon, 12 Feb 2001, Marc Lehmann wrote:

> On Mon, Feb 12, 2001 at 08:48:57AM +0800, Stas Bekman <st...@stason.org> wrote:
> > Looks like Apache doing stat() calls problem. Try to run the request under
> > strace(1) or truss(1). See:
> > http://perl.apache.org/guide/performance.html#Reducing_the_Number_of_stat_Ca
>
> this is with perl-status:
>
> [pid 14461] stat("/tmp/perl-status", 0xbffff3cc) = -1 ENOENT (No such file or directory)
> [pid 14461] stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=3505, ...}) = 0
> [pid 14461] open("/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
> [pid 14461] open("/tmp/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
>
> and this is the same as with /test when there is no /tmp/test. With an
> existing /tmp/test, I get:
>
> [pid 14460] stat("/tmp/test", {st_mode=S_IFDIR|0755, st_size=35, ...}) = 0
> [pid 14460] open("/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
> [pid 14460] open("/tmp/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
> [pid 14460] open("/tmp/test/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)

Seems OK to me. I cannot reproduce your problem on my setup. The only
difference I have is that I have 'Options None' so I don't get the
.htaccess lookup.

> > >    $Location{'/admin'} = { ... };
> > >    $Location{'^/admin'} = { ... };
> >
> > Again, what strace tells you?
>
> apache is stat()'ing the path as long as it can, i.e. until
> .../cgi-bin/printenv oder . (there is no /admin directory in my
> DocumentRoot).
>
> > You will see everything that Apache does
> > while looking at the output.
>
> I couldn't try with PerlTransHandler yet (since I seem to have left this
> out when compiling mod_perl), but my question is: does this also fix the
> problems I encounter? I am not concerned about speed here, but rather
> about correctness, namely that I need ^/admin which shouldn't match at all
> in a Location directive.

What happens if you don't use C<Perl> sections and just a normal Apache
config? Also it's possible that you mix-up name spaces, so Apache gets the
wrong location matched. You can see the docs about that in guide's config
chapter or in Apache manual. If that's the problem.

> Thanks a lot for your reply!
>
> --
>       -----==-                                             |
>       ----==-- _                                           |
>       ---==---(_)__  __ ____  __       Marc Lehmann      +--
>       --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
>       -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
>     The choice of a GNU generation                       |
>                                                          |
>



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/




Re: problems with %Location inside perl-sections

Posted by Marc Lehmann <pc...@goof.com>.
On Mon, Feb 12, 2001 at 08:48:57AM +0800, Stas Bekman <st...@stason.org> wrote:
> Looks like Apache doing stat() calls problem. Try to run the request under
> strace(1) or truss(1). See:
> http://perl.apache.org/guide/performance.html#Reducing_the_Number_of_stat_Ca

this is with perl-status:

[pid 14461] stat("/tmp/perl-status", 0xbffff3cc) = -1 ENOENT (No such file or directory)
[pid 14461] stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=3505, ...}) = 0
[pid 14461] open("/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 14461] open("/tmp/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)

and this is the same as with /test when there is no /tmp/test. With an
existing /tmp/test, I get:

[pid 14460] stat("/tmp/test", {st_mode=S_IFDIR|0755, st_size=35, ...}) = 0
[pid 14460] open("/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 14460] open("/tmp/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 14460] open("/tmp/test/.htaccess", O_RDONLY) = -1 ENOENT (No such file or directory)

> >    $Location{'/admin'} = { ... };
> >    $Location{'^/admin'} = { ... };
> 
> Again, what strace tells you?

apache is stat()'ing the path as long as it can, i.e. until
.../cgi-bin/printenv oder . (there is no /admin directory in my
DocumentRoot).

> You will see everything that Apache does
> while looking at the output. 

I couldn't try with PerlTransHandler yet (since I seem to have left this
out when compiling mod_perl), but my question is: does this also fix the
problems I encounter? I am not concerned about speed here, but rather
about correctness, namely that I need ^/admin which shouldn't match at all
in a Location directive.

Thanks a lot for your reply!

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |

Re: problems with %Location inside perl-sections

Posted by Stas Bekman <st...@stason.org>.
On Sun, 11 Feb 2001, Marc Lehmann wrote:

> I have two problems related to setting Location directives from within
> perl sections that I don't understand (I've looked at the mod_perl guide
> and the archive but a RTFM is certainly welcome ;)
> 
> First problem: <Location> works on url space only while $Location
> requires existing directories (full httpd.conf atatched):
> 
>    DocumentRoot /tmp
> 
>    <Location /perl-status>
>       SetHandler perl-script
>       PerlHandler Apache::Status
>    </Location>
> 
>    <Perl>
>       $Location{'/test'} = {
>          SetHandler => 'perl-script',
>          PerlHandler => "Apache::Status",
>       };
>    </Perl>
> 
> The first location works fine. The second one doesn't UNTIL I mkdir
> /tmp/test (there is no /tmp/perl-status), after which I get the
> perl-status page on both urls.

Looks like Apache doing stat() calls problem. Try to run the request under
strace(1) or truss(1). See:
http://perl.apache.org/guide/performance.html#Reducing_the_Number_of_stat_Ca
 
> The second problem (which I can't reproduce with a small example) is that,
> when using a lot of entries in %Location, they suddenly start to behave
> like LocationMatch, i.e.:
> 
>    $Location{'/admin'} = { ... };
> 
> matches /test/admin, /something/else/admin/jump, /cgi-bin/printenv/admin
> and everything else that contains /admin IFF the url does not directly
> point to something hat can be displayed (e.g. the printenv is a cgi script
> but it doesn't get called).
> 
> If I change this to:
> 
>    $Location{'^/admin'} = { ... };
> 
> it suddenly starts to work as expected, indeed as if LocationMatch was
> used. However, this is not deterministic. Sometimes the above simply
> matches nothing ;)
> 
> Does this ring a bell for somebody? I ahd the same problem with
> apache-1.3.14 and mod_perl-1.24 I upgraded to apache-1.3.17 and modperl
> from cvs but the symptoms didn't change so I guess it might not be a bug
> but rather some misunderstanding on my side :(

Again, what strace tells you? You will see everything that Apache does
while looking at the output. 

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/