From 27f3ff240f553afa93a29eb2848eb48be2ae2099 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 21 Feb 2018 19:30:05 +0300 Subject: on 6-core CPUs this code crashes without locking any change operation --- src/mir_app/src/mdatabasecache.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mir_app') 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) { -- cgit v1.2.3