[open-ils-commits] r18872 - branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Utils (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 30 09:05:10 EST 2010


Author: erickson
Date: 2010-11-30 09:05:09 -0500 (Tue, 30 Nov 2010)
New Revision: 18872

Modified:
   branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
Log:
back-porting cstoreditor fixes to help prevent transaction leaking

Modified: branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
===================================================================
--- branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm	2010-11-30 14:04:48 UTC (rev 18871)
+++ branches/rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm	2010-11-30 14:05:09 UTC (rev 18872)
@@ -76,6 +76,11 @@
 	return $self;
 }
 
+sub DESTROY {
+        my $self = shift;
+        $self->reset;
+        return undef;
+}
 
 sub app {
 	my( $self, $app ) = @_;
@@ -289,13 +294,24 @@
 # -----------------------------------------------------------------------------
 sub rollback {
 	my $self = shift;
-	$self->xact_rollback;
-	$self->disconnect;
+    my $err;
+    my $ret;
+	try {
+        $self->xact_rollback;
+    } catch Error with  {
+        $err = shift
+    } finally {
+        $ret = $self->disconnect
+    };
+    throw $err if ($err);
+    return $ret;
 }
 
 sub disconnect {
 	my $self = shift;
-	$self->session->disconnect if $self->{session};
+	$self->session->disconnect if 
+        $self->{session} and 
+        $self->{session}->state == OpenSRF::AppSession::CONNECTED();
     delete $self->{session};
 }
 
@@ -327,8 +343,17 @@
 # -----------------------------------------------------------------------------
 sub finish {
 	my $self = shift;
-	$self->commit;
-	$self->reset;
+    my $err;
+    my $ret;
+	try {
+        $self->commit;
+    } catch Error with  {
+        $err = shift
+    } finally {
+        $ret = $self->reset
+    };
+    throw $err if ($err);
+    return $ret;
 }
 
 



More information about the open-ils-commits mailing list