From: Peter Rabbitson Date: Sun, 20 Jan 2013 18:09:46 +0000 (+0100) Subject: Revert workarounds for $@ broken during 5.13.x - mainly 1f870d5a X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5815ffb0e34dcd74af49581f65e1d5aa71779a6b;p=dbsrgits%2FDBIx-Class-Historic.git Revert workarounds for $@ broken during 5.13.x - mainly 1f870d5a Luckily reason prevailed and $@ was left alone during DESTROY time, the complexity (mnost of it compiled away) is no longer needed More historic info can be found here: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class-Historic.git;a=blob_plain;f=useful_guard_objects.html;h=4678884 --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index dc4123a..3518d42 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -40,10 +40,6 @@ BEGIN { # otherwise we are good : 0 , - - # There was a brief period of p5p insanity when $@ was invisible in a DESTROY - INVISIBLE_DOLLAR_AT => ($] >= 5.013001 and $] <= 5.013007) ? 1 : 0, - }; if ($] < 5.009_005) { diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index d8ab75c..18e2260 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -5,12 +5,9 @@ use warnings; use Try::Tiny; use Scalar::Util qw/weaken blessed refaddr/; use DBIx::Class; -use DBIx::Class::Exception; use DBIx::Class::Carp; use namespace::clean; -my ($guards_count, $compat_handler, $foreign_handler); - sub new { my ($class, $storage) = @_; @@ -34,41 +31,6 @@ sub new { bless $guard, ref $class || $class; - # install a callback carefully - if (DBIx::Class::_ENV_::INVISIBLE_DOLLAR_AT and !$guards_count) { - - # if the thrown exception is a plain string, wrap it in our - # own exception class - # this is actually a pretty cool idea, may very well keep it - # after perl is fixed - $compat_handler ||= bless( - sub { - $@ = (blessed($_[0]) or ref($_[0])) - ? $_[0] - : bless ( { msg => $_[0] }, 'DBIx::Class::Exception') - ; - die; - }, - '__TxnScopeGuard__FIXUP__', - ); - - if ($foreign_handler = $SIG{__DIE__}) { - $SIG{__DIE__} = bless ( - sub { - # we trust the foreign handler to do whatever it wants, all we do is set $@ - eval { $compat_handler->(@_) }; - $foreign_handler->(@_); - }, - '__TxnScopeGuard__FIXUP__', - ); - } - else { - $SIG{__DIE__} = $compat_handler; - } - } - - $guards_count++; - $guard; } @@ -85,29 +47,6 @@ sub commit { sub DESTROY { my $self = shift; - $guards_count--; - - # don't touch unless it's ours, and there are no more of us left - if ( - DBIx::Class::_ENV_::INVISIBLE_DOLLAR_AT - and - !$guards_count - ) { - - if (ref $SIG{__DIE__} eq '__TxnScopeGuard__FIXUP__') { - # restore what we saved - if ($foreign_handler) { - $SIG{__DIE__} = $foreign_handler; - } - else { - delete $SIG{__DIE__}; - } - } - - # make sure we do not leak the foreign one in case it exists - undef $foreign_handler; - } - return if $self->{inactivated}; # if our dbh is not ours anymore, the $dbh weakref will go undef @@ -164,7 +103,7 @@ sub DESTROY { } } - $@ = $exception unless DBIx::Class::_ENV_::INVISIBLE_DOLLAR_AT; + $@ = $exception; } 1; diff --git a/t/52leaks.t b/t/52leaks.t index 800ec22..8f36669 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -369,9 +369,6 @@ for my $slot (keys %$weak_registry) { delete $weak_registry->{$slot} unless $cleared->{hash_merge_singleton}{$weak_registry->{$slot}{weakref}{behavior}}++; } - elsif (DBIx::Class::_ENV_::INVISIBLE_DOLLAR_AT and $slot =~ /^__TxnScopeGuard__FIXUP__/) { - delete $weak_registry->{$slot} - } elsif ($slot =~ /^DateTime::TimeZone/) { # DT is going through a refactor it seems - let it leak zones for now delete $weak_registry->{$slot}; diff --git a/xt/podcoverage.t b/xt/podcoverage.t index ad93c42..c631576 100644 --- a/xt/podcoverage.t +++ b/xt/podcoverage.t @@ -47,11 +47,6 @@ my $exceptions = { MULTICREATE_DEBUG /], }, - 'DBIx::Class::Storage::TxnScopeGuard' => { - ignore => [qw/ - IS_BROKEN_PERL - /], - }, 'DBIx::Class::FilterColumn' => { ignore => [qw/ new