From: Peter Rabbitson Date: Fri, 11 Jun 2010 00:47:40 +0000 (+0200) Subject: Stop using Try::Tiny until the perl refcounting problem is identified X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ddfd085d3ec95031b148d573ccc2e6cd36032b9d;p=dbsrgits%2FDBIx-Class-Historic.git Stop using Try::Tiny until the perl refcounting problem is identified --- diff --git a/Changes b/Changes index 2348345..b7690d2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class + * Fixes + - Fix a Storage/$dbh leak introduced by th migration to + Try::Tiny (this is *not* a Try::Tiny bug) + * Misc - Test suite default on-disk database now checks for Win32 fail-conditions even when running on other OSes diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index fb2a7a2..5156731 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1166,7 +1166,9 @@ sub _connect { $DBI::connect_via = 'connect'; } - try { + # FIXME - this should have been Try::Tiny, but triggers a leak-bug in perl(!) + # related to coderef refcounting. A failing test has been submitted to T::T + my $connect_ok = eval { if(ref $info[0] eq 'CODE') { $dbh = $info[0]->(); } @@ -1195,14 +1197,17 @@ sub _connect { $dbh->{RaiseError} = 1; $dbh->{PrintError} = 0; } - } - catch { - $self->throw_exception("DBI Connection failed: $_") - } - finally { - $DBI::connect_via = $old_connect_via if $old_connect_via; + + 1; }; + my $possible_err = $@; + $DBI::connect_via = $old_connect_via if $old_connect_via; + + unless ($connect_ok) { + $self->throw_exception("DBI Connection failed: $possible_err") + } + $self->_dbh_autocommit($dbh->{AutoCommit}); $dbh; }