perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <gyo...@laserlink.net>
Subject current_callback bug [ was: push_handlers weirdness]
Date Thu, 01 Jun 2000 11:35:22 GMT


> -----Original Message-----
> From: Kip Cranford [mailto:kcranford@advance-inc.com]
> Sent: Wednesday, May 31, 2000 5:51 PM
> To: Geoffrey Young
> Cc: modperl@apache.org
> Subject: Re: push_handlers weirdness... 
> 
> 
> On: Wed, 31 May 2000 17:04:05 EDT Geoffrey Young wrote:
> 
> >hi all...
> >
> >	I'm not sure if this is related to some of the get/set handler
> >strangeness that I have been seeing lately (as I try to do some weird
> >stacked handler acrobatics), or if it's the result of some 
> closure thing
> >that I really shouldn't be doing...
> >
> >package Test::Test;
> >use Apache::Constants qw( OK );
> >use strict;
> >sub handler
> >{
> >    my $r = shift;
> >    warn "outside..." . $r->current_callback . $r->uri;
> >    $r->push_handlers(PerlCleanupHandler => sub { warn "inside..." .
> >$r->current_callback . $r->uri;
> >                                                  return OK;});
> >    return OK;
> >}
> >1;
> >
> >anyway, for / => /index.html translation using mod_dir, this 
> PerlInitHandler
> >produces:
> >
> >outside...PerlInitHandler/ at 
> /usr/lib/perl5/site_perl/5.005/Test/Test.pm
> >line 9.
> >outside...PerlInitHandler/index.html at
> >/usr/lib/perl5/site_perl/5.005/Test/Test.pm line 9.
> >
> >inside...PerlCleanupHandler/ at 
> /usr/lib/perl5/site_perl/5.005/Test/Test.pm
> >line 10.
> >inside...PerlFixupHandler/index.html at
> >/usr/lib/perl5/site_perl/5.005/Test/Test.pm line 10.
> 
> Hi Geoff,
> 
> Isn't this what's expected?  The first time through (for "/") 
> you push code
> onto the CleanupHandler stack.
> 
> Then there's a subrequest (by mod_dir, although I'm just 
> guessing here) to
> check for "/index.html", which causes another code ref to be 
> pushed onto
> the CleanupHandler stack.
> 
> At the completion of the subrequest, the original request is 
> completed,
> having two code refs to evaluate once it reaches the Cleanup 
> "phase", one
> for the original "/" and one for the "/index.html".
> 
> Or am I totally missing your point :)

hi kip...

well, what you describe is exactly what I would expect :)  however, what was
troubling me was the magic conversion of PerlCleanupHandler to
PerlFixupHandler...

I just recompiled using PERL_DEBUG.  Here's the relevant part:

running 2 pushed (stacked) handlers for /...
calling &{PerlCleanupHandler->[0]} (2 total)
perl_call: handler is a cached CV
blessing request_rec=(0x85aed4c)
inside...PerlCleanupHandler/ at /usr/lib/perl5/site_perl/5.005/Test/Test.pm
line 11.
perl_call_handler: SVs = 29348, OBJs =    16
&{PerlCleanupHandler->[0]} returned status=0
calling &{PerlCleanupHandler->[1]} (2 total)
perl_call: handler is a cached CV
blessing request_rec=(0x85aed4c)
inside...PerlFixupHandler/index.html at
/usr/lib/perl5/site_perl/5.005/Test/Test.pm line 11.
perl_call_handler: SVs = 29348, OBJs =    16
&{PerlCleanupHandler->[1]} returned status=0
PerlCleanupHandler handlers returned 0


I guess I'm somewhat relieved that it's the call to current_callback() that
seems to be at fault and not the request cycle :)
For what it's worth, $r->notes('PERL_CUR_HOOK') contains the wrong value as
well...

I'm still not sure whether the request record is getting confused or not,
since shift() and Apache->request give different results, but perhaps
there's an easy explanation for this outside of the current context?

--Geoff

> 
> --kip
> 

Mime
View raw message