summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbcontacts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-13 17:36:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-13 17:36:14 +0000
commit3ed0cd54cf2db670166af44296694a1c9679ec03 (patch)
tree15dd89ebc75ecc3ff300e1d3ebdd27fc275583be /plugins/Dbx_mdb/src/dbcontacts.cpp
parent88722c0734ae6ce9b91ba397b89c4b73ed6f064d (diff)
- fix for ssize_t;
- various optimizations git-svn-id: http://svn.miranda-ng.org/main/trunk@11848 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index 26c245e8cb..b02c4cb596 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -85,9 +85,12 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
NotifyEventHooks(hContactDeletedEvent, contactID, 0);
// delete
+ mir_cslock lck(m_csDbAccess);
+
MDB_val key = { sizeof(DWORD), &contactID };
txn_lock trnlck(m_pMdbEnv);
+ mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
mdb_del(trnlck, m_dbContacts, &key, NULL);
trnlck.commit();
return 0;
@@ -95,21 +98,26 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
STDMETHODIMP_(MCONTACT) CDbxMdb::AddContact()
{
+ DWORD dwContactId;
+
DBContact dbc;
dbc.signature = DBCONTACT_SIGNATURE;
dbc.eventCount = 0;
-
- DWORD dwContactId = m_dwMaxContactId++;
+ {
+ mir_cslock lck(m_csDbAccess);
+ dwContactId = m_dwMaxContactId++;
- MDB_val key = { sizeof(DWORD), &dwContactId };
- MDB_val data = { sizeof(DBContact), &dbc };
+ MDB_val key = { sizeof(DWORD), &dwContactId };
+ MDB_val data = { sizeof(DBContact), &dbc };
- txn_lock trnlck(m_pMdbEnv);
- mdb_put(trnlck, m_dbContacts, &key, &data, 0);
- trnlck.commit();
+ txn_lock trnlck(m_pMdbEnv);
+ mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
+ mdb_put(trnlck, m_dbContacts, &key, &data, 0);
+ trnlck.commit();
- DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
- cc->dwDriverData = 0;
+ DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
+ cc->dwDriverData = 0;
+ }
NotifyEventHooks(hContactAddedEvent, dwContactId, 0);
return dwContactId;