summaryrefslogtreecommitdiff
path: root/platform/default/mbgl/storage/offline_database.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-08 14:51:52 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commit96e0e5252e27e231021df9058cf1e5bc29181345 (patch)
treea0c6974442a869f5edd0a3296b8e31510e348b23 /platform/default/mbgl/storage/offline_database.cpp
parent4bde1b0c88068914bbd1f14c85dbb51818de6ac9 (diff)
downloadqtlocation-mapboxgl-96e0e5252e27e231021df9058cf1e5bc29181345.tar.gz
[core] Disable SQLite busy timeouts so that multiple readers can access the same database
Diffstat (limited to 'platform/default/mbgl/storage/offline_database.cpp')
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index c6510157bc..fb0dae0b2b 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -37,6 +37,7 @@ void OfflineDatabase::ensureSchema() {
if (path != ":memory:") {
try {
db = std::make_unique<Database>(path.c_str(), ReadWrite);
+ db->setBusyTimeout(Milliseconds::max());
{
Statement userVersionStmt(db->prepare("PRAGMA user_version"));
@@ -51,12 +52,15 @@ void OfflineDatabase::ensureSchema() {
removeExisting();
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
+ db->setBusyTimeout(Milliseconds::max());
} catch (mapbox::sqlite::Exception& ex) {
if (ex.code == SQLITE_CANTOPEN) {
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
+ db->setBusyTimeout(Milliseconds::max());
} else if (ex.code == SQLITE_NOTADB) {
removeExisting();
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
+ db->setBusyTimeout(Milliseconds::max());
}
}
}
@@ -64,6 +68,7 @@ void OfflineDatabase::ensureSchema() {
#include "offline_schema.cpp.include"
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
+ db->setBusyTimeout(Milliseconds::max());
db->exec(schema);
db->exec("PRAGMA user_version = " + util::toString(schemaVersion));
}