summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-23 12:24:44 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-23 12:24:44 +0000
commit6e5e867a1230d0425ac5b69b85cdcdde0abe1045 (patch)
treeb53717aac8a66b83dfc1673c05f4235f6d3bd8e4 /plugins/Dbx_mdb/src
parent4c73ded51e3d25b836fad3a8dfaf35ab1615a281 (diff)
dbx_lmdb: contacts deletion correctly
git-svn-id: http://svn.miranda-ng.org/main/trunk@16328 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index a65a1a0f13..aa5c8a6f9d 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -91,6 +91,9 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
return 1;
// delete
+ // call notifier while outside mutex
+ NotifyEventHooks(hContactDeletedEvent, contactID, 0);
+
mir_cslockfull lck(m_csDbAccess);
MDB_val key = { sizeof(MCONTACT), &contactID }, data;
@@ -102,23 +105,30 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
if (trnlck.commit())
break;
}
-
{
- DBEventSortingKey keyVal = { 0, 0, contactID };
- key.mv_size = sizeof(keyVal); key.mv_data = &keyVal;
- 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)
+ LIST<void> events(50, NumericKeySortT);
{
- DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
- if (pKey->dwContactId != contactID)
- break;
- mdb_cursor_del(cursor, 0);
+ DBEventSortingKey keyVal = { 0, 0, contactID };
+ key.mv_size = sizeof(keyVal); key.mv_data = &keyVal;
+
+ txn_ptr_ro txn(m_txn);
+ cursor_ptr_ro cursor(m_curEventsSort);
+ mdb_cursor_get(cursor, &key, &data, MDB_SET);
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS)
+ {
+ DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
+ if (pKey->dwContactId != contactID)
+ break;
+ events.insert((void*)pKey->dwEventId);
+ }
+ }
+ while (events.getCount())
+ {
+ DeleteEvent(contactID, (MEVENT)events[0]);
+ events.remove(0);
}
- txn.commit();
}
- {
+ {// this code not delete all settings
DBSettingKey keyS = { contactID, 0 };
memset(keyS.szSettingName, 0, sizeof(keyS.szSettingName));
@@ -147,8 +157,6 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
lck.unlock();
- // call notifier while outside mutex
- NotifyEventHooks(hContactDeletedEvent, contactID, 0);
return 0;
}