diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-21 22:20:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-21 22:20:31 +0100 |
commit | d80ff84c28c0be626c1df4528741cddf5a55f547 (patch) | |
tree | dfa1a3771f52970bfaf7b9e56d8675aeabfc65ef /common/storage_lmdb.cpp | |
parent | d21aa4e35fb96fa3b07888f710cbc3440af8bdd3 (diff) | |
download | sink-d80ff84c28c0be626c1df4528741cddf5a55f547.tar.gz sink-d80ff84c28c0be626c1df4528741cddf5a55f547.zip |
Write-Read loop from clientside.
It's a huge hack but starts to show results.
Most urgently we need:
* reliable command results
* the 3 buffers instead of the 1
* A way to implement storage as preprocessor (or a place to impelement it after the preprocessors).
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r-- | common/storage_lmdb.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index a8ec378..eeb0045 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -59,6 +59,7 @@ QMutex Storage::Private::sMutex; | |||
59 | Storage::Private::Private(const QString &s, const QString &n, AccessMode m) | 59 | Storage::Private::Private(const QString &s, const QString &n, AccessMode m) |
60 | : storageRoot(s), | 60 | : storageRoot(s), |
61 | name(n), | 61 | name(n), |
62 | env(0), | ||
62 | transaction(0), | 63 | transaction(0), |
63 | mode(m), | 64 | mode(m), |
64 | readTransaction(false), | 65 | readTransaction(false), |
@@ -66,7 +67,7 @@ Storage::Private::Private(const QString &s, const QString &n, AccessMode m) | |||
66 | { | 67 | { |
67 | const QString fullPath(storageRoot + '/' + name); | 68 | const QString fullPath(storageRoot + '/' + name); |
68 | QDir dir; | 69 | QDir dir; |
69 | dir.mkdir(storageRoot); | 70 | dir.mkpath(storageRoot); |
70 | dir.mkdir(fullPath); | 71 | dir.mkdir(fullPath); |
71 | 72 | ||
72 | //This seems to resolve threading related issues, not sure why though | 73 | //This seems to resolve threading related issues, not sure why though |
@@ -97,8 +98,10 @@ Storage::Private::~Private() | |||
97 | } | 98 | } |
98 | 99 | ||
99 | // it is still there and still unused, so we can shut it down | 100 | // it is still there and still unused, so we can shut it down |
100 | mdb_dbi_close(env, dbi); | 101 | if (env) { |
101 | mdb_env_close(env); | 102 | mdb_dbi_close(env, dbi); |
103 | mdb_env_close(env); | ||
104 | } | ||
102 | } | 105 | } |
103 | 106 | ||
104 | Storage::Storage(const QString &storageRoot, const QString &name, AccessMode mode) | 107 | Storage::Storage(const QString &storageRoot, const QString &name, AccessMode mode) |
@@ -111,6 +114,10 @@ Storage::~Storage() | |||
111 | delete d; | 114 | delete d; |
112 | } | 115 | } |
113 | 116 | ||
117 | bool Storage::exists() const | ||
118 | { | ||
119 | return (d->env != 0); | ||
120 | } | ||
114 | bool Storage::isInTransaction() const | 121 | bool Storage::isInTransaction() const |
115 | { | 122 | { |
116 | return d->transaction; | 123 | return d->transaction; |
@@ -313,12 +320,9 @@ void Storage::scan(const char *keyData, uint keySize, | |||
313 | errorHandler(error); | 320 | errorHandler(error); |
314 | } | 321 | } |
315 | 322 | ||
316 | /** | ||
317 | we don't abort the transaction since we need it for reading the values | ||
318 | if (implicitTransaction) { | 323 | if (implicitTransaction) { |
319 | abortTransaction(); | 324 | abortTransaction(); |
320 | } | 325 | } |
321 | */ | ||
322 | } | 326 | } |
323 | 327 | ||
324 | qint64 Storage::diskUsage() const | 328 | qint64 Storage::diskUsage() const |