Skip to content

Commit

Permalink
Weaken $self to avoid leaks with nested closures on 5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmari committed Oct 21, 2014
1 parent 1d29e7e commit cf52a9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/DBIx/Class/Storage/DBI/Informix.pm
Expand Up @@ -6,6 +6,7 @@ use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';

use Scope::Guard ();
use Scalar::Util 'weaken';
use Context::Preserve 'preserve_context';
use namespace::clean;

Expand Down Expand Up @@ -66,6 +67,7 @@ sub with_deferred_fk_checks {

$self->_do_query('SET CONSTRAINTS ALL DEFERRED');

weaken($self);
return preserve_context {
my $sg = Scope::Guard->new(sub {
$self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
Expand Down
2 changes: 2 additions & 0 deletions lib/DBIx/Class/Storage/DBI/Pg.pm
Expand Up @@ -6,6 +6,7 @@ use warnings;
use base qw/DBIx::Class::Storage::DBI/;

use Scope::Guard ();
use Scalar::Util 'weaken';
use Context::Preserve 'preserve_context';
use DBIx::Class::Carp;
use Try::Tiny;
Expand All @@ -30,6 +31,7 @@ sub with_deferred_fk_checks {

$self->_do_query('SET CONSTRAINTS ALL DEFERRED');

weaken($self);
return preserve_context {
my $sg = Scope::Guard->new(sub {
$self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
Expand Down

0 comments on commit cf52a9a

Please sign in to comment.