[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 22/33] tcl daemons: Break out db-ensure-open and db-ensure-closed
To be able to deliberately reconnect to the database, in case of error, we need functions which actually work with dbh, rather than simply the refcount. No functional change as yet. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- tcl/JobDB-Executive.tcl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl index 3ad3693..da9b7e9 100644 --- a/tcl/JobDB-Executive.tcl +++ b/tcl/JobDB-Executive.tcl @@ -85,6 +85,17 @@ proc db-open {} { if {$dbusers > 0} { incr dbusers; return } + db-ensure-open + incr dbusers +} +proc db-close {} { + variable dbusers + incr dbusers -1 + if {$dbusers > 0} return + if {$dbusers} { error "$dbusers ?!" } + db-ensure-closed +} +proc db-ensure-open {} { set pl { use Osstest; use Osstest::Executive; @@ -98,13 +109,8 @@ proc db-open {} { # is whitespace-separated. regsub -all {;} $db_pg_dsn { } conninfo pg_connect -conninfo $conninfo -connhandle dbh - incr dbusers } -proc db-close {} { - variable dbusers - incr dbusers -1 - if {$dbusers > 0} return - if {$dbusers} { error "$dbusers ?!" } +proc db-ensure-closed {} { pg_disconnect dbh } -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |