replaced GxsMetaData pointers by shared_ptrs in dataaccess and dataservice, so that we can easily disable caching, more freely get rid of cache items, and have a simpler memory management scheme

This commit is contained in:
csoler 2020-12-26 23:13:17 +01:00
parent 4a15c59356
commit 22ceec6c43
14 changed files with 164 additions and 331 deletions

View File

@ -482,7 +482,7 @@ bool RsDataService::finishReleaseUpdate(int release, bool result)
return result; return result;
} }
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset,bool use_cache) std::shared_ptr<RsGxsGrpMetaData> RsDataService::locked_getGrpMeta(RetroCursor& c, int colOffset,bool use_cache)
{ {
#ifdef RS_DATA_SERVICE_DEBUG #ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "RsDataService::locked_getGrpMeta()" << std::endl; std::cerr << "RsDataService::locked_getGrpMeta()" << std::endl;
@ -499,7 +499,7 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
std::string tempId; std::string tempId;
c.getString(mColGrpMeta_GrpId + colOffset, tempId); c.getString(mColGrpMeta_GrpId + colOffset, tempId);
RsGxsGrpMetaData* grpMeta ; std::shared_ptr<RsGxsGrpMetaData> grpMeta ;
RsGxsGroupId grpId(tempId) ; RsGxsGroupId grpId(tempId) ;
if(grpId.isNull()) // not in the DB! if(grpId.isNull()) // not in the DB!
@ -508,7 +508,7 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
if(use_cache) if(use_cache)
grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId); grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId);
else else
grpMeta = new RsGxsGrpMetaData(); grpMeta = std::make_shared<RsGxsGrpMetaData>();
if(!grpMeta->mGroupId.isNull()) // the grpMeta is already initialized because it comes from the cache if(!grpMeta->mGroupId.isNull()) // the grpMeta is already initialized because it comes from the cache
return grpMeta; return grpMeta;
@ -596,12 +596,8 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
if(ok) if(ok)
return grpMeta; return grpMeta;
else else
{
if(!use_cache)
delete grpMeta;
return NULL; return NULL;
} }
}
RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c) RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c)
{ {
@ -645,9 +641,8 @@ RsNxsGrp* RsDataService::locked_getGroup(RetroCursor &c)
return NULL; return NULL;
} }
RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset,bool use_cache) std::shared_ptr<RsGxsMsgMetaData> RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset,bool use_cache)
{ {
bool ok = true; bool ok = true;
uint32_t data_len = 0, uint32_t data_len = 0,
offset = 0; offset = 0;
@ -667,12 +662,12 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset
if(group_id.isNull() || msg_id.isNull()) if(group_id.isNull() || msg_id.isNull())
return nullptr; return nullptr;
RsGxsMsgMetaData* msgMeta = nullptr; std::shared_ptr<RsGxsMsgMetaData> msgMeta;
if(use_cache) if(use_cache)
msgMeta = mMsgMetaDataCache[group_id].getOrCreateMeta(msg_id); msgMeta = mMsgMetaDataCache[group_id].getOrCreateMeta(msg_id);
else else
msgMeta = new RsGxsMsgMetaData(); msgMeta = std::make_shared<RsGxsMsgMetaData>();
if(!msgMeta->mGroupId.isNull()) // we cannot do that because the cursor needs to advance. Is there a method to skip some data in the db? if(!msgMeta->mGroupId.isNull()) // we cannot do that because the cursor needs to advance. Is there a method to skip some data in the db?
return msgMeta; return msgMeta;
@ -712,8 +707,8 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset
if(ok) if(ok)
return msgMeta; return msgMeta;
else if(!use_cache) else
delete msgMeta; return nullptr;
return NULL; return NULL;
} }
@ -842,8 +837,9 @@ int RsDataService::storeMessage(const std::list<RsNxsMsg*>& msg)
// This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded. // This is needed so that mLastPost is correctly updated in the group meta when it is re-loaded.
mGrpMetaDataCache.clear(msgMetaPtr->mGroupId);
mMsgMetaDataCache[msgMetaPtr->mGroupId].updateMeta(msgMetaPtr->mMsgId,*msgMetaPtr); mMsgMetaDataCache[msgMetaPtr->mGroupId].updateMeta(msgMetaPtr->mMsgId,*msgMetaPtr);
delete *mit;
} }
// finish transaction // finish transaction
@ -944,6 +940,8 @@ int RsDataService::storeGroup(const std::list<RsNxsGrp*>& grp)
std::cerr << "\t For GroupId: " << grpMetaPtr->mGroupId.toStdString(); std::cerr << "\t For GroupId: " << grpMetaPtr->mGroupId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
} }
delete *sit;
} }
// finish transaction // finish transaction
bool ret = mDb->commitTransaction(); bool ret = mDb->commitTransaction();
@ -1020,6 +1018,8 @@ int RsDataService::updateGroup(const std::list<RsNxsGrp *> &grp)
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv); mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
mGrpMetaDataCache.updateMeta(grpMetaPtr->mGroupId,*grpMetaPtr); mGrpMetaDataCache.updateMeta(grpMetaPtr->mGroupId,*grpMetaPtr);
delete *sit;
} }
// finish transaction // finish transaction
bool ret = mDb->commitTransaction(); bool ret = mDb->commitTransaction();
@ -1138,8 +1138,8 @@ int RsDataService::retrieveNxsGrps(std::map<RsGxsGroupId, RsNxsGrp *> &grp, bool
return 1; return 1;
} }
void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset){ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>& grps, int metaOffset)
{
if(c){ if(c){
bool valid = c->moveToFirst(); bool valid = c->moveToFirst();
@ -1150,7 +1150,7 @@ void RsDataService::locked_retrieveGroups(RetroCursor* c, std::vector<RsNxsGrp*>
if(g) if(g)
{ {
if (metaOffset) if (metaOffset)
g->metaData = locked_getGrpMeta(*c, metaOffset,false); g->metaData = new RsGxsGrpMetaData(*locked_getGrpMeta(*c, metaOffset,true));
else else
g->metaData = nullptr; g->metaData = nullptr;
@ -1238,7 +1238,7 @@ void RsDataService::locked_retrieveMessages(RetroCursor *c, std::vector<RsNxsMsg
if(m){ if(m){
if (metaOffset) if (metaOffset)
m->metaData = locked_getMsgMeta(*c, metaOffset,false); m->metaData = new RsGxsMsgMetaData(*locked_getMsgMeta(*c, metaOffset,false));
else else
m->metaData = nullptr; m->metaData = nullptr;
@ -1297,7 +1297,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
{ {
const RsGxsMessageId& msgId = *sit; const RsGxsMessageId& msgId = *sit;
RsGxsMsgMetaData *meta = cache.getMeta(msgId); auto meta = cache.getMeta(msgId);
if(meta) if(meta)
metaSet.push_back(meta); metaSet.push_back(meta);
@ -1306,7 +1306,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", ""); RetroCursor* c = mDb->sqlQuery(MSG_TABLE_NAME, mMsgMetaColumns, KEY_GRP_ID+ "='" + grpId.toStdString() + "' AND " + KEY_MSG_ID + "='" + msgId.toStdString() + "'", "");
c->moveToFirst(); c->moveToFirst();
RsGxsMsgMetaData* meta = locked_getMsgMeta(*c, 0,true); auto meta = locked_getMsgMeta(*c, 0,true);
if(meta) if(meta)
metaSet.push_back(meta); metaSet.push_back(meta);
@ -1328,7 +1328,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
return 1; return 1;
} }
void RsDataService::locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId,RsGxsGrpMetaData *>& grpMeta) void RsDataService::locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId,std::shared_ptr<RsGxsGrpMetaData> >& grpMeta)
{ {
if(!c) if(!c)
{ {
@ -1340,15 +1340,16 @@ void RsDataService::locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGro
while(valid) while(valid)
{ {
RsGxsGrpMetaData* m = locked_getGrpMeta(*c, 0,true); auto m = locked_getGrpMeta(*c, 0,true);
if(m) if(m != nullptr)
grpMeta[m->mGroupId] = m; grpMeta[m->mGroupId] = m;
valid = c->moveToNext(); valid = c->moveToNext();
} }
} }
void RsDataService::locked_retrieveMsgMetaList(RetroCursor *c, std::vector<const RsGxsMsgMetaData *>& msgMeta)
void RsDataService::locked_retrieveMsgMetaList(RetroCursor *c, std::vector<std::shared_ptr<RsGxsMsgMetaData> >& msgMeta)
{ {
if(!c) if(!c)
{ {
@ -1357,17 +1358,18 @@ void RsDataService::locked_retrieveMsgMetaList(RetroCursor *c, std::vector<const
} }
bool valid = c->moveToFirst(); bool valid = c->moveToFirst();
while(valid){ while(valid)
const RsGxsMsgMetaData* m = locked_getMsgMeta(*c, 0,true); {
auto m = locked_getMsgMeta(*c, 0,true);
if(m != NULL) if(m != nullptr)
msgMeta.push_back(m); msgMeta.push_back(m);
valid = c->moveToNext(); valid = c->moveToNext();
} }
} }
int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<RsGxsGrpMetaData> >& grp)
{ {
#ifdef RS_DATA_SERVICE_DEBUG #ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "RsDataService::retrieveGxsGrpMetaData()"; std::cerr << "RsDataService::retrieveGxsGrpMetaData()";
@ -1412,33 +1414,13 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
resultCount += grp.size(); resultCount += grp.size();
#endif #endif
// if(c)
// {
// bool valid = c->moveToFirst();
//
// while(valid)
// {
// RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
//
// if(g)
// {
// grp[g->mGroupId] = g;
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// std::cerr << (void *)this << " " << mDbName << ": Retrieving (all) Grp metadata grpId=" << g->mGroupId << std::endl;
//#endif
// }
// valid = c->moveToNext();
//
// }
// delete c;
// }
} }
} }
else else
{ {
for(auto mit(grp.begin()); mit != grp.end(); ++mit) for(auto mit(grp.begin()); mit != grp.end(); ++mit)
{ {
RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ; auto meta = mGrpMetaDataCache.getMeta(mit->first) ;
if(meta) if(meta)
mit->second = meta; mit->second = meta;
@ -1452,7 +1434,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", ""); RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, mGrpMetaColumns, "grpId='" + grpId.toStdString() + "'", "");
c->moveToFirst(); c->moveToFirst();
RsGxsGrpMetaData* meta = locked_getGrpMeta(*c, 0,true); auto meta = locked_getGrpMeta(*c, 0,true);
if(meta) if(meta)
mit->second = meta; mit->second = meta;
@ -1463,33 +1445,6 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
delete c; delete c;
// if(c)
// {
// bool valid = c->moveToFirst();
//
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// if(!valid)
// std::cerr << " Empty query! GrpId " << grpId << " is not in database" << std::endl;
//#endif
// while(valid)
// {
// RsGxsGrpMetaData* g = locked_getGrpMeta(*c, 0,true);
//
// if(g)
// {
// grp[g->mGroupId] = g;
//#ifdef RS_DATA_SERVICE_DEBUG_CACHE
// std::cerr << ". Got it. Updating cache." << std::endl;
//#endif
// }
// valid = c->moveToNext();
//
//#ifdef RS_DATA_SERVICE_DEBUG_TIME
// ++resultCount;
//#endif
// }
// delete c;
// }
#ifdef RS_DATA_SERVICE_DEBUG_CACHE #ifdef RS_DATA_SERVICE_DEBUG_CACHE
else else
std::cerr << ". not found!" << std::endl; std::cerr << ". not found!" << std::endl;

View File

@ -38,35 +38,29 @@ public:
template<class ID, class MetaDataClass> class t_MetaDataCache template<class ID, class MetaDataClass> class t_MetaDataCache
{ {
public: public:
t_MetaDataCache() : mCache_ContainsAllMetas(false) {} t_MetaDataCache()
virtual ~t_MetaDataCache() : mCache_ContainsAllMetas(false)
{ {}
for(auto it: mMetas) virtual ~t_MetaDataCache() = default;
delete it.second;
for(auto it: mOldCachedItems)
delete it.second;
}
bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; } bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; }
void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; } void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; }
void getFullMetaList(std::map<ID,MetaDataClass*>& mp) const { mp = mMetas ; } void getFullMetaList(std::map<ID,std::shared_ptr<MetaDataClass> >& mp) const { mp = mMetas ; }
void getFullMetaList(std::vector<const MetaDataClass*>& mp) const { for(auto& m:mMetas) mp.push_back(m.second) ; } void getFullMetaList(std::vector<std::shared_ptr<MetaDataClass> >& mp) const { for(auto& m:mMetas) mp.push_back(m.second) ; }
MetaDataClass *getMeta(const ID& id) std::shared_ptr<MetaDataClass> getMeta(const ID& id)
{ {
auto itt = mMetas.find(id); auto itt = mMetas.find(id);
if(itt != mMetas.end()) if(itt != mMetas.end())
return itt->second ; return itt->second ;
else else
return NULL; return nullptr;
} }
MetaDataClass *getOrCreateMeta(const ID& id) std::shared_ptr<MetaDataClass> getOrCreateMeta(const ID& id)
{ {
MetaDataClass *meta = nullptr;
auto it = mMetas.find(id) ; auto it = mMetas.find(id) ;
if(it != mMetas.end()) if(it != mMetas.end())
@ -74,18 +68,15 @@ public:
#ifdef RS_DATA_SERVICE_DEBUG #ifdef RS_DATA_SERVICE_DEBUG
RsDbg() << __PRETTY_FUNCTION__ << ": getting group meta " << grpId << " from cache." << std::endl; RsDbg() << __PRETTY_FUNCTION__ << ": getting group meta " << grpId << " from cache." << std::endl;
#endif #endif
meta = it->second ; return it->second ;
} }
else else
{ {
#ifdef RS_DATA_SERVICE_DEBUG #ifdef RS_DATA_SERVICE_DEBUG
RsDbg() << __PRETTY_FUNCTION__ << ": group meta " << grpId << " not in cache. Loading it from DB..." << std::endl; RsDbg() << __PRETTY_FUNCTION__ << ": group meta " << grpId << " not in cache. Loading it from DB..." << std::endl;
#endif #endif
meta = new MetaDataClass(); return (mMetas[id] = std::make_shared<MetaDataClass>());
mMetas[id] = meta ;
} }
return meta;
} }
void updateMeta(const ID& id,const MetaDataClass& meta) void updateMeta(const ID& id,const MetaDataClass& meta)
@ -95,7 +86,7 @@ public:
if(it != mMetas.end()) if(it != mMetas.end())
*(it->second) = meta ; *(it->second) = meta ;
else else
mMetas[id] = new MetaDataClass(meta) ; mMetas[id] = std::make_shared<MetaDataClass>();
} }
void clear(const ID& id) void clear(const ID& id)
@ -114,39 +105,21 @@ public:
std::cerr << "(II) moving database cache entry " << (void*)(*it).second << " to dead list." << std::endl; std::cerr << "(II) moving database cache entry " << (void*)(*it).second << " to dead list." << std::endl;
#endif #endif
mOldCachedItems.push_back(std::make_pair(now,it->second)) ;
mMetas.erase(it) ; mMetas.erase(it) ;
mCache_ContainsAllMetas = false; mCache_ContainsAllMetas = false;
} }
// We also take that opportunity to delete old entries.
auto it2(mOldCachedItems.begin());
while(it2!=mOldCachedItems.end() && (*it2).first + CACHE_ENTRY_GRACE_PERIOD < now)
{
#ifdef RS_DATA_SERVICE_DEBUG
std::cerr << "(II) deleting old GXS database cache entry " << (void*)(*it2).second << ", " << now - (*it2).first << " seconds old." << std::endl;
#endif
delete (*it2).second ;
it2 = mOldCachedItems.erase(it2) ;
}
} }
void debug_computeSize(uint32_t& nb_items, uint32_t& nb_items_on_deadlist, uint64_t& total_size,uint64_t& total_size_of_deadlist) const void debug_computeSize(uint32_t& nb_items, uint32_t& nb_items_on_deadlist, uint64_t& total_size,uint64_t& total_size_of_deadlist) const
{ {
nb_items = mMetas.size(); nb_items = mMetas.size();
nb_items_on_deadlist = mOldCachedItems.size();
total_size = 0; total_size = 0;
total_size_of_deadlist = 0; total_size_of_deadlist = 0;
for(auto it:mMetas) total_size += it.second->serial_size(); for(auto it:mMetas) total_size += it.second->serial_size();
for(auto it:mOldCachedItems) total_size_of_deadlist += it.second->serial_size();
} }
private: private:
std::map<ID,MetaDataClass*> mMetas; std::map<ID,std::shared_ptr<MetaDataClass> > mMetas;
std::list<std::pair<rstime_t,MetaDataClass*> > mOldCachedItems ; // dead list, where items get deleted after being unused for a while. This is due to not using smart ptrs.
static const uint32_t CACHE_ENTRY_GRACE_PERIOD = 600 ; // Unused items are deleted 10 minutes after last usage. static const uint32_t CACHE_ENTRY_GRACE_PERIOD = 600 ; // Unused items are deleted 10 minutes after last usage.
@ -189,7 +162,7 @@ public:
* @param cache whether to store retrieval in mem for faster later retrieval * @param cache whether to store retrieval in mem for faster later retrieval
* @return error code * @return error code
*/ */
int retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp); int retrieveGxsGrpMetaData(std::map<RsGxsGroupId, std::shared_ptr<RsGxsGrpMetaData> > &grp);
/*! /*!
* Retrieves meta data of all groups stored (most current versions only) * Retrieves meta data of all groups stored (most current versions only)
@ -316,26 +289,26 @@ private:
* @param c cursor to result set * @param c cursor to result set
* @param msgMeta message metadata retrieved from cursor are stored here * @param msgMeta message metadata retrieved from cursor are stored here
*/ */
void locked_retrieveMsgMetaList(RetroCursor* c, std::vector<const RsGxsMsgMetaData*>& msgMeta); void locked_retrieveMsgMetaList(RetroCursor* c, std::vector<std::shared_ptr<RsGxsMsgMetaData> > &msgMeta);
/*! /*!
* Retrieves all the grp meta results from a cursor * Retrieves all the grp meta results from a cursor
* @param c cursor to result set * @param c cursor to result set
* @param grpMeta group metadata retrieved from cursor are stored here * @param grpMeta group metadata retrieved from cursor are stored here
*/ */
void locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId,RsGxsGrpMetaData *>& grpMeta); void locked_retrieveGrpMetaList(RetroCursor *c, std::map<RsGxsGroupId, std::shared_ptr<RsGxsGrpMetaData> > &grpMeta);
/*! /*!
* extracts a msg meta item from a cursor at its * extracts a msg meta item from a cursor at its
* current position * current position
*/ */
RsGxsMsgMetaData* locked_getMsgMeta(RetroCursor& c, int colOffset, bool use_cache); std::shared_ptr<RsGxsMsgMetaData> locked_getMsgMeta(RetroCursor& c, int colOffset, bool use_cache);
/*! /*!
* extracts a grp meta item from a cursor at its * extracts a grp meta item from a cursor at its
* current position * current position
*/ */
RsGxsGrpMetaData* locked_getGrpMeta(RetroCursor& c, int colOffset, bool use_cache); std::shared_ptr<RsGxsGrpMetaData> locked_getGrpMeta(RetroCursor& c, int colOffset, bool use_cache);
/*! /*!
* extracts a msg item from a cursor at its * extracts a msg item from a cursor at its

View File

@ -19,8 +19,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef RSGDS_H
#define RSGDS_H #pragma once
#include <set> #include <set>
#include <map> #include <map>
@ -56,8 +56,6 @@ struct MsgLocMetaData {
ContentValue val; ContentValue val;
}; };
typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap;
/*! /*!
* This allows modification of local * This allows modification of local
* meta data items of a group * meta data items of a group
@ -166,7 +164,7 @@ public:
* , if grpId is failed to be retrieved it will be erased from map * , if grpId is failed to be retrieved it will be erased from map
* @return error code * @return error code
*/ */
virtual int retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) = 0; virtual int retrieveGxsGrpMetaData(std::map<RsGxsGroupId,std::shared_ptr<RsGxsGrpMetaData> >& grp) = 0;
/*! /*!
* Retrieves meta data of all groups stored (most current versions only) * Retrieves meta data of all groups stored (most current versions only)
@ -274,8 +272,3 @@ public:
virtual bool validSize(RsNxsGrp* grp) const = 0 ; virtual bool validSize(RsNxsGrp* grp) const = 0 ;
}; };
#endif // RSGDS_H

View File

@ -809,12 +809,13 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
else else
{ {
// get publish key // get publish key
const RsGxsGrpMetaData* grpMeta = metaMap[id]; const auto& grpMeta = metaMap[id];
uint32_t metaDataLen = meta.serial_size(); uint32_t metaDataLen = meta.serial_size();
uint32_t allMsgDataLen = metaDataLen + msg->msg.bin_len; uint32_t allMsgDataLen = metaDataLen + msg->msg.bin_len;
char* metaData = new char[metaDataLen];
char* allMsgData = new char[allMsgDataLen]; // msgData + metaData RsTemporaryMemory metaData(metaDataLen);
RsTemporaryMemory allMsgData(allMsgDataLen);
meta.serialise(metaData, &metaDataLen); meta.serialise(metaData, &metaDataLen);
@ -839,9 +840,6 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
// assign msg id to msg meta // assign msg id to msg meta
msg->metaData->mMsgId = msg->msgId; msg->metaData->mMsgId = msg->msgId;
delete[] metaData;
delete[] allMsgData;
} }
if(ret_val == SIGN_FAIL) if(ret_val == SIGN_FAIL)
@ -1299,16 +1297,14 @@ bool RsGenExchange::getPublishedGroupMeta(const uint32_t& token,RsGroupMetaData&
bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo) bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
{ {
std::list<const RsGxsGrpMetaData*> metaL; std::list<std::shared_ptr<RsGxsGrpMetaData> > metaL;
bool ok = mDataAccess->getGroupSummary(token, metaL); bool ok = mDataAccess->getGroupSummary(token, metaL);
RsGroupMetaData m;
for( auto lit = metaL.begin(); lit != metaL.end(); ++lit) for( auto lit = metaL.begin(); lit != metaL.end(); ++lit)
{ {
const RsGxsGrpMetaData& gMeta = *(*lit); const RsGxsGrpMetaData& gMeta = *(*lit);
m = gMeta; RsGroupMetaData m(gMeta);
RsGroupNetworkStats sts ; RsGroupNetworkStats sts ;
if(mNetService != NULL && mNetService->getGroupNetworkStats(gMeta.mGroupId,sts)) if(mNetService != NULL && mNetService->getGroupNetworkStats(gMeta.mGroupId,sts))
@ -1341,24 +1337,15 @@ bool RsGenExchange::getMsgMeta(const uint32_t &token,
GxsMsgMetaResult result; GxsMsgMetaResult result;
bool ok = mDataAccess->getMsgSummary(token, result); bool ok = mDataAccess->getMsgSummary(token, result);
GxsMsgMetaResult::iterator mit = result.begin(); for(auto mit=result.begin(); mit != result.end(); ++mit)
for(; mit != result.end(); ++mit)
{ {
std::vector<const RsGxsMsgMetaData*>& metaV = mit->second; auto& metaV = mit->second;
std::vector<RsMsgMetaData>& msgInfoV = msgInfo[mit->first]; std::vector<RsMsgMetaData>& msgInfoV = msgInfo[mit->first];
std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin();
RsMsgMetaData meta; RsMsgMetaData meta;
for(; vit != metaV.end(); ++vit) for(auto vit=metaV.begin(); vit != metaV.end(); ++vit)
{ msgInfoV.push_back(RsMsgMetaData(*(*vit)));
const RsGxsMsgMetaData& m = *(*vit);
meta = m;
msgInfoV.push_back(meta);
//delete *vit;
}
metaV.clear();
} }
return ok; return ok;
@ -1373,20 +1360,12 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
for(; mit != result.end(); ++mit) for(; mit != result.end(); ++mit)
{ {
std::vector<const RsGxsMsgMetaData*>& metaV = mit->second; auto& metaV = mit->second;
std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first]; std::vector<RsMsgMetaData>& msgInfoV = msgMeta[mit->first];
std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin(); for(auto vit=metaV.begin(); vit != metaV.end(); ++vit)
RsMsgMetaData meta; msgInfoV.push_back(RsMsgMetaData(*(*vit)));
for(; vit != metaV.end(); ++vit)
{
const RsGxsMsgMetaData& m = *(*vit);
meta = m;
msgInfoV.push_back(meta);
//delete *vit;
}
metaV.clear();
} }
return ok; return ok;
@ -2107,15 +2086,14 @@ void RsGenExchange::processMsgMetaChanges()
if(mit != result.end()) if(mit != result.end())
{ {
std::vector<const RsGxsMsgMetaData*>& msgMetaV = mit->second; const auto& msgMetaV = mit->second;
if(!msgMetaV.empty()) if(!msgMetaV.empty())
{ {
const RsGxsMsgMetaData* meta = *(msgMetaV.begin()); const auto& meta = *(msgMetaV.begin());
value = (meta->mMsgStatus & ~mask) | (mask & value); value = (meta->mMsgStatus & ~mask) | (mask & value);
changed = (static_cast<int64_t>(meta->mMsgStatus) != value); changed = (static_cast<int64_t>(meta->mMsgStatus) != value);
m.val.put(RsGeneralDataService::MSG_META_STATUS, value); m.val.put(RsGeneralDataService::MSG_META_STATUS, value);
//delete meta;
ok = true; ok = true;
} }
} }
@ -2210,16 +2188,16 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
// first find out which mask is involved // first find out which mask is involved
int32_t value, mask, currValue; int32_t value, mask, currValue;
std::string key; std::string key;
const RsGxsGrpMetaData* grpMeta = NULL; std::shared_ptr<RsGxsGrpMetaData> grpMeta;
bool ok = false; bool ok = false;
RsGxsGrpMetaTemporaryMap grpMetaMap; RsGxsGrpMetaTemporaryMap grpMetaMap;
std::map<RsGxsGroupId, RsGxsGrpMetaData* >::iterator mit;
grpMetaMap.insert(std::make_pair(grpId, (RsGxsGrpMetaData*)(NULL))); grpMetaMap.insert(std::make_pair(grpId, (RsGxsGrpMetaData*)(NULL)));
mDataStore->retrieveGxsGrpMetaData(grpMetaMap); mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
auto mit = grpMetaMap.find(grpId);
if((mit = grpMetaMap.find(grpId)) != grpMetaMap.end()) if(mit != grpMetaMap.end())
{ {
grpMeta = mit->second; grpMeta = mit->second;
@ -2501,10 +2479,11 @@ void RsGenExchange::processGroupUpdatePublish()
{ {
GroupUpdatePublish& gup = *vit; GroupUpdatePublish& gup = *vit;
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId; const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.find(groupId); auto mit = grpMeta.find(groupId);
const RsGxsGrpMetaData* meta = NULL; std::shared_ptr<RsGxsGrpMetaData> meta;
if(mit == grpMeta.end() || mit->second == NULL)
if(mit == grpMeta.end() || mit->second == nullptr)
{ {
std::cerr << "Error! could not find meta of old group to update!" << std::endl; std::cerr << "Error! could not find meta of old group to update!" << std::endl;
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED); mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);
@ -2960,7 +2939,7 @@ bool RsGenExchange::getGroupKeys(const RsGxsGroupId &grpId, RsTlvSecurityKeySet
if(grpMeta.empty()) if(grpMeta.empty())
return false; return false;
const RsGxsGrpMetaData* meta = grpMeta[grpId]; const auto& meta = grpMeta[grpId];
if(meta == NULL) if(meta == NULL)
return false; return false;
@ -3086,7 +3065,7 @@ void RsGenExchange::processRecvdMessages()
#ifdef GEN_EXCH_DEBUG #ifdef GEN_EXCH_DEBUG
std::cerr << " deserialised info: grp id=" << msg->grpId << ", msg id=" << msg->msgId ; std::cerr << " deserialised info: grp id=" << msg->grpId << ", msg id=" << msg->msgId ;
#endif #endif
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMetas.find(msg->grpId); auto mit = grpMetas.find(msg->grpId);
#ifdef GEN_EXCH_DEBUG #ifdef GEN_EXCH_DEBUG
std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl; std::cerr << " msg info : grp id=" << msg->grpId << ", msg id=" << msg->msgId << std::endl;
@ -3100,7 +3079,7 @@ void RsGenExchange::processRecvdMessages()
continue ; continue ;
} }
const RsGxsGrpMetaData *grpMeta = mit->second; const auto& grpMeta = mit->second;
RsTlvSecurityKeySet keys = grpMeta->keys ; RsTlvSecurityKeySet keys = grpMeta->keys ;
GxsSecurity::createPublicKeysFromPrivateKeys(keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing. GxsSecurity::createPublicKeysFromPrivateKeys(keys); // make sure we have the public keys that correspond to the private ones, as it happens. Most of the time this call does nothing.

View File

@ -29,8 +29,8 @@
/* data types used throughout Gxs from netservice to genexchange */ /* data types used throughout Gxs from netservice to genexchange */
typedef std::map<RsGxsGroupId, std::vector<const RsGxsMsgMetaData*> > GxsMsgMetaResult; typedef std::map<RsGxsGroupId, std::vector<std::shared_ptr<RsGxsMsgMetaData> > > GxsMsgMetaResult;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<const RsGxsMsgMetaData*> > MsgRelatedMetaResult; typedef std::map<RsGxsGrpMsgIdPair, std::vector<std::shared_ptr<RsGxsMsgMetaData> > > MsgRelatedMetaResult;
// Default values that are used throughout GXS code // Default values that are used throughout GXS code

