Skip Menu |

This queue is for tickets about the Attribute-Constant CPAN distribution.

Report information
The Basics
Id: 84092
Status: resolved
Priority: 0/
Queue: Attribute-Constant

People
Owner: Nobody in particular
Requestors: gfuji [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: dlock("0") locks $0
Try `perl -e 'use Data::Lock qw(dlock); dlock "0"; $0 = "hoge"'`, which will fail. "no strict 'refs'" seems the fault. "use strict 'refs'" again in the (un)lock routines. -- Goro Fuji (gfx) GFUJI at CPAN.org
Thanks. unfortunately that solution fails to lock ordinary non-reference data types. I also found d(un)?lock loops forever on circular reference. the patch below fix all that. New version on its way to CPAN. Dan On Wed Mar 20 10:28:49 2013, GFUJI wrote: Show quoted text
> Try `perl -e 'use Data::Lock qw(dlock); dlock "0"; $0 = "hoge"'`, > which will fail. > > "no strict 'refs'" seems the fault. "use strict 'refs'" again in the > (un)lock routines.
diff -u -r0.4 lib/Data/Lock.pm --- lib/Data/Lock.pm 2013/03/20 22:17:40 0.4 +++ lib/Data/Lock.pm 2013/03/20 22:29:19 @@ -19,6 +19,7 @@ *{$subname} = sub { no warnings "uninitialized"; return if Internals::SvREADONLY( $_[0]) == $locked; + Internals::SvREADONLY( $_[0], $locked ); my $type = Scalar::Util::reftype( $_[0] ); for ( $type eq 'ARRAY' ? @{ $_[0] } @@ -27,14 +28,13 @@ : () ) { - dlock($_) if ref $_; + &$subname($_) if ref $_; Internals::SvREADONLY( $_, $locked ); } $type eq 'ARRAY' ? Internals::SvREADONLY( @{ $_[0] }, $locked ) : $type eq 'HASH' ? Internals::SvREADONLY( %{ $_[0] }, $locked ) : $type ne 'CODE' ? Internals::SvREADONLY( ${ $_[0] }, $locked ) : undef; - Internals::SvREADONLY( $_[0], $locked ); }; }
Thanks for the quick work! Anyway, it's good that everything works well ;) -- Goro Fuji (gfx) GFUJI at CPAN.org
(sorry to re-open it) -- Goro Fuji (gfx) GFUJI at CPAN.org