Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 71009 invoked from network); 29 May 2005 17:50:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 May 2005 17:50:24 -0000 Received: (qmail 77144 invoked by uid 500); 29 May 2005 17:50:15 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 77128 invoked by uid 500); 29 May 2005 17:50:14 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 77109 invoked by uid 99); 29 May 2005 17:50:14 -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 mark@immermail.com designates 207.8.226.5 as permitted sender) Received: from orb.pobox.com (HELO orb.pobox.com) (207.8.226.5) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 29 May 2005 10:50:14 -0700 Received: from orb (localhost [127.0.0.1]) by orb.pobox.com (Postfix) with ESMTP id 1BFC690B for ; Sun, 29 May 2005 13:49:56 -0400 (EDT) Received: from [192.168.1.2] (adsl-63-195-70-242.dsl.snfc21.pacbell.net [63.195.70.242]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by orb.sasl.smtp.pobox.com (Postfix) with ESMTP id B4F0D8E for ; Sun, 29 May 2005 13:49:55 -0400 (EDT) Message-ID: <429A0164.9090303@immermail.com> Date: Sun, 29 May 2005 10:52:36 -0700 From: Mark User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: modperl@perl.apache.org Subject: Re: Apache2::Reload problem (ModPerl::Util bug) References: <4299FCA2.1040604@immermail.com> In-Reply-To: <4299FCA2.1040604@immermail.com> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Mark wrote: > In 2.0.0, if there are heirarchical packages, and Apache2::Reload is > configured to reload the 'parent', it blows away the 'children' package > namespaces (and doesn't reload the children.) For example, if @INC has: > > Fubar.pm > Fubar/Child.pm > > And Apache2::Reload reloads package Fubar, it blows away > Fubar::Child::* and only reloads file Fubar.pm. Only a server > restart can recover from this point. > > The actual unloading work is done by ModPerl::Util::unload_package(), > whose behavior is contrary to the docs, which say: > > "unload_package()" takes care to leave sub-stashes intact while > deleting the requested stash. So for example if "CGI" and "CGI::Carp" > are loaded, calling "unload_package('CGI')" won't affect "CGI::Carp". > > > I only partly understand how unload_package() works, but it seems to > just iterate over symbols in the package and blow them away, without > regard for the actual file from which the symbol was instantiated. > > I tried modifying the code to skip over symbols that correspond > to a key in %INC, which seems logical and works correctly in my tests, > but may not be a complete or perfect solution for reasons beyond > my current testing/thinking. However, in my tests, it works correctly > if either the parent package, child package, or both are modified. > > Comments/suggestions about the correctness of this patch requested. Correction. Ignore previous patch. It only worked one level of heirarchy. Correct patch is: *** ./blib/lib/ModPerl/Util.pm 2005-05-22 10:14:19.000000000 -0700 --- /usr/lib/perl5/site_perl/5.8.5/i686-linux/ModPerl/Util.pm 2005-05-29 10:47:37.000000000 -0700 *************** *** 37,56 **** --- 37,61 ---- my $package = shift; no strict 'refs'; my $tab = \%{ $package . '::' }; # below we assign to a symbol first before undef'ing it, to avoid # nuking aliases. If we undef directly we may undef not only the # alias but the original function as well for (keys %$tab) { my $fullname = join '::', $package, $_; + if (my ($subpackage) = $fullname =~ /(.*)::/) { + $subpackage =~ s[::][/]g; + $subpackage .= ".pm"; + next if exists $INC{$subpackage}; + } # code/hash/array/scalar might be imported make sure the gv # does not point elsewhere before undefing each if (%$fullname) { *{$fullname} = {}; undef %$fullname; } if (@$fullname) { *{$fullname} = []; undef @$fullname; }