Retry access in case the settings database is locked
This commit is contained in:
parent
67e71691eb
commit
3981bbd37e
@ -56,10 +56,11 @@ class settings {
|
|||||||
|
|
||||||
proc {settings _safer_query} { queryText args } {
|
proc {settings _safer_query} { queryText args } {
|
||||||
global settingsdb
|
global settingsdb
|
||||||
|
|
||||||
# allow 5 (too many?) tries with 1s (too long?) delay to get access
|
# allow 5 (too many?) tries with 1s (too long?) delay to get access
|
||||||
for {set lockCnt 5} {} {sleep 1} {
|
for {set lockCnt 5} {true} {sleep 1} {
|
||||||
try {
|
try {
|
||||||
$settingsdb query $queryText {*}$args
|
return [$settingsdb query $queryText {*}$arg]
|
||||||
} on error {msg opts} {
|
} on error {msg opts} {
|
||||||
if {[string first "database is locked" $msg] >= 0 && [incr lockCnt -1] > 0} {
|
if {[string first "database is locked" $msg] >= 0 && [incr lockCnt -1] > 0} {
|
||||||
continue
|
continue
|
||||||
@ -122,7 +123,7 @@ settings method _nval_setting {name {val -1}} {
|
|||||||
|
|
||||||
if {$val == -1} {
|
if {$val == -1} {
|
||||||
# Get
|
# Get
|
||||||
set res [settings::_safer_query "
|
set res [settings _safer_query "
|
||||||
select nval from settings
|
select nval from settings
|
||||||
where name = '$name'
|
where name = '$name'
|
||||||
"]
|
"]
|
||||||
@ -132,7 +133,7 @@ settings method _nval_setting {name {val -1}} {
|
|||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
# Set
|
# Set
|
||||||
settings::_safer_query "
|
settings _safer_query "
|
||||||
replace into settings(name,nval)
|
replace into settings(name,nval)
|
||||||
values('$name', $val)
|
values('$name', $val)
|
||||||
"
|
"
|
||||||
@ -144,7 +145,7 @@ settings method _tval_setting {name {val -1} {def 0}} {
|
|||||||
|
|
||||||
if {$val eq "-1"} {
|
if {$val eq "-1"} {
|
||||||
# Get
|
# Get
|
||||||
set res [settings::_safer_query "
|
set res [settings _safer_query "
|
||||||
select tval from settings
|
select tval from settings
|
||||||
where name = '$name'
|
where name = '$name'
|
||||||
"]
|
"]
|
||||||
@ -154,7 +155,7 @@ settings method _tval_setting {name {val -1} {def 0}} {
|
|||||||
return $def
|
return $def
|
||||||
} else {
|
} else {
|
||||||
# Set
|
# Set
|
||||||
settings::_safer_query "
|
settings _safer_query "
|
||||||
replace into settings(name,tval)
|
replace into settings(name,tval)
|
||||||
values('$name', '%s')
|
values('$name', '%s')
|
||||||
" $val
|
" $val
|
||||||
|
Loading…
Reference in New Issue
Block a user