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]} {
|
if {[catch {set db [sqlite3.open /var/lib/humaxtv/setup.db]} msg]} {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
catch {$db query {pragma busy_timeout(50)}}
|
||||||
set val 0
|
set val 0
|
||||||
set ret [$db query "
|
loop _ 2 {
|
||||||
select item$type
|
try {
|
||||||
from TBL_$tbl
|
set ret [$db query "
|
||||||
where itemName = '$param'
|
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} {
|
if {[llength $ret] == 1} {
|
||||||
lassign [lindex $ret 0] x val
|
lassign [lindex $ret 0] x val
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user