diff mbox

[OSSTEST,27/33] tcl daemons: transaction: Properly match db-open and db-close

Message ID 1468002385-4407-28-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson July 8, 2016, 6:26 p.m. UTC
* Do the db-open inside the catch, so that if it fails we do the
  rest of the error handling.

* Do the db-close before deconstructing the error, so that we
  necessarily get the db-open reference count right.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 tcl/JobDB-Executive.tcl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 3c2b4db..fe1c946 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -306,10 +306,10 @@  proc step-set-status {flight job stepno st} {
 proc transaction {tables script} {
     global errorInfo errorCode
     set retries 100
-    db-open
     while 1 {
         set ol {}
 	set rc [catch {
+	    db-open
 	    db-execute BEGIN
 	    db-execute "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"
 	    lock-tables $tables
@@ -318,6 +318,7 @@  proc transaction {tables script} {
 	} result]
 	set ei $errorInfo
 	set ec $errorCode
+	db-close
 	if {$rc} {
 	    db-execute ROLLBACK
 	    switch -glob $errorCode {
@@ -333,7 +334,6 @@  proc transaction {tables script} {
 		}
 	    }
 	}
-        db-close
 	return -code $rc -errorinfo $ei -errorcode $ec $result
     }
 }