mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
Move warning timing logic into handleSQLiteBusy.
This commit is contained in:
parent
da322ebda6
commit
de3df3009b
2 changed files with 6 additions and 13 deletions
|
@ -239,9 +239,11 @@ SQLiteTxn::~SQLiteTxn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSQLiteBusy(const SQLiteBusy & e, bool shouldWarn)
|
void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning)
|
||||||
{
|
{
|
||||||
if (shouldWarn) {
|
time_t now = time(0);
|
||||||
|
if (now > nextWarning) {
|
||||||
|
nextWarning = now + 10;
|
||||||
logWarning({
|
logWarning({
|
||||||
.msg = hintfmt(e.what())
|
.msg = hintfmt(e.what())
|
||||||
});
|
});
|
||||||
|
|
|
@ -139,7 +139,7 @@ protected:
|
||||||
|
|
||||||
MakeError(SQLiteBusy, SQLiteError);
|
MakeError(SQLiteBusy, SQLiteError);
|
||||||
|
|
||||||
void handleSQLiteBusy(const SQLiteBusy & e, bool shouldWarn);
|
void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function for retrying a SQLite transaction when the
|
* Convenience function for retrying a SQLite transaction when the
|
||||||
|
@ -153,17 +153,8 @@ T retrySQLite(F && fun)
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
return fun();
|
return fun();
|
||||||
|
|
||||||
} catch (SQLiteBusy & e) {
|
} catch (SQLiteBusy & e) {
|
||||||
time_t now = time(0);
|
handleSQLiteBusy(e, nextWarning);
|
||||||
bool shouldWarn = false;
|
|
||||||
|
|
||||||
if (now > nextWarning) {
|
|
||||||
nextWarning = now + 10;
|
|
||||||
shouldWarn = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSQLiteBusy(e, shouldWarn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue