From 80207f75648fad4294a77ff9ce50f0edaedffeca Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 23 Jan 2018 19:51:30 +0300 Subject: dbx_mdbx: - fix for a name conflict; - stricter transaction scope; - version bump --- plugins/Dbx_mdbx/src/dbsettings.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'plugins/Dbx_mdbx/src/dbsettings.cpp') diff --git a/plugins/Dbx_mdbx/src/dbsettings.cpp b/plugins/Dbx_mdbx/src/dbsettings.cpp index fe7b40626b..312d4aa68e 100644 --- a/plugins/Dbx_mdbx/src/dbsettings.cpp +++ b/plugins/Dbx_mdbx/src/dbsettings.cpp @@ -80,18 +80,22 @@ LBL_Seek: if (szCachedSettingName[-1] != 0) return 1; + int res; + const BYTE *pBlob; DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : nullptr; + { + txn_ptr_ro trnlck(m_txn_ro); - txn_ptr_ro trnlck(m_txn); - - DBSettingKey *keyVal = (DBSettingKey *)_alloca(sizeof(DBSettingKey) + settingNameLen); - keyVal->hContact = contactID; - keyVal->dwModuleId = GetModuleID(szModule); - memcpy(&keyVal->szSettingName, szSetting, settingNameLen + 1); - + DBSettingKey *keyVal = (DBSettingKey *)_alloca(sizeof(DBSettingKey) + settingNameLen); + keyVal->hContact = contactID; + keyVal->dwModuleId = GetModuleID(szModule); + memcpy(&keyVal->szSettingName, szSetting, settingNameLen + 1); - MDBX_val key = { keyVal, sizeof(DBSettingKey) + settingNameLen }, data; - if (mdbx_get(trnlck, m_dbSettings, &key, &data) != MDBX_SUCCESS) { + MDBX_val key = { keyVal, sizeof(DBSettingKey) + settingNameLen }, data; + res = mdbx_get(trnlck, m_dbSettings, &key, &data); + pBlob = (const BYTE*)data.iov_base; + } + if (res != MDBX_SUCCESS) { // try to get the missing mc setting from the active sub if (cc && cc->IsMeta() && ValidLookupName(szModule, szSetting)) { if (contactID = db_mc_getDefault(contactID)) { @@ -104,7 +108,6 @@ LBL_Seek: return 1; } - const BYTE *pBlob = (const BYTE*)data.iov_base; if (isStatic && (pBlob[0] & DBVTF_VARIABLELENGTH) && VLT(dbv->type) != VLT(pBlob[0])) return 1; @@ -381,7 +384,7 @@ STDMETHODIMP_(BOOL) CDbxMDBX::EnumContactSettings(MCONTACT hContact, DBSETTINGEN int result = -1; DBSettingKey keyVal = { hContact, GetModuleID(szModule), 0 }; - txn_ptr_ro txn(m_txn); + txn_ptr_ro txn(m_txn_ro); cursor_ptr_ro cursor(m_curSettings); LIST arKeys(100); -- cgit v1.2.3