From f1ed7196eb270b02eefa3fdb7cebb8df9bb04bd9 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 19 Feb 2016 18:22:47 +0000 Subject: dbx_lmdb: last commit temporary reverted git-svn-id: http://svn.miranda-ng.org/main/trunk@16312 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbcontacts.cpp | 2 +- plugins/Dbx_mdb/src/dbevents.cpp | 11 +++++------ plugins/Dbx_mdb/src/stdafx.h | 22 ++-------------------- 3 files changed, 8 insertions(+), 27 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp index deccf4f4fd..c9e549da8e 100644 --- a/plugins/Dbx_mdb/src/dbcontacts.cpp +++ b/plugins/Dbx_mdb/src/dbcontacts.cpp @@ -108,7 +108,7 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID) DBEventSortingKey keyVal = { 0, 0, contactID }; key = { sizeof(keyVal), &keyVal }; MDB_val data; - txn_ptr_ro trnlck(m_pMdbEnv); + txn_ptr trnlck(m_pMdbEnv, true); cursor_ptr cursor(trnlck, m_dbEventsSort); mdb_cursor_get(cursor, &key, &data, MDB_SET); while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index af81195ff7..39ec4d4afb 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" MDB_txn* txn_ptr_ro::m_txn; -MDB_cursor* cursor_ptr_ro::m_cursor; STDMETHODIMP_(LONG) CDbxMdb::GetEventCount(MCONTACT contactID) { @@ -247,7 +246,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSortingKey &key2) { - cursor_ptr_ro cursor(txn, m_dbEventsSort); + cursor_ptr cursor(txn, m_dbEventsSort); MDB_val key = { sizeof(key2), &key2 }, data; key2.dwEventId++; @@ -326,7 +325,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindFirstEvent(MCONTACT contactID) mir_cslock lck(m_csDbAccess); txn_ptr_ro txn(m_pMdbEnv); - cursor_ptr_ro cursor(txn, m_dbEventsSort); + cursor_ptr cursor(txn, m_dbEventsSort); mdb_cursor_get(cursor, &key, &data, MDB_SET); if (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) != MDB_SUCCESS) return m_evLast = 0; @@ -350,7 +349,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindLastEvent(MCONTACT contactID) mir_cslock lck(m_csDbAccess); txn_ptr_ro txn(m_pMdbEnv); - cursor_ptr_ro cursor(txn, m_dbEventsSort); + cursor_ptr cursor(txn, m_dbEventsSort); mdb_cursor_get(cursor, &key, &data, MDB_SET); if (mdb_cursor_get(cursor, &key, &data, MDB_PREV) != MDB_SUCCESS) return m_evLast = 0; @@ -381,7 +380,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent DBEventSortingKey keyVal = { hDbEvent, ts, contactID }; MDB_val key = { sizeof(keyVal), &keyVal }; - cursor_ptr_ro cursor(txn, m_dbEventsSort); + cursor_ptr cursor(txn, m_dbEventsSort); if (mdb_cursor_get(cursor, &key, &data, MDB_SET) != MDB_SUCCESS) return m_evLast = 0; @@ -414,7 +413,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent DBEventSortingKey keyVal = { hDbEvent, ts, contactID }; MDB_val key = { sizeof(keyVal), &keyVal }; - cursor_ptr_ro cursor(txn, m_dbEventsSort); + cursor_ptr cursor(txn, m_dbEventsSort); if (mdb_cursor_get(cursor, &key, &data, MDB_SET) != MDB_SUCCESS) return m_evLast = 0; diff --git a/plugins/Dbx_mdb/src/stdafx.h b/plugins/Dbx_mdb/src/stdafx.h index 3f193dda47..0a777f5e5b 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) + __forceinline txn_ptr(MDB_env *pEnv, bool bReadOnly = false) { - mdb_txn_begin(pEnv, NULL, 0, &m_txn); + mdb_txn_begin(pEnv, NULL, (bReadOnly) ? MDB_RDONLY : 0, &m_txn); } __forceinline ~txn_ptr() @@ -118,24 +118,6 @@ public: __forceinline operator MDB_cursor*() const { return m_cursor; } }; -class cursor_ptr_ro -{ - static MDB_cursor *m_cursor; - -public: - __forceinline cursor_ptr_ro(MDB_txn *_txn, MDB_dbi _dbi) - { - if (!m_cursor) - mdb_cursor_open(_txn, _dbi, &m_cursor); - } - - __forceinline ~cursor_ptr_ro() - { - } - - __forceinline operator MDB_cursor*() const { return m_cursor; } -}; - #define MDB_CHECK(A,B) \ switch(A) { \ case MDB_SUCCESS: break; \ -- cgit v1.2.3