[core] Disable SQLite busy timeouts so that multiple readers can access the same database

This commit is contained in:
John Firebaugh
2016-02-08 14:51:52 -08:00
parent 4bde1b0c88
commit 96e0e5252e
3 changed files with 16 additions and 0 deletions

View File

@@ -59,6 +59,15 @@ Database::operator bool() const {
return db != nullptr;
}
void Database::setBusyTimeout(std::chrono::milliseconds timeout) {
assert(db);
const int err = sqlite3_busy_timeout(db,
int(std::min<std::chrono::milliseconds::rep>(timeout.count(), std::numeric_limits<int>::max())));
if (err != SQLITE_OK) {
throw Exception { err, sqlite3_errmsg(db) };
}
}
void Database::exec(const std::string &sql) {
assert(db);
char *msg = nullptr;