fixed bug in debug_printCacheSize() that was actually corrupting the cache

This commit is contained in:
csoler 2020-12-19 21:11:13 +01:00
parent 125fbde48e
commit e8d6632473
3 changed files with 11 additions and 4 deletions

View File

@ -1730,8 +1730,10 @@ int RsDataService::setCacheSize(uint32_t /* size */)
return 0;
}
void RsDataService::debug_printCacheSize() const
void RsDataService::debug_printCacheSize()
{
RS_STACK_MUTEX(mDbMutex);
uint32_t nb_items,nb_items_on_deadlist;
uint64_t total_size,total_size_of_deadlist;
@ -1743,7 +1745,7 @@ void RsDataService::debug_printCacheSize() const
nb_items = 0,nb_items_on_deadlist = 0;
total_size = 0,total_size_of_deadlist = 0;
for(auto it:mMsgMetaDataCache)
for(auto& it:mMsgMetaDataCache)
{
uint32_t tmp_nb_items,tmp_nb_items_on_deadlist;
uint64_t tmp_total_size,tmp_total_size_of_deadlist;

View File

@ -292,7 +292,7 @@ public:
int updateGroupKeys(const RsGxsGroupId& grpId,const RsTlvSecurityKeySet& keys, uint32_t subscribe_flags) ;
void debug_printCacheSize() const;
void debug_printCacheSize() ;
private:

View File

@ -1472,7 +1472,12 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult);
const std::vector<const RsGxsMsgMetaData*>& msgMetaV = metaResult[req->mGrpId];
const auto& msgMetaV_it = metaResult.find(req->mGrpId);
if(msgMetaV_it == metaResult.end())
return false;
const auto& msgMetaV(msgMetaV_it->second);
req->mGroupStatistic.mGrpId = req->mGrpId;
req->mGroupStatistic.mNumMsgs = msgMetaV.size();