From cb0f5fb769380db5771ff8e0dba8d780cdc92edb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 14 Dec 2014 23:39:48 +0100 Subject: Make lmdb work with threads. --- common/storage_lmdb.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index b9a007d..ce77bbb 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -26,8 +27,11 @@ public: AccessMode mode; bool readTransaction; bool firstOpen; + static QMutex sMutex; }; +QMutex Storage::Private::sMutex; + Storage::Private::Private(const QString &s, const QString &n, AccessMode m) : storageRoot(s), name(n), @@ -41,6 +45,9 @@ Storage::Private::Private(const QString &s, const QString &n, AccessMode m) dir.mkdir(storageRoot); dir.mkdir(fullPath); + //This seems to resolve threading related issues, not sure why though + QMutexLocker locker(&sMutex); + //create file if (mdb_env_create(&env)) { // TODO: handle error -- cgit v1.2.3