diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-14 23:39:48 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-15 09:23:58 +0100 |
commit | cb0f5fb769380db5771ff8e0dba8d780cdc92edb (patch) | |
tree | 24ef4d7883035628c0f5701b6e61bcef865fcbf2 /common | |
parent | 9cf2db435768b4917e9d322df2366fbdf478cc58 (diff) | |
download | sink-cb0f5fb769380db5771ff8e0dba8d780cdc92edb.tar.gz sink-cb0f5fb769380db5771ff8e0dba8d780cdc92edb.zip |
Make lmdb work with threads.
Diffstat (limited to 'common')
-rw-r--r-- | common/storage_lmdb.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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 @@ | |||
8 | #include <QReadWriteLock> | 8 | #include <QReadWriteLock> |
9 | #include <QString> | 9 | #include <QString> |
10 | #include <QTime> | 10 | #include <QTime> |
11 | #include <QMutex> | ||
11 | 12 | ||
12 | #include <lmdb.h> | 13 | #include <lmdb.h> |
13 | 14 | ||
@@ -26,8 +27,11 @@ public: | |||
26 | AccessMode mode; | 27 | AccessMode mode; |
27 | bool readTransaction; | 28 | bool readTransaction; |
28 | bool firstOpen; | 29 | bool firstOpen; |
30 | static QMutex sMutex; | ||
29 | }; | 31 | }; |
30 | 32 | ||
33 | QMutex Storage::Private::sMutex; | ||
34 | |||
31 | Storage::Private::Private(const QString &s, const QString &n, AccessMode m) | 35 | Storage::Private::Private(const QString &s, const QString &n, AccessMode m) |
32 | : storageRoot(s), | 36 | : storageRoot(s), |
33 | name(n), | 37 | name(n), |
@@ -41,6 +45,9 @@ Storage::Private::Private(const QString &s, const QString &n, AccessMode m) | |||
41 | dir.mkdir(storageRoot); | 45 | dir.mkdir(storageRoot); |
42 | dir.mkdir(fullPath); | 46 | dir.mkdir(fullPath); |
43 | 47 | ||
48 | //This seems to resolve threading related issues, not sure why though | ||
49 | QMutexLocker locker(&sMutex); | ||
50 | |||
44 | //create file | 51 | //create file |
45 | if (mdb_env_create(&env)) { | 52 | if (mdb_env_create(&env)) { |
46 | // TODO: handle error | 53 | // TODO: handle error |