summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-29 13:25:01 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-29 13:25:01 +0000
commit7ec6beadc3938e353351f9fae686a8759b8fde88 (patch)
tree311a178c2ec168ca45d678a7f511fbe160646134 /plugins/Dbx_mdb
parent6df974bc3fa6657b37fb039fc77458463629326a (diff)
dbx_lmdb: fix(?) events mixing
git-svn-id: http://svn.miranda-ng.org/main/trunk@16377 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb')
-rw-r--r--plugins/Dbx_mdb/src/dbevents.cpp14
-rw-r--r--plugins/Dbx_mdb/src/dbintf.cpp14
2 files changed, 22 insertions, 6 deletions
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp
index bf7d39b253..30078625c7 100644
--- a/plugins/Dbx_mdb/src/dbevents.cpp
+++ b/plugins/Dbx_mdb/src/dbevents.cpp
@@ -39,6 +39,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
dbe.contactID = contactID; // store native or subcontact's id
dbe.ofsModuleName = GetModuleNameOfs(dbei->szModule);
+ mir_cslockfull lck(m_csDbAccess);
MCONTACT contactNotifyID = contactID;
DBCachedContact *cc, *ccSub = NULL;
@@ -58,6 +59,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
contactNotifyID = contactID;
}
+ lck.unlock();
+
if (m_safetyMode)
if (NotifyEventHooks(hEventFilterAddedEvent, contactNotifyID, (LPARAM)dbei))
return NULL;
@@ -79,7 +82,8 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
}
}
- mir_cslockfull lck(m_csDbAccess);
+ lck.lock();
+
DWORD dwEventId = ++m_dwMaxEventId;
for (cc->Snapshot();; cc->Revert(), Remap()) {
@@ -243,12 +247,12 @@ void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSor
cursor_ptr cursor(txn, m_dbEventsSort);
MDB_val key = { sizeof(key2), &key2 }, data;
- key2.dwEventId++;
+ //key2.dwEventId++;
mdb_cursor_get(cursor, &key, &data, MDB_SET);
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
DBEvent *dbe = (DBEvent*)data.mv_data;
- if (!dbe->markedRead()) {
+ if (dbe->contactID == cc->contactID && !dbe->markedRead()) {
cc->dbc.dwFirstUnread = key2.dwEventId;
cc->dbc.tsFirstUnread = key2.ts;
return;
@@ -323,8 +327,6 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindFirstEvent(MCONTACT contactID)
cursor_ptr_ro cursor(m_curEventsSort);
mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE);
-// if (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) != MDB_SUCCESS)
-// return m_evLast = 0;
DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
m_tsLast = pKey->ts;
@@ -412,7 +414,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent
MDB_val key = { sizeof(keyVal), &keyVal };
cursor_ptr_ro cursor(m_curEventsSort);
- if (mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE) != MDB_SUCCESS)
+ if (mdb_cursor_get(cursor, &key, &data, MDB_SET) != MDB_SUCCESS)
return m_evLast = 0;
if (mdb_cursor_get(cursor, &key, &data, MDB_PREV) != MDB_SUCCESS)
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp
index 741fd0997f..56a116b234 100644
--- a/plugins/Dbx_mdb/src/dbintf.cpp
+++ b/plugins/Dbx_mdb/src/dbintf.cpp
@@ -23,6 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+/*#define CMP_DWORDS_K(x, y, f) { if(x->f != y->f) return (x->f<y->f)?-1:1; }
+
+static int EventsComparator(const MDB_val *v1, const MDB_val *v2)
+{
+ const DBEventSortingKey *k1 = (DBEventSortingKey *)v1->mv_data;
+ const DBEventSortingKey *k2 = (DBEventSortingKey *)v2->mv_data;
+ CMP_DWORDS_K(k1, k2, dwContactId);
+ CMP_DWORDS_K(k1, k2, ts);
+ CMP_DWORDS_K(k1, k2, dwEventId);
+ return 0;
+}*/
+
static int ModCompare(const ModuleName *mn1, const ModuleName *mn2)
{
return strcmp(mn1->name, mn2->name);
@@ -94,6 +106,8 @@ int CDbxMdb::Load(bool bSkipInit)
mdb_dbi_open(trnlck, "eventsrt", MDB_CREATE | MDB_INTEGERKEY, &m_dbEventsSort);
mdb_dbi_open(trnlck, "settings", MDB_CREATE, &m_dbSettings);
+ //mdb_set_compare(trnlck, m_dbEventsSort, EventsComparator);
+
DWORD keyVal = 1;
MDB_val key = { sizeof(DWORD), &keyVal }, data;
if (mdb_get(trnlck, m_dbGlobal, &key, &data) == MDB_SUCCESS) {