perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Quatravaux <...@idealx.com>
Subject [PATCH] Re: [BUG] Bad refcounting in Apache->push_handlers()
Date Thu, 31 Mar 2005 14:26:36 GMT
> Any chance you could add a test to the modperl2 test suite that I can 
> reproduce the problem with?

I finally got around to doing that, sorry for the delay. Here is a new
test case, with inspiration from TestHooks::inlined_handlers.

Warning: since Apache->server->push_handlers() needs to operate at the
global server-config level, once this patch is applied, the *entire*
test suite mostly stops working :-] However, I am confident that once
the bug is gone this patch will no longer be intrusive, because when I
un-inline the sub (there is a commented-out line to that effect in the
test case file), the test suite passes correctly as a whole.

Regards,

diff --exclude .svn -Naur mod_perl-2.ORIG/t/hooks/TestHooks/inlined_handlers_server_wide.pm
mod_perl-2/t/hooks/TestHooks/inlined_handlers_server_wide.pm
--- mod_perl-2.ORIG/t/hooks/TestHooks/inlined_handlers_server_wide.pm	1970-01-01 01:00:00.000000000
+0100
+++ mod_perl-2/t/hooks/TestHooks/inlined_handlers_server_wide.pm	2005-03-31 16:20:20.000000000
+0200
@@ -0,0 +1,48 @@
+package TestHooks::inlined_handlers_server_wide;
+
+# this test exercises Apache handlers as anonymous subs, installed
+# using Apache->server->push_handlers() at mod_perl initialization
+# time.
+# Previously there was a refcounting bug there, similar to the
+# one described in inlined_handlers.pm
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::RequestIO ();
+use Apache2::ServerUtil ();
+use Apache2::Const -compile => qw(OK DECLINED);
+
+our $answer = "not ok 1\n";
+
+sub test_waz_zere {
+    my ($r) = @_;
+    $r->notes->set("test_waz_zere", 1);
+    Apache2::DECLINED;
+}
+
+BEGIN { if ($ENV{MOD_PERL}) {
+## This works (non-inlined handler):
+#    Apache2->server->push_handlers(PerlFixupHandler => \&test_waz_zere );
+## This did not work as of Subversion r159573:
+    Apache2->server->push_handlers(PerlFixupHandler => sub { test_waz_zere() });
+} }
+
+sub handler {
+    my $r = shift;
+
+    $r->print("1..1\n");
+    $r->print($r->notes->get("test_waz_zere") ? "ok 1\n" :
+             "not ok 1\n");
+    Apache2::OK;
+}
+
+1;
+__DATA__
+<NoAutoConfig>
+    PerlModule TestHooks::inlined_handlers_server_wide
+  <Location /TestHooks__inlined_handlers_server_wide>
+      SetHandler modperl
+      PerlResponseHandler TestHooks::inlined_handlers_server_wide
+  </Location>
+</NoAutoConfig>


-- 
Dominique QUATRAVAUX                           Ingénieur senior
01 44 42 00 08                                 IDEALX


Mime
View raw message