diff options
author | George Hazan <ghazan@miranda.im> | 2018-02-21 19:30:05 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-02-21 19:30:05 +0300 |
commit | 27f3ff240f553afa93a29eb2848eb48be2ae2099 (patch) | |
tree | bb1504dddfcec74988258aa9f25898c006003c0d /src | |
parent | 477a6ea70d0bb1b1dfe9cbd9a15b6dad0284ddeb (diff) |
on 6-core CPUs this code crashes without locking any change operation
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/mdatabasecache.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mir_app/src/mdatabasecache.cpp b/src/mir_app/src/mdatabasecache.cpp index 83ab81790d..6c78fcf8b1 100644 --- a/src/mir_app/src/mdatabasecache.cpp +++ b/src/mir_app/src/mdatabasecache.cpp @@ -187,6 +187,7 @@ STDMETHODIMP_(DBVARIANT*) MDatabaseCache::GetCachedValuePtr(MCONTACT contactID, if (index != -1) {
V = m_lGlobalSettings[index];
if (bAllocate == -1) {
+ mir_cslock lck(m_csVal);
FreeCachedVariant(&V->value);
m_lGlobalSettings.remove(index);
HeapFree(m_hCacheHeap, 0, V);
@@ -197,6 +198,7 @@ STDMETHODIMP_(DBVARIANT*) MDatabaseCache::GetCachedValuePtr(MCONTACT contactID, if (bAllocate != 1)
return nullptr;
+ mir_cslock lck(m_csVal);
V = (DBCachedGlobalValue*)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedGlobalValue));
V->name = szSetting;
m_lGlobalSettings.insert(V);
@@ -225,6 +227,7 @@ STDMETHODIMP_(DBVARIANT*) MDatabaseCache::GetCachedValuePtr(MCONTACT contactID, if (bAllocate != 1)
return nullptr;
+ mir_cslock lck(m_csVal);
V = (DBCachedContactValue *)HeapAlloc(m_hCacheHeap, HEAP_ZERO_MEMORY, sizeof(DBCachedContactValue));
if (cc->last)
cc->last->next = V;
@@ -234,6 +237,7 @@ STDMETHODIMP_(DBVARIANT*) MDatabaseCache::GetCachedValuePtr(MCONTACT contactID, V->name = szSetting;
}
else if (bAllocate == -1) {
+ mir_cslock lck(m_csVal);
m_lastVL = nullptr;
FreeCachedVariant(&V->value);
if (cc->first == V) {
|