From: Peter Rabbitson Date: Thu, 4 Feb 2016 09:18:51 +0000 (+0100) Subject: Do our best to disconnect on request (goes with 45792de6) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=86cdddbe2781f77d81d27cdd83910543c313a8f0;p=dbsrgits%2FDBIx-Class-Historic.git Do our best to disconnect on request (goes with 45792de6) This ensures that a failed rollback won't leave is in a weird state --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1c2a922..d390dc6 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -885,6 +885,12 @@ sub disconnect { # in order to unambiguously reset the state - do the cleanup in guard my $g = scope_guard { + + { + local $@ if DBIx::Class::_ENV_::UNSTABLE_DOLLARAT; + eval { $self->_dbh->disconnect }; + } + $self->_dbh(undef); $self->_dbh_details({}); $self->transaction_depth(undef); @@ -895,7 +901,7 @@ sub disconnect { #$self->_sql_maker(undef); # this may also end up being different }; - if( my $dbh = $self->_dbh ) { + if( $self->_dbh ) { $self->_do_connection_actions(disconnect_call_ => $_) for ( ( $self->on_disconnect_call || () ), @@ -904,8 +910,6 @@ sub disconnect { # stops the "implicit rollback on disconnect" warning $self->_exec_txn_rollback unless $self->_dbh_autocommit; - - $dbh->disconnect; } }