perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [Fwd: Apache::Reload Module]
Date Thu, 12 Jun 2003 23:02:46 GMT
[CC'ing Matt and the dev list]

Hi Steve,

> I recently sent a patch for Apache::Reload to that module's original 
> author - Matt Sergeant - but he replied to say that he's now given 
> control of that module to you.  I'm therefore forwarding the patch to you.

No, that's incorrect. I'm not the owner of this module. All I have asked Matt 
is to let me perms to upload Apache/Reload.pm as part of mod_perl 2.0. I 
haven't taken over the maintenance of this module.

Currently there are two versions of this module. One on CPAN for mod_perl 1.0, 
the other inside the mod_perl 2.0 package. The mod_perl developers 
collectively maintain the version in 2.0, but not the CPAN version.  Perhaps 
what should be done is backport the module in 2.0 to mod_perl 1.0.

Also Philippe may consider to put Apache/Reload.pm into the 1.0 distro as well.

Now Steve, to your original question. You want these changes for mod_perl 1.0, 
correct?

If you try the version in the 2.0 package it already includes all the changes 
that you ask for. However it won't work with 1.0 as is, since it deploys the 
2.0 API.

> Could you possibly have a look at it?
> 
> I'm after two things: an "UndefOnReload" option like Apache::StatINC has 
> (which I haven't quite got working to my satisfaction yet), and a 
> GPL/Artistic license statement (like I recently requested for your 
> Apache::Test module, in fact!)
> 
> Many thanks,
> 
> Steve
> 
> 
> -------- Original Message --------
> Subject: Apache::Reload Module
> Date: Mon, 19 May 2003 10:12:21 +0100
> From: Steve Hay <steve.hay@uk.radan.com>
> To: matt@sergeant.org
> 
> 
> 
> Hi Matt,
> 
> I'm looking into using your Apache::Reload module as an improvement over 
> the Apache::StatINC module, but found that one feature was missing from 
> it: the option to have functions undefined on reload to avoid all those 
> "Subroutine ... redefined ..." warnings.
> 
> The attached patch provides this option (but not quite to my 
> satisfaction).  Specify "PerlSetVar UndefOnReload On" in httpd.conf and 
> the handler performs the same undeffing action (using 
> Apache::Symbol::undef_functions) as Apache::StatINC does...
> 
> ... well, almost!  Apache::StatINC calls undef_functions(undef, 1) which 
> arranges for ONLY functions specified in the EXPORT arrays (including a 
> special @EXPORT_EXTRAS array) to be undefined.
> 
> This is not very nice for OO-code which doesn't list its methods in the 
> EXPORT arrays, so initially I looked at calling undef_functions(undef, 
> 0), which would undefine all functions in the class concerned.  However, 
> I found that this includes sub-classes too, so, for example, if I have 
> Foo:: functions and Foo::Bar:: functions and I edit Foo.pm then all the 
> Foo::Bar:: functions get undefined too, but not reloaded since I haven't 
> edited Foo/Bar.pm!
> 
> My latest attempt (in the patch) is undef_functions("^${class}::.+::", 
> 0), which will undefine all functions in $class, but skips those 
> matching the pattern in the first argument.  This avoids the Foo::Bar:: 
> problem described above.
> 
> However, there is still one gremlin left that I don't know how to get 
> around.  If Foo use()s the Exporter module then Foo::import is an alias 
> for Exporter::import, so when Foo::import is undefined we find that 
> Exporter::import is now also undefined (and, of course, doesn't get 
> reloaded since Exporter.pm has not been edited)!  This applies to any 
> symbols that Foo has imported.
> 
> Can you think of a way around that last problem?  Maybe Apache::Symbol 
> needs some work?
> 
> If not, then probably going back to undef_functions(undef, 1) is safer.
> 
> One last point: I want to put this module into a Perl distribution that 
> is being shipped with some (commercial, not open source) software, and I 
> would need it to have a LICENSE statement somewhere in it, which it 
> currently doesn't have.  Preferably the usual blurb about "the same 
> terms as Perl itself -- GPL or Artistic" since just the GPL (which, 
> sadly, some modules do specify) would not permit inclusion in such a 
> commercial distribution.
> 
> A new release with either or both of these things in it would be greatly 
> appreciated.
> 
> Best regards,
> 
> Steve
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --- Reload.pm.orig	2001-04-22 19:10:00.000000000 +0100
> +++ Reload.pm	2003-05-19 09:49:00.000000000 +0100
> @@ -100,6 +100,7 @@
>          }
>      }
>      
> +    my $Undef = ref($r) && (lc($r->dir_config("UndefOnReload") || '') eq
'on');
>      
>      while (my($key, $file) = each %Apache::Reload::INCS) {
>          local $^W;
> @@ -122,6 +123,13 @@
>          }
>          
>          if ($mtime > $Stat{$file}) {
> +            if ($Undef) {
> +                require Apache::Symbol;
> +                my $class = Apache::Symbol::file2class($key);
> +                # Skip symbols in subclasses of $class::
> +                my $re = "^${class}::.+::";
> +                $class->Apache::Symbol::undef_functions($re, 0);
> +            }
>              delete $INC{$key};
>   #           warn "Reloading $key\n";
>              if (my $symref = $UndefFields{$key}) {


-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message