From 3ed0cd54cf2db670166af44296694a1c9679ec03 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Jan 2015 17:36:14 +0000 Subject: - fix for ssize_t; - various optimizations git-svn-id: http://svn.miranda-ng.org/main/trunk@11848 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mdb/src/dbcontacts.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'plugins/Dbx_mdb/src/dbcontacts.cpp') 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; -- cgit v1.2.3