From 9b0a04f1262e37d94ca0a5ba6326ddbd1bfe9ddd Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 7 Oct 2017 11:48:34 -0700 Subject: [PATCH] - try slightly different way to protect mutex list --- source/shared_lib/include/platform/common/cache_manager.h | 5 +++-- source/shared_lib/sources/platform/common/cache_manager.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/shared_lib/include/platform/common/cache_manager.h b/source/shared_lib/include/platform/common/cache_manager.h index 3ed96bf37..51c149108 100644 --- a/source/shared_lib/include/platform/common/cache_manager.h +++ b/source/shared_lib/include/platform/common/cache_manager.h @@ -40,7 +40,7 @@ static const char *getFolderTreeContentsCheckSumListRecursivelyCacheLookupKey2; protected: static std::map itemCacheMutexList; - + static Mutex mutexMap; typedef enum { cacheItemGet, cacheItemSet @@ -48,7 +48,6 @@ protected: template static Mutex & manageCachedItemMutex(string cacheKey) { - static Mutex mutexMap(CODE_AT_LINE); if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) { MutexSafeWrapper safeMutex(&mutexMap); if(itemCacheMutexList.find(cacheKey) == itemCacheMutexList.end()) { @@ -102,12 +101,14 @@ public: CacheManager() { } static void cleanupMutexes() { + MutexSafeWrapper safeMutex(&mutexMap); for(std::map::iterator iterMap = itemCacheMutexList.begin(); iterMap != itemCacheMutexList.end(); iterMap++) { delete iterMap->second; iterMap->second = NULL; } itemCacheMutexList.clear(); + safeMutex.ReleaseLock(); } ~CacheManager() { CacheManager::cleanupMutexes(); diff --git a/source/shared_lib/sources/platform/common/cache_manager.cpp b/source/shared_lib/sources/platform/common/cache_manager.cpp index dbdcfb668..dc6eda5fb 100644 --- a/source/shared_lib/sources/platform/common/cache_manager.cpp +++ b/source/shared_lib/sources/platform/common/cache_manager.cpp @@ -14,6 +14,7 @@ namespace Shared { namespace PlatformCommon { //Mutex CacheManager::mutexCache; +Mutex CacheManager::mutexMap(CODE_AT_LINE); std::map CacheManager::itemCacheMutexList; const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey1 = "CRC_Cache_FileTree1"; const char *CacheManager::getFolderTreeContentsCheckSumRecursivelyCacheLookupKey2 = "CRC_Cache_FileTree2";