View File

@ -373,7 +373,7 @@ bool RsGxsDataAccess::locked_clearRequest(const uint32_t& token)
return true; return true;
} }
bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<const RsGxsGrpMetaData*>& groupInfo) bool RsGxsDataAccess::getGroupSummary(const uint32_t& token, std::list<std::shared_ptr<RsGxsGrpMetaData> >& groupInfo)
{ {
RS_STACK_MUTEX(mDataMutex); RS_STACK_MUTEX(mDataMutex);
@ -908,23 +908,21 @@ bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
if(grpIdsOut.empty()) if(grpIdsOut.empty())
return true; return true;
std::list<RsGxsGroupId>::const_iterator lit = grpIdsOut.begin(); for(auto lit = grpIdsOut.begin();lit != grpIdsOut.end(); ++lit)
for(; lit != grpIdsOut.end(); ++lit)
grpMeta[*lit] = nullptr; grpMeta[*lit] = nullptr;
mDataStore->retrieveGxsGrpMetaData(grpMeta); mDataStore->retrieveGxsGrpMetaData(grpMeta);
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin(); for(auto mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
for(; mit != grpMeta.end(); ++mit)
req->mGroupMetaData.push_back(mit->second); req->mGroupMetaData.push_back(mit->second);
return true; return true;
} }
bool RsGxsDataAccess::getGroupList(GroupIdReq* req) bool RsGxsDataAccess::getGroupList(GroupIdReq* req)
{ return getGroupList(req->mGroupIds, req->Options, req->mGroupIdResult); } {
return getGroupList(req->mGroupIds, req->Options, req->mGroupIdResult);
}
bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, const RsTokReqOptions& opts, std::list<RsGxsGroupId>& grpIdsOut) bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, const RsTokReqOptions& opts, std::list<RsGxsGroupId>& grpIdsOut)
{ {
@ -1030,7 +1028,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
//auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls //auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls
std::vector<const RsGxsMsgMetaData*>& metaV = meta_it->second; auto& metaV = meta_it->second;
if (onlyLatestMsgs) // if we only consider latest messages, we need to first filter out messages with "children" if (onlyLatestMsgs) // if we only consider latest messages, we need to first filter out messages with "children"
{ {
@ -1124,7 +1122,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(uint32_t i=0;i<metaV.size();++i) for(uint32_t i=0;i<metaV.size();++i)
if(metaV[i] != nullptr) if(metaV[i] != nullptr)
{ {
const RsGxsMsgMetaData* msgMeta = metaV[i]; const auto& msgMeta = metaV[i];
bool add = false; bool add = false;
/* if we are grabbing thread Head... then parentId == empty. */ /* if we are grabbing thread Head... then parentId == empty. */
@ -1291,8 +1289,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
GxsMsgReq msgIds; GxsMsgReq msgIds;
msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>())); msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set<RsGxsMessageId>()));
mDataStore->retrieveGxsMsgMetaData(msgIds, result); mDataStore->retrieveGxsMsgMetaData(msgIds, result);
std::vector<const RsGxsMsgMetaData*>& metaV = result[grpMsgIdPair.first]; auto& metaV = result[grpMsgIdPair.first];
std::vector<const RsGxsMsgMetaData*>::iterator vit_meta;
// msg id to relate to // msg id to relate to
const RsGxsMessageId& msgId = grpMsgIdPair.second; const RsGxsMessageId& msgId = grpMsgIdPair.second;
@ -1300,17 +1297,13 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
std::set<RsGxsMessageId> outMsgIds; std::set<RsGxsMessageId> outMsgIds;
const RsGxsMsgMetaData* origMeta = nullptr; std::shared_ptr<RsGxsMsgMetaData> origMeta;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(auto vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
if(msgId == (*vit_meta)->mMsgId)
{ {
const RsGxsMsgMetaData* meta = *vit_meta; origMeta = *vit_meta;
if(msgId == meta->mMsgId)
{
origMeta = meta;
break; break;
}
} }
if(!origMeta) if(!origMeta)
@ -1320,7 +1313,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
} }
const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId; const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId;
std::map<RsGxsMessageId, const RsGxsMsgMetaData*>& metaMap = filterMap[grpId]; auto& metaMap = filterMap[grpId];
if (onlyLatestMsgs) if (onlyLatestMsgs)
{ {
@ -1329,10 +1322,10 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
// RUN THROUGH ALL MSGS... in map origId -> TS. // RUN THROUGH ALL MSGS... in map origId -> TS.
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> > origMsgTs; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> > origMsgTs;
std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> >::iterator oit; std::map<RsGxsMessageId, std::pair<RsGxsMessageId, rstime_t> >::iterator oit;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{
const RsGxsMsgMetaData* meta = *vit_meta; for(auto vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
{
auto meta = *vit_meta;
// skip msgs that aren't children. // skip msgs that aren't children.
if (onlyChildMsgs) if (onlyChildMsgs)
@ -1400,37 +1393,30 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
/* first guess is potentially better than Orig (can't be worse!) */ /* first guess is potentially better than Orig (can't be worse!) */
rstime_t latestTs = 0; rstime_t latestTs = 0;
RsGxsMessageId latestMsgId; RsGxsMessageId latestMsgId;
const RsGxsMsgMetaData* latestMeta=nullptr; std::shared_ptr<RsGxsMsgMetaData> latestMeta;
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(auto vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
if ((*vit_meta)->mOrigMsgId == origMsgId)
{ {
const RsGxsMsgMetaData* meta = *vit_meta; if ((*vit_meta)->mPublishTs > latestTs)
{
latestTs = (*vit_meta)->mPublishTs;
latestMsgId = (*vit_meta)->mMsgId;
latestMeta = (*vit_meta);
}
}
if (meta->mOrigMsgId == origMsgId)
{
if (meta->mPublishTs > latestTs)
{
latestTs = meta->mPublishTs;
latestMsgId = meta->mMsgId;
latestMeta = meta;
}
}
}
outMsgIds.insert(latestMsgId); outMsgIds.insert(latestMsgId);
metaMap.insert(std::make_pair(latestMsgId, latestMeta)); metaMap.insert(std::make_pair(latestMsgId, latestMeta));
} }
} }
else if (onlyAllVersions) else if (onlyAllVersions)
{ {
for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) for(auto vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta)
if ((*vit_meta)->mOrigMsgId == origMsgId)
{ {
const RsGxsMsgMetaData* meta = *vit_meta; outMsgIds.insert((*vit_meta)->mMsgId);
metaMap.insert(std::make_pair((*vit_meta)->mMsgId, (*vit_meta)));
if (meta->mOrigMsgId == origMsgId)
{
outMsgIds.insert(meta->mMsgId);
metaMap.insert(std::make_pair(meta->mMsgId, meta));
}
} }
} }
@ -1495,7 +1481,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
for(uint32_t i = 0; i < msgMetaV.size(); ++i) for(uint32_t i = 0; i < msgMetaV.size(); ++i)
{ {
const RsGxsMsgMetaData* m = msgMetaV[i]; const auto& m = msgMetaV[i];
req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size(); req->mGroupStatistic.mTotalSizeOfMsgs += m->mMsgSize + m->serial_size();
if(obsolete_msgs.find(m->mMsgId) != obsolete_msgs.end()) // skip obsolete messages. if(obsolete_msgs.find(m->mMsgId) != obsolete_msgs.end()) // skip obsolete messages.
@ -1504,24 +1490,19 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
if (IS_MSG_NEW(m->mMsgStatus)) if (IS_MSG_NEW(m->mMsgStatus))
{ {
if (m->mParentId.isNull()) if (m->mParentId.isNull())
{
++req->mGroupStatistic.mNumThreadMsgsNew; ++req->mGroupStatistic.mNumThreadMsgsNew;
} else { else
++req->mGroupStatistic.mNumChildMsgsNew; ++req->mGroupStatistic.mNumChildMsgsNew;
} }
}
if (IS_MSG_UNREAD(m->mMsgStatus)) if (IS_MSG_UNREAD(m->mMsgStatus))
{ {
if (m->mParentId.isNull()) if (m->mParentId.isNull())
{
++req->mGroupStatistic.mNumThreadMsgsUnread; ++req->mGroupStatistic.mNumThreadMsgsUnread;
} else { else
++req->mGroupStatistic.mNumChildMsgsUnread; ++req->mGroupStatistic.mNumChildMsgsUnread;
} }
} }
}
//cleanseMsgMetaMap(metaResult);
return true; return true;
} }
@ -1544,7 +1525,7 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
for(auto mit = grpMeta.begin(); mit != grpMeta.end(); ++mit) for(auto mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
{ {
const RsGxsGrpMetaData* m = mit->second; const auto& m = mit->second;
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size(RS_GXS_GRP_META_DATA_CURRENT_API_VERSION); req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size(RS_GXS_GRP_META_DATA_CURRENT_API_VERSION);
if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags)) if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags))
@ -1573,23 +1554,15 @@ bool RsGxsDataAccess::getMsgIdList(MsgIdReq* req)
{ {
GxsMsgMetaResult result; GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result); mDataStore->retrieveGxsMsgMetaData(req->mMsgIds, result);
GxsMsgMetaResult::iterator mit = result.begin(), mit_end = result.end(); for(auto mit = result.begin(); mit != result.end(); ++mit)
for(; mit != mit_end; ++mit)
{ {
const RsGxsGroupId grpId = mit->first; const RsGxsGroupId grpId = mit->first;
std::vector<const RsGxsMsgMetaData*>& metaV = mit->second; auto& metaV = mit->second;
std::vector<const RsGxsMsgMetaData*>::iterator vit = metaV.begin(),
vit_end = metaV.end();
for(; vit != vit_end; ++vit) for(auto vit=metaV.begin(); vit != metaV.end(); ++vit)
{ req->mMsgIdResult[grpId].insert((*vit)->mMsgId);
const RsGxsMsgMetaData* meta = *vit;
req->mMsgIdResult[grpId].insert(meta->mMsgId);
}
} }
GxsMsgReq msgIdOut; GxsMsgReq msgIdOut;
@ -1601,25 +1574,6 @@ bool RsGxsDataAccess::getMsgIdList(MsgIdReq* req)
return true; return true;
} }
// void RsGxsDataAccess::cleanseMsgMetaMap(GxsMsgMetaResult& result)
// {
// GxsMsgMetaResult::iterator mit = result.begin();
//
// for(; mit !=result.end(); ++mit)
// {
//
// std::vector<RsGxsMsgMetaData*>& msgMetaV = mit->second;
// std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetaV.begin();
// for(; vit != msgMetaV.end(); ++vit)
// {
// delete *vit;
// }
// }
//
// result.clear();
// return;
// }
void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokReqOptions& opts, const MsgMetaFilter& msgMetas ) const void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokReqOptions& opts, const MsgMetaFilter& msgMetas ) const
{ {
for( GxsMsgIdResult::iterator grpIt = resultsMap.begin(); grpIt != resultsMap.end(); ++grpIt ) for( GxsMsgIdResult::iterator grpIt = resultsMap.begin(); grpIt != resultsMap.end(); ++grpIt )
@ -1638,16 +1592,13 @@ void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokRe
for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin(); msgIdIt != msgsIdSet.end(); ) for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin(); msgIdIt != msgsIdSet.end(); )
{ {
const RsGxsMessageId& msgId(*msgIdIt); const RsGxsMessageId& msgId(*msgIdIt);
const std::map<RsGxsMessageId, const RsGxsMsgMetaData*>& msgsMetaMap = const auto& msgsMetaMap = cit->second;
cit->second;
bool keep = false; bool keep = false;
std::map<RsGxsMessageId, const RsGxsMsgMetaData*>::const_iterator msgsMetaMapIt; auto msgsMetaMapIt = msgsMetaMap.find(msgId);
if( (msgsMetaMapIt = msgsMetaMap.find(msgId)) != msgsMetaMap.end() ) if( msgsMetaMapIt != msgsMetaMap.end() )
{
keep = checkMsgFilter(opts, msgsMetaMapIt->second); keep = checkMsgFilter(opts, msgsMetaMapIt->second);
}
if(keep) if(keep)
++msgIdIt; ++msgIdIt;
@ -1665,28 +1616,20 @@ void RsGxsDataAccess::filterMsgIdList( GxsMsgIdResult& resultsMap, const RsTokRe
void RsGxsDataAccess::filterGrpList(std::list<RsGxsGroupId> &grpIds, const RsTokReqOptions &opts, const GrpMetaFilter& meta) const void RsGxsDataAccess::filterGrpList(std::list<RsGxsGroupId> &grpIds, const RsTokReqOptions &opts, const GrpMetaFilter& meta) const
{ {
std::list<RsGxsGroupId>::iterator lit = grpIds.begin(); for(auto lit = grpIds.begin(); lit != grpIds.end(); )
for(; lit != grpIds.end(); )
{ {
GrpMetaFilter::const_iterator cit = meta.find(*lit); auto cit = meta.find(*lit);
bool keep = false; bool keep = false;
if(cit != meta.end()) if(cit != meta.end())
{
keep = checkGrpFilter(opts, cit->second); keep = checkGrpFilter(opts, cit->second);
}
if(keep) if(keep)
{
++lit; ++lit;
}else else
{
lit = grpIds.erase(lit); lit = grpIds.erase(lit);
} }
}
} }
@ -1843,7 +1786,7 @@ bool RsGxsDataAccess::disposeOfPublicToken(uint32_t token)
return false; return false;
} }
bool RsGxsDataAccess::checkGrpFilter(const RsTokReqOptions &opts, const RsGxsGrpMetaData *meta) const bool RsGxsDataAccess::checkGrpFilter(const RsTokReqOptions &opts, const std::shared_ptr<RsGxsGrpMetaData>& meta) const
{ {
bool subscribeMatch = false; bool subscribeMatch = false;
@ -1863,8 +1806,7 @@ bool RsGxsDataAccess::checkGrpFilter(const RsTokReqOptions &opts, const RsGxsGrp
return subscribeMatch; return subscribeMatch;
} }
bool RsGxsDataAccess::checkMsgFilter( bool RsGxsDataAccess::checkMsgFilter(const RsTokReqOptions& opts, const std::shared_ptr<RsGxsMsgMetaData> &meta ) const
const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta ) const
{ {
if (opts.mStatusMask) if (opts.mStatusMask)
{ {

View File

@ -28,8 +28,8 @@
#include "rsgds.h" #include "rsgds.h"
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, const RsGxsMsgMetaData*> > MsgMetaFilter; typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, std::shared_ptr<RsGxsMsgMetaData> > > MsgMetaFilter;
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter; typedef std::map< RsGxsGroupId, std::shared_ptr<RsGxsGrpMetaData> > GrpMetaFilter;
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2); bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2);
@ -220,7 +220,7 @@ public:
* @param token request token to be redeemed * @param token request token to be redeemed
* @param groupInfo * @param groupInfo
*/ */
bool getGroupSummary(const uint32_t &token, std::list<const RsGxsGrpMetaData*>& groupInfo); bool getGroupSummary(const uint32_t &token, std::list<std::shared_ptr<RsGxsGrpMetaData> > &groupInfo);
/*! /*!
* *
@ -478,7 +478,7 @@ private:
* @param meta meta containing currently defined options for msg * @param meta meta containing currently defined options for msg
* @return true if msg meta passes all options * @return true if msg meta passes all options
*/ */
bool checkMsgFilter(const RsTokReqOptions& opts, const RsGxsMsgMetaData* meta) const; bool checkMsgFilter(const RsTokReqOptions& opts, const std::shared_ptr<RsGxsMsgMetaData>& meta) const;
/*! /*!
* This applies the options to the meta to find out if the given group satisfies * This applies the options to the meta to find out if the given group satisfies
@ -487,7 +487,7 @@ private:
* @param meta meta containing currently defined options for group * @param meta meta containing currently defined options for group
* @return true if group meta passes all options * @return true if group meta passes all options
*/ */
bool checkGrpFilter(const RsTokReqOptions& opts, const RsGxsGrpMetaData* meta) const; bool checkGrpFilter(const RsTokReqOptions& opts, const std::shared_ptr<RsGxsGrpMetaData> &meta) const;
/*! /*!

View File

@ -637,7 +637,7 @@ void RsGxsNetService::syncWithPeers()
for(RsGxsGrpMetaTemporaryMap::iterator mit = grpMeta.begin(); mit != grpMeta.end(); ++mit) for(RsGxsGrpMetaTemporaryMap::iterator mit = grpMeta.begin(); mit != grpMeta.end(); ++mit)
{ {
RsGxsGrpMetaData* meta = mit->second; const auto& meta = mit->second;
// This was commented out because we want to know how many messages are available for unsubscribed groups. // This was commented out because we want to know how many messages are available for unsubscribed groups.
@ -674,7 +674,7 @@ void RsGxsNetService::syncWithPeers()
RsGxsGrpMetaTemporaryMap::const_iterator mmit = toRequest.begin(); RsGxsGrpMetaTemporaryMap::const_iterator mmit = toRequest.begin();
for(; mmit != toRequest.end(); ++mmit) for(; mmit != toRequest.end(); ++mmit)
{ {
const RsGxsGrpMetaData* meta = mmit->second; const auto& meta = mmit->second;
const RsGxsGroupId& grpId = mmit->first; const RsGxsGroupId& grpId = mmit->first;
RsGxsCircleId encrypt_to_this_circle_id ; RsGxsCircleId encrypt_to_this_circle_id ;
@ -928,7 +928,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
mDataStore->retrieveGxsGrpMetaData(grpMetas); mDataStore->retrieveGxsGrpMetaData(grpMetas);
const RsGxsGrpMetaData* grpMeta = grpMetas[grs->grpId]; const auto& grpMeta = grpMetas[grs->grpId];
if(grpMeta == NULL) if(grpMeta == NULL)
{ {
@ -959,7 +959,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs)
#endif #endif
mDataStore->retrieveGxsMsgMetaData(reqIds, result); mDataStore->retrieveGxsMsgMetaData(reqIds, result);
const std::vector<const RsGxsMsgMetaData*>& vec(result[grs->grpId]) ; const auto& vec(result[grs->grpId]) ;
if(vec.empty()) // that means we don't have any, or there isn't any, but since the default is always 0, no need to send. if(vec.empty()) // that means we don't have any, or there isn't any, but since the default is always 0, no need to send.
return ; return ;
@ -2196,7 +2196,7 @@ void RsGxsNetService::updateServerSyncTS()
RS_STACK_MUTEX(mNxsMutex) ; RS_STACK_MUTEX(mNxsMutex) ;
const RsGxsGrpMetaData* grpMeta = mit->second; const auto& grpMeta = mit->second;
#ifdef TO_REMOVE #ifdef TO_REMOVE
// That accounts for modification of the meta data. // That accounts for modification of the meta data.
@ -2924,7 +2924,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
grpMetaMap[grpId] = NULL; grpMetaMap[grpId] = NULL;
mDataStore->retrieveGxsGrpMetaData(grpMetaMap); mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
const RsGxsGrpMetaData* grpMeta = grpMetaMap[grpId]; const auto& grpMeta = grpMetaMap[grpId];
if(grpMeta == NULL) // this should not happen, but just in case... if(grpMeta == NULL) // this should not happen, but just in case...
{ {
@ -2956,17 +2956,16 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
reqIds[grpId] = std::set<RsGxsMessageId>(); reqIds[grpId] = std::set<RsGxsMessageId>();
GxsMsgMetaResult result; GxsMsgMetaResult result;
mDataStore->retrieveGxsMsgMetaData(reqIds, result); mDataStore->retrieveGxsMsgMetaData(reqIds, result);
std::vector<const RsGxsMsgMetaData*> &msgMetaV = result[grpId]; auto& msgMetaV = result[grpId];
#ifdef NXS_NET_DEBUG_1 #ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << " retrieving grp message list..." << std::endl; GXSNETDEBUG_PG(item->PeerId(),grpId) << " retrieving grp message list..." << std::endl;
GXSNETDEBUG_PG(item->PeerId(),grpId) << " grp locally contains " << msgMetaV.size() << " messsages." << std::endl; GXSNETDEBUG_PG(item->PeerId(),grpId) << " grp locally contains " << msgMetaV.size() << " messsages." << std::endl;
#endif #endif
std::vector<const RsGxsMsgMetaData*>::const_iterator vit = msgMetaV.begin();
std::set<RsGxsMessageId> msgIdSet; std::set<RsGxsMessageId> msgIdSet;
// put ids in set for each searching // put ids in set for each searching
for(; vit != msgMetaV.end(); ++vit) for(auto vit=msgMetaV.begin(); vit != msgMetaV.end(); ++vit)
msgIdSet.insert((*vit)->mMsgId); msgIdSet.insert((*vit)->mMsgId);
msgMetaV.clear(); msgMetaV.clear();
@ -3230,7 +3229,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
RsNxsSyncGrpItem*& grpSyncItem = *llit; RsNxsSyncGrpItem*& grpSyncItem = *llit;
const RsGxsGroupId& grpId = grpSyncItem->grpId; const RsGxsGroupId& grpId = grpSyncItem->grpId;
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator metaIter = grpMetaMap.find(grpId); auto metaIter = grpMetaMap.find(grpId);
bool haveItem = false; bool haveItem = false;
bool latestVersion = false; bool latestVersion = false;
@ -4050,7 +4049,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
for(auto mit = grp.begin(); mit != grp.end(); ++mit) for(auto mit = grp.begin(); mit != grp.end(); ++mit)
{ {
const RsGxsGrpMetaData* grpMeta = mit->second; const auto& grpMeta = mit->second;
// Only send info about subscribed groups. // Only send info about subscribed groups.
@ -4369,7 +4368,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
grpMetas[item->grpId] = NULL; grpMetas[item->grpId] = NULL;
mDataStore->retrieveGxsGrpMetaData(grpMetas); mDataStore->retrieveGxsGrpMetaData(grpMetas);
const RsGxsGrpMetaData* grpMeta = grpMetas[item->grpId]; const auto& grpMeta = grpMetas[item->grpId];
if(grpMeta == NULL) if(grpMeta == NULL)
{ {
@ -4402,7 +4401,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
GxsMsgMetaResult metaResult; GxsMsgMetaResult metaResult;
mDataStore->retrieveGxsMsgMetaData(req, metaResult); mDataStore->retrieveGxsMsgMetaData(req, metaResult);
std::vector<const RsGxsMsgMetaData*>& msgMetas = metaResult[item->grpId]; auto& msgMetas = metaResult[item->grpId];
#ifdef NXS_NET_DEBUG_0 #ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " retrieving message meta data." << std::endl; GXSNETDEBUG_PG(item->PeerId(),item->grpId) << " retrieving message meta data." << std::endl;
@ -4432,7 +4431,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
{ {
for(auto vit = msgMetas.begin();vit != msgMetas.end(); ++vit) for(auto vit = msgMetas.begin();vit != msgMetas.end(); ++vit)
{ {
const RsGxsMsgMetaData* m = *vit; const auto& m = *vit;
// Check reputation // Check reputation
@ -4577,7 +4576,7 @@ void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, c
} }
} }
bool RsGxsNetService::canSendMsgIds(std::vector<const RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId,RsGxsCircleId& should_encrypt_id) bool RsGxsNetService::canSendMsgIds(std::vector<std::shared_ptr<RsGxsMsgMetaData> >& msgMetas, const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId,RsGxsCircleId& should_encrypt_id)
{ {
#ifdef NXS_NET_DEBUG_4 #ifdef NXS_NET_DEBUG_4
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING" << std::endl; GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING" << std::endl;
@ -4929,7 +4928,7 @@ void RsGxsNetService::sharePublishKeysPending()
// Find the publish keys in the retrieved info // Find the publish keys in the retrieved info
const RsGxsGrpMetaData *grpMeta = grpMetaMap[mit->first] ; const auto& grpMeta = grpMetaMap[mit->first] ;
if(grpMeta == NULL) if(grpMeta == NULL)
{ {
@ -5014,7 +5013,7 @@ void RsGxsNetService::handleRecvPublishKeys(RsNxsGroupPublishKeyItem *item)
// update the publish keys in this group meta info // update the publish keys in this group meta info
const RsGxsGrpMetaData *grpMeta = grpMetaMap[item->grpId] ; const auto& grpMeta = grpMetaMap[item->grpId] ;
if (!grpMeta) { if (!grpMeta) {
std::cerr << "(EE) RsGxsNetService::handleRecvPublishKeys() grpMeta not found." << std::endl; std::cerr << "(EE) RsGxsNetService::handleRecvPublishKeys() grpMeta not found." << std::endl;
return ; return ;

View File

@ -399,7 +399,7 @@ private:
* @return false, if you cannot send to this peer, true otherwise * @return false, if you cannot send to this peer, true otherwise
*/ */
bool canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt); bool canSendGrpId(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet, bool &should_encrypt);
bool canSendMsgIds(std::vector<const RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id); bool canSendMsgIds(std::vector<std::shared_ptr<RsGxsMsgMetaData> > &msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId, RsGxsCircleId &should_encrypt_id);
/*! /*!
* \brief checkPermissionsForFriendGroup * \brief checkPermissionsForFriendGroup

View File

@ -156,13 +156,6 @@ GroupDataReq::~GroupDataReq()
rsstd::delete_all(mGroupData.begin(), mGroupData.end()); rsstd::delete_all(mGroupData.begin(), mGroupData.end());
} }
MsgMetaReq::~MsgMetaReq()
{
for (GxsMsgMetaResult::iterator it = mMsgMetaData.begin(); it != mMsgMetaData.end(); ++it) {
rsstd::delete_all(it->second.begin(), it->second.end());
}
}
MsgDataReq::~MsgDataReq() MsgDataReq::~MsgDataReq()
{ {
for (NxsMsgDataResult::iterator it = mMsgData.begin(); it != mMsgData.end(); ++it) { for (NxsMsgDataResult::iterator it = mMsgData.begin(); it != mMsgData.end(); ++it) {
@ -172,13 +165,9 @@ MsgDataReq::~MsgDataReq()
MsgRelatedInfoReq::~MsgRelatedInfoReq() MsgRelatedInfoReq::~MsgRelatedInfoReq()
{ {
for (MsgRelatedMetaResult::iterator metaIt = mMsgMetaResult.begin(); metaIt != mMsgMetaResult.end(); ++metaIt) { for (NxsMsgRelatedDataResult::iterator dataIt = mMsgDataResult.begin(); dataIt != mMsgDataResult.end(); ++dataIt)
rsstd::delete_all(metaIt->second.begin(), metaIt->second.end());
}
for (NxsMsgRelatedDataResult::iterator dataIt = mMsgDataResult.begin(); dataIt != mMsgDataResult.end(); ++dataIt) {
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end()); rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
} }
}
std::ostream& MessageSetFlagReq::print(std::ostream& o) const std::ostream& MessageSetFlagReq::print(std::ostream& o) const
{ {
return o << "[Request type=MsgFlagSet" << "]" ; return o << "[Request type=MsgFlagSet" << "]" ;

View File

@ -55,7 +55,7 @@ public:
virtual std::ostream& print(std::ostream& o) const override; virtual std::ostream& print(std::ostream& o) const override;
public: public:
std::list<RsGxsGroupId> mGroupIds; std::list<RsGxsGroupId> mGroupIds;
std::list<const RsGxsGrpMetaData*> mGroupMetaData; std::list<std::shared_ptr<RsGxsGrpMetaData> > mGroupMetaData;
}; };
class GroupIdReq : public GxsRequest class GroupIdReq : public GxsRequest
@ -98,7 +98,7 @@ public:
class MsgMetaReq : public GxsRequest class MsgMetaReq : public GxsRequest
{ {
public: public:
virtual ~MsgMetaReq(); virtual ~MsgMetaReq() = default;
virtual std::ostream& print(std::ostream& o) const override; virtual std::ostream& print(std::ostream& o) const override;

View File

@ -111,7 +111,7 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check,std::vector<RsGxsGrou
for(; mit != result.end(); ++mit) for(; mit != result.end(); ++mit)
{ {
std::vector<const RsGxsMsgMetaData*>& metaV = mit->second; auto& metaV = mit->second;
// First, make a map of which message have a child message. This allows to only delete messages that dont have child messages. // First, make a map of which message have a child message. This allows to only delete messages that dont have child messages.
// A more accurate way to go would be to compute the time of the oldest message and possibly delete all the branch, but in the // A more accurate way to go would be to compute the time of the oldest message and possibly delete all the branch, but in the
@ -125,7 +125,7 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check,std::vector<RsGxsGrou
for( uint32_t i=0;i<metaV.size();++i) for( uint32_t i=0;i<metaV.size();++i)
{ {
const RsGxsMsgMetaData* meta = metaV[i]; const auto& meta = metaV[i];
bool have_kids = (messages_with_kids.find(meta->mMsgId)!=messages_with_kids.end()); bool have_kids = (messages_with_kids.find(meta->mMsgId)!=messages_with_kids.end());

View File

@ -102,10 +102,10 @@ public:
} }
}; };
typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap; typedef std::map<RsGxsGroupId, std::shared_ptr<RsGxsGrpMetaData> > RsGxsGrpMetaTemporaryMap; // This map doesn't need to delete elements since it holds
typedef t_RsGxsGenericDataTemporaryMap<RsGxsGroupId,RsNxsGrp> RsNxsGrpDataTemporaryMap; typedef std::map<RsGxsGroupId,std::vector<std::shared_ptr<RsGxsMsgMetaData> > > RsGxsMsgMetaTemporaryMap; // shared_ptr's.
typedef t_RsGxsGenericDataTemporaryMapVector<RsGxsMsgMetaData> RsGxsMsgMetaTemporaryMap ; typedef t_RsGxsGenericDataTemporaryMap<RsGxsGroupId,RsNxsGrp> RsNxsGrpDataTemporaryMap;
typedef t_RsGxsGenericDataTemporaryMapVector<RsNxsMsg> RsNxsMsgDataTemporaryMap ; typedef t_RsGxsGenericDataTemporaryMapVector<RsNxsMsg> RsNxsMsgDataTemporaryMap ;
typedef t_RsGxsGenericDataTemporaryList<RsNxsGrp> RsNxsGrpDataTemporaryList ; typedef t_RsGxsGenericDataTemporaryList<RsNxsGrp> RsNxsGrpDataTemporaryList ;

View File

@ -66,6 +66,7 @@ struct RsGroupMetaData : RsSerializable
virtual ~RsGroupMetaData() {} virtual ~RsGroupMetaData() {}
void operator =(const RsGxsGrpMetaData& rGxsMeta); void operator =(const RsGxsGrpMetaData& rGxsMeta);
RsGroupMetaData(const RsGxsGrpMetaData& rGxsMeta) { operator=(rGxsMeta); }
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
std::string mGroupName; std::string mGroupName;
@ -138,7 +139,9 @@ struct RsMsgMetaData : RsSerializable
RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {} RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {}
virtual ~RsMsgMetaData() {} virtual ~RsMsgMetaData() {}
void operator =(const RsGxsMsgMetaData& rGxsMeta); void operator =(const RsGxsMsgMetaData& rGxsMeta);
RsMsgMetaData(const RsGxsMsgMetaData& rGxsMeta) { operator=(rGxsMeta); }
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
RsGxsMessageId mMsgId; RsGxsMessageId mMsgId;