diff options
author | George Hazan <ghazan@miranda.im> | 2017-11-23 20:12:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-11-23 20:12:31 +0300 |
commit | 2e31328cb95f04bba6eed36efec3539bf54c6b0f (patch) | |
tree | 4083a55ab481b595628090dcf70a78c89a8db537 /src | |
parent | 72ed903dac773db034a187b4ba7f187ef43d717e (diff) |
we need the additional lock to prevent the list from corruption
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/database.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/mdatabasecache.cpp | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/mir_app/src/database.h b/src/mir_app/src/database.h index ec052b2f31..f5c793d94a 100644 --- a/src/mir_app/src/database.h +++ b/src/mir_app/src/database.h @@ -27,7 +27,7 @@ class MDatabaseCache : public MIDatabaseCache char* m_lastSetting;
size_t m_contactSize;
DBCachedContact *m_lastVL;
- mir_cs m_cs;
+ mir_cs m_csContact, m_csVal;
LIST<DBCachedContact> m_lContacts;
LIST<DBCachedGlobalValue> m_lGlobalSettings;
diff --git a/src/mir_app/src/mdatabasecache.cpp b/src/mir_app/src/mdatabasecache.cpp index c4b9e8d946..6d62c3d49b 100644 --- a/src/mir_app/src/mdatabasecache.cpp +++ b/src/mir_app/src/mdatabasecache.cpp @@ -59,7 +59,7 @@ MDatabaseCache::~MDatabaseCache() DBCachedContact* MDatabaseCache::AddContactToCache(MCONTACT contactID)
{
- mir_cslock lck(m_cs);
+ mir_cslock lck(m_csContact);
int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
if (index != -1)
@@ -74,7 +74,7 @@ DBCachedContact* MDatabaseCache::AddContactToCache(MCONTACT contactID) DBCachedContact* MDatabaseCache::GetCachedContact(MCONTACT contactID)
{
- mir_cslock lck(m_cs);
+ mir_cslock lck(m_csContact);
int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
return (index == -1) ? nullptr : m_lContacts[index];
@@ -82,13 +82,13 @@ DBCachedContact* MDatabaseCache::GetCachedContact(MCONTACT contactID) DBCachedContact* MDatabaseCache::GetFirstContact()
{
- mir_cslock lck(m_cs);
+ mir_cslock lck(m_csContact);
return m_lContacts[0];
}
DBCachedContact* MDatabaseCache::GetNextContact(MCONTACT contactID)
{
- mir_cslock lck(m_cs);
+ mir_cslock lck(m_csContact);
int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
return (index == -1) ? nullptr : m_lContacts[index+1];
@@ -96,7 +96,7 @@ DBCachedContact* MDatabaseCache::GetNextContact(MCONTACT contactID) void MDatabaseCache::FreeCachedContact(MCONTACT contactID)
{
- mir_cslock lck(m_cs);
+ mir_cslock lck(m_csContact);
int index = m_lContacts.getIndex((DBCachedContact*)&contactID);
if (index == -1)
@@ -124,7 +124,10 @@ char* MDatabaseCache::InsertCachedSetting(const char* szName, int cbLen) char* newValue = (char*)HeapAlloc(m_hCacheHeap, 0, cbLen);
*newValue++ = 0;
mir_strcpy(newValue, szName);
- m_lSettings.insert(newValue);
+ {
+ mir_cslock lck(m_csVal);
+ m_lSettings.insert(newValue);
+ }
return newValue;
}
|