summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx')
-rw-r--r--plugins/Dbx_mdbx/src/dbevents.cpp65
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h3
-rw-r--r--plugins/Dbx_mdbx/src/version.h2
3 files changed, 43 insertions, 27 deletions
diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp
index 0fa08dfc08..0262cf89ec 100644
--- a/plugins/Dbx_mdbx/src/dbevents.cpp
+++ b/plugins/Dbx_mdbx/src/dbevents.cpp
@@ -336,11 +336,12 @@ STDMETHODIMP_(MCONTACT) CDbxMDBX::GetEventContact(MEVENT hDbEvent)
///////////////////////////////////////////////////////////////////////////////
-thread_local uint64_t t_tsLast = 0;
-thread_local MEVENT t_evLast = 0;
-
STDMETHODIMP_(MEVENT) CDbxMDBX::FindFirstEvent(MCONTACT contactID)
{
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == nullptr)
+ return 0;
+
DBEventSortingKey keyVal = { contactID, 0, 0 };
MDBX_val key = { &keyVal, sizeof(keyVal) }, data;
@@ -348,11 +349,11 @@ STDMETHODIMP_(MEVENT) CDbxMDBX::FindFirstEvent(MCONTACT contactID)
cursor_ptr_ro cursor(m_curEventsSort);
if (mdbx_cursor_get(cursor, &key, &data, MDBX_SET_RANGE) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
const DBEventSortingKey *pKey = (const DBEventSortingKey*)key.iov_base;
- t_tsLast = pKey->ts;
- return t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
+ cc->t_tsLast = pKey->ts;
+ return cc->t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -367,6 +368,10 @@ STDMETHODIMP_(MEVENT) CDbxMDBX::FindFirstUnreadEvent(MCONTACT contactID)
STDMETHODIMP_(MEVENT) CDbxMDBX::FindLastEvent(MCONTACT contactID)
{
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == nullptr)
+ return 0;
+
DBEventSortingKey keyVal = { contactID, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF };
MDBX_val key = { &keyVal, sizeof(keyVal) }, data;
@@ -375,80 +380,88 @@ STDMETHODIMP_(MEVENT) CDbxMDBX::FindLastEvent(MCONTACT contactID)
if (mdbx_cursor_get(cursor, &key, &data, MDBX_SET_RANGE) != MDBX_SUCCESS) {
if (mdbx_cursor_get(cursor, &key, &data, MDBX_LAST) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
}
else {
if (mdbx_cursor_get(cursor, &key, &data, MDBX_PREV) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
}
const DBEventSortingKey *pKey = (const DBEventSortingKey*)key.iov_base;
- t_tsLast = pKey->ts;
- return t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
+ cc->t_tsLast = pKey->ts;
+ return cc->t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
}
///////////////////////////////////////////////////////////////////////////////
STDMETHODIMP_(MEVENT) CDbxMDBX::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == nullptr)
+ return 0;
+
if (hDbEvent == 0)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
txn_ptr_ro txn(m_txn_ro);
- if (t_evLast != hDbEvent) {
+ if (cc->t_evLast != hDbEvent) {
MDBX_val key = { &hDbEvent, sizeof(MEVENT) }, data;
if (mdbx_get(txn, m_dbEvents, &key, &data) != MDBX_SUCCESS)
return 0;
- t_tsLast = ((DBEvent*)data.iov_base)->timestamp;
+ cc->t_tsLast = ((DBEvent*)data.iov_base)->timestamp;
}
- DBEventSortingKey keyVal = { contactID, hDbEvent, t_tsLast };
+ DBEventSortingKey keyVal = { contactID, hDbEvent, cc->t_tsLast };
MDBX_val key = { &keyVal, sizeof(keyVal) }, data;
cursor_ptr_ro cursor(m_curEventsSort);
if (mdbx_cursor_get(cursor, &key, &data, MDBX_SET) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
if (mdbx_cursor_get(cursor, &key, &data, MDBX_NEXT) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
const DBEventSortingKey *pKey = (const DBEventSortingKey*)key.iov_base;
- t_tsLast = pKey->ts;
- return t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
+ cc->t_tsLast = pKey->ts;
+ return cc->t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
}
///////////////////////////////////////////////////////////////////////////////
STDMETHODIMP_(MEVENT) CDbxMDBX::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
{
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == nullptr)
+ return 0;
+
if (hDbEvent == 0)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
MDBX_val data;
txn_ptr_ro txn(m_txn_ro);
- if (t_evLast != hDbEvent) {
+ if (cc->t_evLast != hDbEvent) {
MDBX_val key = { &hDbEvent, sizeof(MEVENT) };
if (mdbx_get(txn, m_dbEvents, &key, &data) != MDBX_SUCCESS)
return 0;
- t_tsLast = ((DBEvent*)data.iov_base)->timestamp;
+ cc->t_tsLast = ((DBEvent*)data.iov_base)->timestamp;
}
- DBEventSortingKey keyVal = { contactID, hDbEvent, t_tsLast };
+ DBEventSortingKey keyVal = { contactID, hDbEvent, cc->t_tsLast };
MDBX_val key = { &keyVal, sizeof(keyVal) };
cursor_ptr_ro cursor(m_curEventsSort);
if (mdbx_cursor_get(cursor, &key, &data, MDBX_SET) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
if (mdbx_cursor_get(cursor, &key, &data, MDBX_PREV) != MDBX_SUCCESS)
- return t_evLast = 0;
+ return cc->t_evLast = 0;
const DBEventSortingKey *pKey = (const DBEventSortingKey*)key.iov_base;
- t_tsLast = pKey->ts;
- return t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
+ cc->t_tsLast = pKey->ts;
+ return cc->t_evLast = (pKey->hContact == contactID) ? pKey->hEvent : 0;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index 0ef57afdab..725bc28c61 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -113,7 +113,10 @@ struct DBCachedContact : public DBCachedContactBase
void Advance(MEVENT id, DBEvent &dbe);
void Snapshot();
void Revert();
+
DBContact dbc, tmp_dbc;
+ uint64_t t_tsLast;
+ MEVENT t_evLast;
};
struct EventItem
diff --git a/plugins/Dbx_mdbx/src/version.h b/plugins/Dbx_mdbx/src/version.h
index aa3c82c33e..543e9abbe4 100644
--- a/plugins/Dbx_mdbx/src/version.h
+++ b/plugins/Dbx_mdbx/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 8
-#define __BUILD_NUM 4
+#define __BUILD_NUM 5
#include <stdver.h>