Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 70509 invoked from network); 31 Mar 2005 14:26:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Mar 2005 14:26:29 -0000 Received: (qmail 35878 invoked by uid 500); 31 Mar 2005 14:26:28 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 35858 invoked by uid 500); 31 Mar 2005 14:26:27 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 35842 invoked by uid 99); 31 Mar 2005 14:26:27 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of dom@idealx.com designates 213.41.87.90 as permitted sender) Received: from sarajevo.idealx.com (HELO sarajevo.idealx.com) (213.41.87.90) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 31 Mar 2005 06:26:27 -0800 Received: from localhost (sarajevo [127.0.0.1]) by sarajevo.idealx.com (IDEALX S.A.S Mail Daemon) with ESMTP id 3EEEC11DCE2 for ; Thu, 31 Mar 2005 16:36:19 +0200 (CEST) Received: from sarajevo.idealx.com ([127.0.0.1]) by localhost (sarajevo.idealx.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04227-31 for ; Thu, 31 Mar 2005 16:36:16 +0200 (CEST) Received: by sarajevo.idealx.com (IDEALX S.A.S Mail Daemon, from userid 10) id 7DE7D11DCE5; Thu, 31 Mar 2005 16:36:15 +0200 (CEST) Received: from dom by saperlipopette with local (Exim 4.22) id 1DH0d2-00010I-HP; Thu, 31 Mar 2005 16:26:36 +0200 Date: Thu, 31 Mar 2005 16:26:36 +0200 From: Dominique Quatravaux To: Stas Bekman Cc: modperl@perl.apache.org, dev@perl.apache.org Subject: [PATCH] Re: [BUG] Bad refcounting in Apache->push_handlers() Message-ID: <20050331142636.GB23413@idealx.com> Mail-Followup-To: Stas Bekman , modperl@perl.apache.org, dev@perl.apache.org References: <422EEC0A.6060503@kilimandjaro.dyndns.org> <422FB264.2030200@stason.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9zSXsLTf0vkW971A" Content-Disposition: inline In-Reply-To: <422FB264.2030200@stason.org> User-Agent: Mutt/1.3.28i X-archive: yes X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --9zSXsLTf0vkW971A Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > Any chance you could add a test to the modperl2 test suite that I can=20 > 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_handler= s_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 =3D> 'all'; + +use Apache2::RequestIO (); +use Apache2::ServerUtil (); +use Apache2::Const -compile =3D> qw(OK DECLINED); + +our $answer =3D "not ok 1\n"; + +sub test_waz_zere { + my ($r) =3D @_; + $r->notes->set("test_waz_zere", 1); + Apache2::DECLINED; +} + +BEGIN { if ($ENV{MOD_PERL}) { +## This works (non-inlined handler): +# Apache2->server->push_handlers(PerlFixupHandler =3D> \&test_waz_zere = ); +## This did not work as of Subversion r159573: + Apache2->server->push_handlers(PerlFixupHandler =3D> sub { test_waz_ze= re() }); +} } + +sub handler { + my $r =3D 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__ + + PerlModule TestHooks::inlined_handlers_server_wide + + SetHandler modperl + PerlResponseHandler TestHooks::inlined_handlers_server_wide + + --=20 Dominique QUATRAVAUX Ing=E9nieur senior 01 44 42 00 08 IDEALX --9zSXsLTf0vkW971A Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFCTAicMJAKAU3mjcsRAt1OAKCLwf/fDoVim+/GyEO1YjuWl69IBwCfcgFA K+JS/aJbiARV/XDsysZNbGc= =MEIb -----END PGP SIGNATURE----- --9zSXsLTf0vkW971A--