diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-31 11:08:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-31 11:08:53 +0000 |
commit | 81f73a9df3f62a65d2c3f9c1d2033bca1f66acf0 (patch) | |
tree | e342cff1e5746435b3095562c3e7c377eadb413f /plugins/Db3x_mmap/src/dbsettings.cpp | |
parent | 6cc54049b4e7ba48787758c5332341df6f93be81 (diff) |
misplaced lock for database cache access
git-svn-id: http://svn.miranda-ng.org/main/trunk@11693 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbsettings.cpp')
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 82f65d627e..a2175e6f8b 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -722,56 +722,58 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz }
MCONTACT saveContact = contactID;
- char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
- if (szCachedSettingName[-1] == 0) { // it's not a resident variable
+ {
mir_cslock lck(m_csDbAccess);
- DWORD ofsModuleName = GetModuleNameOfs(szModule);
- DWORD ofsContact = GetContactOffset(contactID);
- DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL);
- if (dbc->signature != DBCONTACT_SIGNATURE)
- return 1;
+ char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
+ if (szCachedSettingName[-1] == 0) { // it's not a resident variable
+ DWORD ofsModuleName = GetModuleNameOfs(szModule);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL);
+ if (dbc->signature != DBCONTACT_SIGNATURE)
+ return 1;
- // make sure the module group exists
- DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
- if (ofsSettingsGroup == 0)
- return 1;
+ // make sure the module group exists
+ DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
+ if (ofsSettingsGroup == 0)
+ return 1;
- // find if the setting exists
- DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
- int bytesRemaining;
- PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
- while (pBlob[0]) {
- NeedBytes(settingNameLen + 1);
- if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen))
- break;
- NeedBytes(1);
- MoveAlong(pBlob[0] + 1);
- NeedBytes(3);
- MoveAlong(1 + GetSettingValueLength(pBlob));
- NeedBytes(1);
- }
- if (!pBlob[0]) //setting didn't exist
- return 1;
+ // find if the setting exists
+ DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
+ int bytesRemaining;
+ PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ while (pBlob[0]) {
+ NeedBytes(settingNameLen + 1);
+ if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, szSetting, settingNameLen))
+ break;
+ NeedBytes(1);
+ MoveAlong(pBlob[0] + 1);
+ NeedBytes(3);
+ MoveAlong(1 + GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ if (!pBlob[0]) //setting didn't exist
+ return 1;
- // bin it
- MoveAlong(1 + settingNameLen);
- NeedBytes(3);
- int nameLen = 1 + settingNameLen;
- int valLen = 1 + GetSettingValueLength(pBlob);
- DWORD ofsSettingToCut = ofsBlobPtr - nameLen;
- MoveAlong(valLen);
- NeedBytes(1);
- while (pBlob[0]) {
- MoveAlong(pBlob[0] + 1);
+ // bin it
+ MoveAlong(1 + settingNameLen);
NeedBytes(3);
- MoveAlong(1 + GetSettingValueLength(pBlob));
+ int nameLen = 1 + settingNameLen;
+ int valLen = 1 + GetSettingValueLength(pBlob);
+ DWORD ofsSettingToCut = ofsBlobPtr - nameLen;
+ MoveAlong(valLen);
NeedBytes(1);
+ while (pBlob[0]) {
+ MoveAlong(pBlob[0] + 1);
+ NeedBytes(3);
+ MoveAlong(1 + GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ DBMoveChunk(ofsSettingToCut, ofsSettingToCut + nameLen + valLen, ofsBlobPtr + 1 - ofsSettingToCut);
+ DBFlush(1);
}
- DBMoveChunk(ofsSettingToCut, ofsSettingToCut + nameLen + valLen, ofsBlobPtr + 1 - ofsSettingToCut);
- DBFlush(1);
- }
- m_cache->GetCachedValuePtr(saveContact, szCachedSettingName, -1);
+ m_cache->GetCachedValuePtr(saveContact, szCachedSettingName, -1);
+ }
// notify
DBCONTACTWRITESETTING dbcws = { 0 };
|