[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 32/33] tcl daemons: Provide with-db



This makes it easier to get the matching of db-open and db-close right.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 tcl/JobDB-Executive.tcl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 0fc0a6d..07a0438 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -303,6 +303,22 @@ proc step-set-status {flight job stepno st} {
     }
 }
 
+proc with-db {script} {
+    global errorInfo errorCode
+    set rc [catch {
+       db-open
+       uplevel 1 $script
+    } result]
+    set ei $errorInfo
+    set ec $errorCode
+    if {$rc} {
+       catch { db-close }
+    } else {
+       db-close
+    }
+    return -code $rc -errorinfo $ei -errorcode $ec $result
+}
+    
 proc transaction {tables script {autoreconnect 0}} {
     global errorInfo errorCode
     set retries 100
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.