mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 14:36:39 +00:00
Merge branch 'navmeshdb_sqlite_open_nomutex' into 'master'
Use SQLITE_OPEN_NOMUTEX for navmeshdb See merge request OpenMW/openmw!1673
This commit is contained in:
commit
6f5c6171dd
2 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,6 @@
|
||||||
#include <components/sqlite3/db.hpp>
|
#include <components/sqlite3/db.hpp>
|
||||||
#include <components/sqlite3/request.hpp>
|
#include <components/sqlite3/request.hpp>
|
||||||
#include <components/sqlite3/statement.hpp>
|
#include <components/sqlite3/statement.hpp>
|
||||||
#include <components/sqlite3/transaction.hpp>
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
|
@ -16,7 +16,10 @@ namespace Sqlite3
|
||||||
Db makeDb(std::string_view path, const char* schema)
|
Db makeDb(std::string_view path, const char* schema)
|
||||||
{
|
{
|
||||||
sqlite3* handle = nullptr;
|
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)
|
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));
|
const std::string message(sqlite3_errmsg(handle));
|
||||||
|
|
Loading…
Reference in a new issue