From 59130366380b234707be1974cf44b7f7ec6b5618 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 27 Jan 2022 21:17:56 +0100 Subject: [PATCH] Use SQLITE_OPEN_NOMUTEX --- components/sqlite3/db.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/sqlite3/db.cpp b/components/sqlite3/db.cpp index 54a156057d..b1e3afb1ae 100644 --- a/components/sqlite3/db.cpp +++ b/components/sqlite3/db.cpp @@ -16,7 +16,10 @@ namespace Sqlite3 Db makeDb(std::string_view path, const char* schema) { sqlite3* handle = nullptr; - const int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + // All uses of NavMeshDb are protected by a mutex (navmeshtool) or serialized in a single thread (DbWorker) + // so additional synchronization between threads is not required and SQLITE_OPEN_NOMUTEX can be used. + // This is unsafe to use NavMeshDb without external synchronization because of internal state. + const int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX; if (const int ec = sqlite3_open_v2(std::string(path).c_str(), &handle, flags, nullptr); ec != SQLITE_OK) { const std::string message(sqlite3_errmsg(handle));