Stop using Try::Tiny until the perl refcounting problem is identified
Peter Rabbitson [Fri, 11 Jun 2010 00:47:40 +0000 (02:47 +0200)]
Changes
lib/DBIx/Class/Storage/DBI.pm

diff --git a/Changes b/Changes
index 2348345..b7690d2 100644 (file)
--- 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
index fb2a7a2..5156731 100644 (file)
@@ -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;
 }