summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx/src/dbcontacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_mdbx/src/dbcontacts.cpp75
1 files changed, 36 insertions, 39 deletions
diff --git a/plugins/Dbx_mdbx/src/dbcontacts.cpp b/plugins/Dbx_mdbx/src/dbcontacts.cpp
index 1195c0af6e..1b8a269026 100644
--- a/plugins/Dbx_mdbx/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdbx/src/dbcontacts.cpp
@@ -67,15 +67,15 @@ STDMETHODIMP_(LONG) CDbxMDBX::DeleteContact(MCONTACT contactID)
}
MDBX_val key = { &contactID, sizeof(MCONTACT) };
- for (;; Remap()) {
+ {
txn_ptr trnlck(m_env);
- MDBX_CHECK(mdbx_del(trnlck, m_dbContacts, &key, nullptr), 1);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
+ if (mdbx_del(trnlck, m_dbContacts, &key, nullptr) != MDBX_SUCCESS)
+ return 1;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 1;
}
InterlockedDecrement(&m_contactCount);
-
return 0;
}
@@ -84,15 +84,15 @@ STDMETHODIMP_(MCONTACT) CDbxMDBX::AddContact()
MCONTACT dwContactId = InterlockedIncrement(&m_maxContactId);
DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
+ {
+ MDBX_val key = { &dwContactId, sizeof(MCONTACT) };
+ MDBX_val data = { &cc->dbc, sizeof(cc->dbc) };
- MDBX_val key = { &dwContactId, sizeof(MCONTACT) };
- MDBX_val data = { &cc->dbc, sizeof(cc->dbc) };
-
- for (;; Remap()) {
txn_ptr trnlck(m_env);
- MDBX_CHECK(mdbx_put(trnlck, m_dbContacts, &key, &data, 0), 0);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
+ if (mdbx_put(trnlck, m_dbContacts, &key, &data, 0) != MDBX_SUCCESS)
+ return 0;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 0;
}
InterlockedIncrement(&m_contactCount);
@@ -110,7 +110,7 @@ STDMETHODIMP_(BOOL) CDbxMDBX::IsDbContact(MCONTACT contactID)
void CDbxMDBX::GatherContactHistory(MCONTACT hContact, LIST<EventItem> &list)
{
- DBEventSortingKey keyVal = { 0, 0, hContact };
+ DBEventSortingKey keyVal = { hContact, 0, 0 };
MDBX_val key = { &keyVal, sizeof(keyVal) }, data;
txn_ptr_ro trnlck(m_txn);
@@ -132,27 +132,26 @@ BOOL CDbxMDBX::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
for (int i = 0; i < list.getCount(); i++) {
EventItem *EI = list[i];
-
- for (;; Remap()) {
+ {
txn_ptr trnlck(m_env);
- DBEventSortingKey insVal = { EI->eventId, EI->ts, ccMeta->contactID };
+ DBEventSortingKey insVal = { ccMeta->contactID, EI->eventId, EI->ts };
MDBX_val key = { &insVal, sizeof(insVal) }, data = { (void*)"", 1 };
- mdbx_put(trnlck, m_dbEventsSort, &key, &data, 0);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
+
+ if (mdbx_put(trnlck, m_dbEventsSort, &key, &data, 0) != MDBX_SUCCESS)
+ return 1;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 1;
}
ccMeta->dbc.dwEventCount++;
delete EI;
}
MDBX_val keyc = { &ccMeta->contactID, sizeof(MCONTACT) }, datac = { &ccMeta->dbc, sizeof(ccMeta->dbc) };
-
- for (;; Remap()) {
- txn_ptr trnlck(m_env);
- MDBX_CHECK(mdbx_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
- }
+ txn_ptr trnlck(m_env);
+ if (mdbx_put(trnlck, m_dbContacts, &keyc, &datac, 0) != MDBX_SUCCESS)
+ return 1;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 1;
return 0;
}
@@ -165,27 +164,25 @@ BOOL CDbxMDBX::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
for (int i = 0; i < list.getCount(); i++) {
EventItem *EI = list[i];
-
- for (;; Remap()) {
+ {
txn_ptr trnlck(m_env);
- DBEventSortingKey insVal = { EI->eventId, EI->ts, ccMeta->contactID };
+ DBEventSortingKey insVal = { ccMeta->contactID, EI->eventId, EI->ts };
MDBX_val key = { &insVal, sizeof(insVal) }, data = { (void*)"", 1 };
- mdbx_del(trnlck, m_dbEventsSort, &key, &data);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
+ if (mdbx_del(trnlck, m_dbEventsSort, &key, &data) != MDBX_SUCCESS)
+ return 1;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 1;
}
ccMeta->dbc.dwEventCount--;
delete EI;
}
+ txn_ptr trnlck(m_env);
MDBX_val keyc = { &ccMeta->contactID, sizeof(MCONTACT) }, datac = { &ccMeta->dbc, sizeof(ccMeta->dbc) };
-
- for (;; Remap()) {
- txn_ptr trnlck(m_env);
- MDBX_CHECK(mdbx_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
- if (trnlck.commit() == MDBX_SUCCESS)
- break;
- }
+ if(mdbx_put(trnlck, m_dbContacts, &keyc, &datac, 0) != MDBX_SUCCESS)
+ return 1;
+ if (trnlck.commit() != MDBX_SUCCESS)
+ return 1;
return 0;
}