diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-02-21 15:38:01 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-02-21 15:38:01 +0000 |
commit | 0f56c7c50ab021665a1592eeec59ab7ecfc9a584 (patch) | |
tree | a6435a1ae53262e0e29145dbd635456267525444 /plugins/Dbx_mdb | |
parent | c435188487f1e89942b6ada46808b9103f3f25cd (diff) |
dbx_lmdb: some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@16319 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb')
-rw-r--r-- | plugins/Dbx_mdb/src/dbcontacts.cpp | 10 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/dbevents.cpp | 4 | ||||
-rw-r--r-- | plugins/Dbx_mdb/src/stdafx.h | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index c0c07f0240..d52a581d28 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -109,8 +109,8 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID) key.mv_size = sizeof(keyVal); key.mv_data = &keyVal;
MDB_val data;
- txn_ptr trnlck(m_pMdbEnv, true);
- cursor_ptr cursor(trnlck, m_dbEventsSort);
+ txn_ptr txn(m_pMdbEnv);
+ cursor_ptr cursor(txn, m_dbEventsSort);
mdb_cursor_get(cursor, &key, &data, MDB_SET);
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS)
{
@@ -120,6 +120,7 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID) mdb_cursor_del(cursor, 0);
}
+ txn.commit();
return 0;
}
@@ -242,7 +243,7 @@ BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) delete EI;
}
- MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
+ MDB_val keyc = { sizeof(MCONTACT), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
for (;; Remap())
{
@@ -294,7 +295,8 @@ void CDbxMdb::FillContacts() cursor_ptr_ro cursor(m_curContacts);
MDB_val key, data;
- while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0)
+ {
DBContact *dbc = (DBContact*)data.mv_data;
if (dbc->dwSignature != DBCONTACT_SIGNATURE)
DatabaseCorruption(NULL);
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index 580b4d0d62..50b5f2a8b8 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -82,7 +82,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) mir_cslockfull lck(m_csDbAccess);
DWORD dwEventId = ++m_dwMaxEventId;
- for (bool bContactIncremented = false; ;[=](){ if (bContactIncremented) cc->Revert(); }(), Remap()) {
+ for (cc->Snapshot();; cc->Revert(), Remap()) {
txn_ptr txn(m_pMdbEnv);
MDB_val key = { sizeof(int), &dwEventId }, data = { sizeof(DBEvent) + dbe.cbBlob, NULL };
@@ -98,9 +98,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) data.mv_size = 1; data.mv_data = "";
MDB_CHECK(mdb_put(txn, m_dbEventsSort, &key, &data, 0), 0);
- cc->Snapshot();
cc->Advance(dwEventId, dbe);
- bContactIncremented = true;
MDB_val keyc = { sizeof(int), &contactID }, datac = { sizeof(DBContact), &cc->dbc };
MDB_CHECK(mdb_put(txn, m_dbContacts, &keyc, &datac, 0), 0);
diff --git a/plugins/Dbx_mdb/src/stdafx.h b/plugins/Dbx_mdb/src/stdafx.h index 793c25b6f0..8f8c3b4829 100644 --- a/plugins/Dbx_mdb/src/stdafx.h +++ b/plugins/Dbx_mdb/src/stdafx.h @@ -50,9 +50,9 @@ class txn_ptr MDB_txn *m_txn;
public:
- __forceinline txn_ptr(MDB_env *pEnv, bool bReadOnly = false)
+ __forceinline txn_ptr(MDB_env *pEnv)
{
- mdb_txn_begin(pEnv, NULL, (bReadOnly) ? MDB_RDONLY : 0, &m_txn);
+ mdb_txn_begin(pEnv, NULL, 0, &m_txn);
}
__forceinline ~txn_ptr()
|