perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fred Moyer" <f...@taperfriendlymusic.org>
Subject [Fwd: Re: mp2: push_handlers / set_handlers vs. Perl*Handler]
Date Thu, 14 Sep 2006 22:28:57 GMT
[Forwarding from modperl@perl.apache.org]
[fred@taperfriendlymusic.org wrote]
>> So I have been playing with different combinations of push_handlers()
>> and it looks like it's working properly for RUN_FIRST handlers (my
>> initial success with using DECLINED instead of OK) but not RUN_ALL
>> handlers.
[geoff@modperlcookbook.org wrote]
> argh.

>> Here's the test case, run make test and check the log to see
>> which handlers ran.  Anyone?

> well, I added something simple to the test suite, which looks like what
> you're trying to do, but I couldn't get it to fail.

> could you adjust this patch so that you can replicate the problem then
> submit it to dev?  that way we have something in the test suite that
> exhibits the problem so we can replicate it and keep from regressing
> later on.

Geoff, the patch you gave me passed, which is good.  I have adjusted the
patch so that it replicates the problem that Jeremy and I both ran into. 
The specific problem seems to be that push_handlers doesn't behave as it
should when pushing a FixupHandler from a PostReadRequestHandler, if I am
understanding how this test works.  The fixup handler gets pushed ok, but
it seems to remove the existing Fixup handlers.  Let me know if you want
me test this another way, it's possible that I'm not fully grokking the
test magic here but I think I get it.

# Using Test.pm version 1.25
# Using Apache/Test.pm version 1.29
# Failed test 1 in t/hooks/stacked_handlers2.t at line 35
# testing : stacked_handlers
# expected: ran 3 PerlPostReadRequestHandler handlers
# ran 1 PerlTransHandler handlers
# ran 1 PerlMapToStorageHandler handlers
# ran 4 PerlHeaderParserHandler handlers
# ran 2 PerlAccessHandler handlers
# ran 2 PerlAuthenHandler handlers
# ran 2 PerlAuthzHandler handlers
# ran 1 PerlTypeHandler handlers
# ran 3 PerlFixupHandler handlers
# ran 2 PerlResponseHandler handlers
# ran 2 PerlOutputFilterHandler handlers
# received: ran 3 PerlPostReadRequestHandler handlers
# ran 1 PerlTransHandler handlers
# ran 1 PerlMapToStorageHandler handlers
# ran 4 PerlHeaderParserHandler handlers
# ran 2 PerlAccessHandler handlers
# ran 2 PerlAuthenHandler handlers
# ran 2 PerlAuthzHandler handlers
# ran 1 PerlTypeHandler handlers
# ran 1 PerlFixupHandler handlers
# ran 2 PerlResponseHandler handlers
# ran 2 PerlOutputFilterHandler handlers
not ok 1
FAILED test 1
        Failed 1/1 tests, 0.00% okay
Failed Test                 Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/hooks/stacked_handlers2.t                1    1 100.00%  1
Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay.

Index: t/hooks/stacked_handlers2.t
===================================================================
--- t/hooks/stacked_handlers2.t (revision 443450)
+++ t/hooks/stacked_handlers2.t (working copy)
@@ -18,7 +18,7 @@

 plan tests => 1;

-my $expected = q!ran 2 PerlPostReadRequestHandler handlers
+my $expected = q!ran 3 PerlPostReadRequestHandler handlers
 ran 1 PerlTransHandler handlers
 ran 1 PerlMapToStorageHandler handlers
 ran 4 PerlHeaderParserHandler handlers
@@ -26,7 +26,7 @@
 ran 2 PerlAuthenHandler handlers
 ran 2 PerlAuthzHandler handlers
 ran 1 PerlTypeHandler handlers
-ran 2 PerlFixupHandler handlers
+ran 3 PerlFixupHandler handlers
 ran 2 PerlResponseHandler handlers
 ran 2 PerlOutputFilterHandler handlers!;

Index: t/hooks/TestHooks/stacked_handlers2.pm
===================================================================
--- t/hooks/TestHooks/stacked_handlers2.pm      (revision 443450)
+++ t/hooks/TestHooks/stacked_handlers2.pm      (working copy)
@@ -45,6 +45,17 @@
     return Apache2::Const::SERVER_ERROR;
 }

+sub push_fixup_handler {
+
+    my $r = shift;
+
+    $r->push_handlers(PerlFixupHandler => \&ok);
+
+    callback($r);
+
+    return Apache2::Const::OK;
+}
+
 sub callback {

     my $obj = shift;
@@ -139,7 +150,8 @@

     PerlModule TestHooks::stacked_handlers2

-    # all 2 run
+    # all 3 run
+    PerlPostReadRequestHandler
TestHooks::stacked_handlers2::push_fixup_handler    
PerlPostReadRequestHandler TestHooks::stacked_handlers2::ok
TestHooks::stacked_handlers2::ok

Mime
View raw message