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";