push_handlers weirdness...
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. changing shift() to Apache-request() yields: outside...PerlInitHandler/ at /usr/lib/perl5/site_perl/5.005/Test/Test.pm line 10. outside...PerlHandler/ at /usr/lib/perl5/site_perl/5.005/Test/Test.pm line 10. inside...PerlCleanupHandler/ at /usr/lib/perl5/site_perl/5.005/Test/Test.pm line 11. inside...PerlCleanupHandler/ at /usr/lib/perl5/site_perl/5.005/Test/Test.pm line 11. which still isn't quite right, but sorta like what I might expect when reading through mod_dir code and the ap_internal_redirect docs... I tried playing around with setting $r in the anon subroutine too, but I still can't get push_handlers to push code to the cleanup phase for the internal redirect... I guess the question I have is what's being shift()ed that for that second pass and if the problem is just my code, mod_perl, mod_dir, or not-a-problem/expected behavior... fun, eh? --Geoff
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 :) --kip