diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-08 14:51:52 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-10 15:40:20 -0800 |
commit | 96e0e5252e27e231021df9058cf1e5bc29181345 (patch) | |
tree | a0c6974442a869f5edd0a3296b8e31510e348b23 /platform/default/mbgl/storage/offline_database.cpp | |
parent | 4bde1b0c88068914bbd1f14c85dbb51818de6ac9 (diff) | |
download | qtlocation-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.cpp | 5 |
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)); } |