You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@cpan.org> on 2003/05/26 10:36:13 UTC
Re: [patch] shutting down 'constant sub redefined' in
Apache::Reload
On Mon, 2003-05-26 at 15:46, Stas Bekman wrote:
> Currently if you have used a constant sub in your code, Apache::Reload will
> complain every time the code is reloaded. And for a good reason:
> http://groups.google.com/groups?threadm=20020519214851.3981.qmail%40airtrout.tregar.com
> http://archive.develooper.com/perl5-changes%40perl.org/msg04919.html
>
> However it's a bad thing not being able to shut those warning, if you know
> that you didn't modify the constant subs. The approach suggested by Rafael is
> to use $SIG{__WARN__} override, only for those who know what they are doing:
>
> PerlSetVar ReloadNoWarningsConstantRedefine on
>
> here is the patch. Not sure if that variable is not too long... may be
> shouldn't use reverse logic but:
>
> PerlSetVar ReloadWarningsConstantRedefine off
>
> with 'on' being the default.
Sure prefers non-reverse logic myself ;-)
> better name suggestions are welcome as well.
PerlSetVar ReloadAllowConstantRedefine on/off ???
> Index: lib/Apache/Reload.pm
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/lib/Apache/Reload.pm,v
> retrieving revision 1.10
> diff -u -r1.10 Reload.pm
> --- lib/Apache/Reload.pm 8 May 2003 00:31:27 -0000 1.10
> +++ lib/Apache/Reload.pm 26 May 2003 07:38:31 -0000
> @@ -63,6 +63,9 @@
>
> my $TouchFile = ref($o) && $o->dir_config("ReloadTouchFile");
>
> + my $NoWarningsConstantRedefine = ref($o) &&
> + (lc($o->dir_config("ReloadNoWarningsConstantRedefine") || '') eq 'on');;
> +
> my $TouchModules;
>
> if ($TouchFile) {
> @@ -141,6 +144,8 @@
> undef %{$symref};
> }
> no warnings FATAL => 'all';
> + local $SIG{__WARN__} = \&skip_redefine_const_sub_warn
> + if $NoWarningsConstantRedefine;
> require $key;
> warn("Apache::Reload: process $$ reloading $key\n")
> if $DEBUG;
> @@ -149,6 +154,11 @@
> }
>
> return Apache::OK;
> +}
> +
> +sub skip_redefine_const_sub_warn {
> + return if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/;
> + CORE::warn(@_);
> }
>
> 1;
>
I am not sure about this one, but I would say that this will cut the
grass from under the feet of a module that installed his/her own
SIG{__WARN__} handler, won't it ?
Wouldn't it be possible for Apache::Reload to somehow turn off the CONST
flag on that CV before attempting to re-define it? (didn't check if
that's even remotly possibly)
> __________________________________________________________________
> 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
--
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'
Re: [patch] shutting down 'constant sub redefined'
in Apache::Reload
Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Mon, 2003-05-26 at 17:16, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > On Mon, 2003-05-26 at 15:46, Stas Bekman wrote:
> >
> >>Currently if you have used a constant sub in your code, Apache::Reload will
> >>complain every time the code is reloaded. And for a good reason:
> >>http://groups.google.com/groups?threadm=20020519214851.3981.qmail%40airtrout.tregar.com
> >>http://archive.develooper.com/perl5-changes%40perl.org/msg04919.html
> >>
> >>However it's a bad thing not being able to shut those warning, if you know
> >>that you didn't modify the constant subs. The approach suggested by Rafael is
> >>to use $SIG{__WARN__} override, only for those who know what they are doing:
[...]
> >
> >
> > I am not sure about this one, but I would say that this will cut the
> > grass from under the feet of a module that installed his/her own
> > SIG{__WARN__} handler, won't it ?
>
> it sure would. Messing with SIG{__(WARN|DIE)__} is always a bad idea if it's
> not under your control.
>
> > Wouldn't it be possible for Apache::Reload to somehow turn off the CONST
> > flag on that CV before attempting to re-define it? (didn't check if
> > that's even remotly possibly)
>
> Perl doesn't provide any API to shut this down. See the recent question about
> this on p5p (from me).
Just caught up on the p5p postings. In light of that, I would think that
using SIG{__WARN__} is indeed that best course of action. I'd just make
sure to mark it with red tape, so that when an Apache::Reload gets
strange behaviour in previously working $SIG{WARN} catching, we'll be
able to point at the documentation and say : "Told you so" ;-p
And this is most certainly something broken with Perl, as no warnings
FATAL => 'all' should shield you from that annoying redefinition
warning. Oh well...
> __________________________________________________________________
> 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
--
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'
Re: [patch] shutting down 'constant sub redefined' in Apache::Reload
Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
>>> no warnings FATAL => 'all';
>>> + local $SIG{__WARN__} = \&skip_redefine_const_sub_warn
>>> + if $NoWarningsConstantRedefine;
>>> require $key;
>>> warn("Apache::Reload: process $$ reloading $key\n")
>>> if $DEBUG;
>>> @@ -149,6 +154,11 @@
>>> }
>>>
>>> return Apache::OK;
>>> +}
>>> +
>>> +sub skip_redefine_const_sub_warn {
>>> + return if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/;
>>> + CORE::warn(@_);
>>> }
>>>
>>> 1;
>>>
>>
>>
>> I am not sure about this one, but I would say that this will cut the
>> grass from under the feet of a module that installed his/her own
>> SIG{__WARN__} handler, won't it ?
>
>
> it sure would. Messing with SIG{__(WARN|DIE)__} is always a bad idea if
> it's not under your control.
Actually it won't. if the module defines its own $SIG{__WARN__} it will
override Apache::Reload's one, but that's fine, since the module will be
reloaded by that time.
__________________________________________________________________
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
Re: [patch] shutting down 'constant sub redefined' in Apache::Reload
Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
>
>> On Mon, 2003-05-26 at 15:46, Stas Bekman wrote:
>>
>>> Currently if you have used a constant sub in your code,
>>> Apache::Reload will complain every time the code is reloaded. And for
>>> a good reason:
>>> http://groups.google.com/groups?threadm=20020519214851.3981.qmail%40airtrout.tregar.com
>>>
>>> http://archive.develooper.com/perl5-changes%40perl.org/msg04919.html
>>>
>>> However it's a bad thing not being able to shut those warning, if you
>>> know that you didn't modify the constant subs. The approach suggested
>>> by Rafael is to use $SIG{__WARN__} override, only for those who know
>>> what they are doing:
>>>
>>> PerlSetVar ReloadNoWarningsConstantRedefine on
>>>
>>> here is the patch. Not sure if that variable is not too long... may
>>> be shouldn't use reverse logic but:
>>>
>>> PerlSetVar ReloadWarningsConstantRedefine off
>>>
>>> with 'on' being the default.
>>
>>
>>
>> Sure prefers non-reverse logic myself ;-)
>>
>>
>>> better name suggestions are welcome as well.
>>
>>
>>
>> PerlSetVar ReloadAllowConstantRedefine on/off ???
>
>
> yes, but you don't want to "allow" constants to be redefined, you can't
> control that, as they will be redefined. All you want is to be able to
> shut the warning. Dunno what happens if Apache::Reload tries to undef
> those first.
Eventually I went with non-reversed logic as you have suggested.
PerlSetVar ReloadConstantRedefineWarnings Off
__________________________________________________________________
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
Re: [patch] shutting down 'constant sub redefined' in Apache::Reload
Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> On Mon, 2003-05-26 at 15:46, Stas Bekman wrote:
>
>>Currently if you have used a constant sub in your code, Apache::Reload will
>>complain every time the code is reloaded. And for a good reason:
>>http://groups.google.com/groups?threadm=20020519214851.3981.qmail%40airtrout.tregar.com
>>http://archive.develooper.com/perl5-changes%40perl.org/msg04919.html
>>
>>However it's a bad thing not being able to shut those warning, if you know
>>that you didn't modify the constant subs. The approach suggested by Rafael is
>>to use $SIG{__WARN__} override, only for those who know what they are doing:
>>
>> PerlSetVar ReloadNoWarningsConstantRedefine on
>>
>>here is the patch. Not sure if that variable is not too long... may be
>>shouldn't use reverse logic but:
>>
>> PerlSetVar ReloadWarningsConstantRedefine off
>>
>>with 'on' being the default.
>
>
> Sure prefers non-reverse logic myself ;-)
>
>
>>better name suggestions are welcome as well.
>
>
> PerlSetVar ReloadAllowConstantRedefine on/off ???
yes, but you don't want to "allow" constants to be redefined, you can't
control that, as they will be redefined. All you want is to be able to shut
the warning. Dunno what happens if Apache::Reload tries to undef those first.
>> no warnings FATAL => 'all';
>>+ local $SIG{__WARN__} = \&skip_redefine_const_sub_warn
>>+ if $NoWarningsConstantRedefine;
>> require $key;
>> warn("Apache::Reload: process $$ reloading $key\n")
>> if $DEBUG;
>>@@ -149,6 +154,11 @@
>> }
>>
>> return Apache::OK;
>>+}
>>+
>>+sub skip_redefine_const_sub_warn {
>>+ return if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/;
>>+ CORE::warn(@_);
>> }
>>
>> 1;
>>
>
>
> I am not sure about this one, but I would say that this will cut the
> grass from under the feet of a module that installed his/her own
> SIG{__WARN__} handler, won't it ?
it sure would. Messing with SIG{__(WARN|DIE)__} is always a bad idea if it's
not under your control.
> Wouldn't it be possible for Apache::Reload to somehow turn off the CONST
> flag on that CV before attempting to re-define it? (didn't check if
> that's even remotly possibly)
Perl doesn't provide any API to shut this down. See the recent question about
this on p5p (from me).
__________________________________________________________________
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