summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbcontacts.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-21 09:42:11 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-21 09:42:11 +0000
commit5380ed0fad80744e3093a6fb6f13f8d8a7b2e03a (patch)
treeaf15eeb3b7f96efca86f4d05afc9df694962e020 /plugins/Dbx_mdb/src/dbcontacts.cpp
parente151d6242dafb449fae9784e19e8122c44b57095 (diff)
dbx_lmdb: speed optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@16317 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbcontacts.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index cee0d1dedf..7c225f25d0 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -208,9 +208,14 @@ BOOL CDbxMdb::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
}
MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
- txn_ptr trnlck(m_pMdbEnv);
- mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0);
- trnlck.commit();
+
+ for (;; Remap())
+ {
+ txn_ptr trnlck(m_pMdbEnv);
+ MDB_CHECK(mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
+ if (trnlck.commit())
+ break;
+ }
return 0;
}
@@ -237,9 +242,14 @@ BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
}
MDB_val keyc = { sizeof(int), &ccMeta->contactID }, datac = { sizeof(ccMeta->dbc), &ccMeta->dbc };
- txn_ptr trnlck(m_pMdbEnv);
- mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0);
- trnlck.commit();
+
+ for (;; Remap())
+ {
+ txn_ptr trnlck(m_pMdbEnv);
+ MDB_CHECK(mdb_put(trnlck, m_dbContacts, &keyc, &datac, 0), 1);
+ if (trnlck.commit())
+ break;
+ }
return 0;
}
@@ -276,10 +286,11 @@ void CDbxMdb::FillContacts()
{
LIST<DBCachedContact> arContacts(10);
- txn_ptr trnlck(m_pMdbEnv);
- //mdb_open(trnlck, "contacts", MDB_INTEGERKEY, &m_dbContacts);
{
- cursor_ptr cursor(trnlck, m_dbContacts);
+ mir_cslock lck(m_csDbAccess);
+
+ txn_ptr_ro trnlck(m_txn);
+ cursor_ptr_ro cursor(m_curContacts);
MDB_val key, data;
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
@@ -297,7 +308,8 @@ void CDbxMdb::FillContacts()
}
m_contactCount = 0;
- for (int i = 0; i < arContacts.getCount(); i++) {
+ for (int i = 0; i < arContacts.getCount(); i++)
+ {
DBCachedContact *cc = arContacts[i];
CheckProto(cc, "");