Improve lock handling of /var/lib/humaxtv/setup.db
This commit is contained in:
parent
aab63aa8cc
commit
25bb62f622
@ -569,16 +569,41 @@ proc {system restartpending} {{mode 1}} {
|
||||
}
|
||||
}
|
||||
|
||||
proc {system param} {param {type Value} {tbl MENUCONFIG}} {
|
||||
proc {system param} {param {type Value} {tbl MENUCONFIG}} {{newdb ""}} {
|
||||
if {[catch {set db [sqlite3.open /var/lib/humaxtv/setup.db]} msg]} {
|
||||
return 0
|
||||
}
|
||||
catch {$db query {pragma busy_timeout(50)}}
|
||||
set val 0
|
||||
set ret [$db query "
|
||||
select item$type
|
||||
from TBL_$tbl
|
||||
where itemName = '$param'
|
||||
"]
|
||||
loop _ 2 {
|
||||
try {
|
||||
set ret [$db query "
|
||||
select item$type
|
||||
from TBL_$tbl
|
||||
where itemName = '$param'
|
||||
"]
|
||||
break
|
||||
} on error {msg opts} {
|
||||
if {[string first "database is locked" $msg] >= 0} {
|
||||
try {
|
||||
if {$newdb eq ""} {
|
||||
set newdb [file tempfile /tmp/setupXXXXXX]
|
||||
defer "catch {file delete $newdb}"
|
||||
}
|
||||
file copy -force /var/lib/humaxtv/setup.db $newdb
|
||||
set db [sqlite3.open $newdb]
|
||||
} on error {msg opts} {
|
||||
file delete $newdb
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
catch {$db close}
|
||||
return {*}$opts $msg
|
||||
}
|
||||
}
|
||||
|
||||
if {[llength $ret] == 1} {
|
||||
lassign [lindex $ret 0] x val
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user