summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbcontacts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-12 23:00:18 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-12 23:00:18 +0000
commit88722c0734ae6ce9b91ba397b89c4b73ed6f064d (patch)
treef7015fc820d7ec94dcea7f9e4511edcb9d6bce69 /plugins/Dbx_mdb/src/dbcontacts.cpp
parent3f5208b9147b32ddcf259ec8bb3fb280192928f8 (diff)
transaction locker
very first version of settings writer/reader git-svn-id: http://svn.miranda-ng.org/main/trunk@11847 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index fbb3c89276..26c245e8cb 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -87,10 +87,9 @@ STDMETHODIMP_(LONG) CDbxMdb::DeleteContact(MCONTACT contactID)
// delete
MDB_val key = { sizeof(DWORD), &contactID };
- MDB_txn *txn;
- mdb_txn_begin(m_pMdbEnv, NULL, 0, &txn);
- mdb_del(txn, m_dbContacts, &key, NULL);
- mdb_txn_commit(txn);
+ txn_lock trnlck(m_pMdbEnv);
+ mdb_del(trnlck, m_dbContacts, &key, NULL);
+ trnlck.commit();
return 0;
}
@@ -105,10 +104,9 @@ STDMETHODIMP_(MCONTACT) CDbxMdb::AddContact()
MDB_val key = { sizeof(DWORD), &dwContactId };
MDB_val data = { sizeof(DBContact), &dbc };
- MDB_txn *txn;
- mdb_txn_begin(m_pMdbEnv, NULL, 0, &txn);
- mdb_put(txn, m_dbContacts, &key, &data, 0);
- mdb_txn_commit(txn);
+ txn_lock trnlck(m_pMdbEnv);
+ mdb_put(trnlck, m_dbContacts, &key, &data, 0);
+ trnlck.commit();
DBCachedContact *cc = m_cache->AddContactToCache(dwContactId);
cc->dwDriverData = 0;
@@ -163,12 +161,11 @@ void CDbxMdb::FillContacts()
{
m_contactCount = 0;
- MDB_txn *txn;
- mdb_txn_begin(m_pMdbEnv, NULL, MDB_RDONLY, &txn);
- mdb_open(txn, "contacts", MDB_CREATE | MDB_INTEGERKEY, &m_dbContacts);
+ txn_lock trnlck(m_pMdbEnv);
+ mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
MDB_cursor *cursor;
- mdb_cursor_open(txn, m_dbContacts, &cursor);
+ mdb_cursor_open(trnlck, m_dbContacts, &cursor);
MDB_val key, data;
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
@@ -199,5 +196,4 @@ void CDbxMdb::FillContacts()
}
mdb_cursor_close(cursor);
- mdb_txn_abort(txn);
}