mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 14:42:51 -04:00
Fixed crash after last commit in p3idservice.cc.
Fixed memory leaks and possible crashs in ::getGroupData - p3gxschannels - p3gxscircles - p3gxsforums - p3idservice - p3posted - p3photoservice git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6524 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3730645808
commit
f5218cdfc3
7 changed files with 143 additions and 109 deletions
|
@ -1109,7 +1109,6 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
||||||
|
|
||||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::list<RsNxsGrp*> nxsGrps;
|
std::list<RsNxsGrp*> nxsGrps;
|
||||||
bool ok = mDataAccess->getGroupData(token, nxsGrps);
|
bool ok = mDataAccess->getGroupData(token, nxsGrps);
|
||||||
|
|
||||||
|
@ -1118,7 +1117,7 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
||||||
std::cerr << "RsGenExchange::getGroupData() RsNxsGrp::len: " << nxsGrps.size();
|
std::cerr << "RsGenExchange::getGroupData() RsNxsGrp::len: " << nxsGrps.size();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
for(; lit != nxsGrps.end(); lit++)
|
for(; lit != nxsGrps.end(); lit++)
|
||||||
{
|
{
|
||||||
|
@ -1134,7 +1133,7 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
||||||
if (gItem)
|
if (gItem)
|
||||||
{
|
{
|
||||||
gItem->meta = *((*lit)->metaData);
|
gItem->meta = *((*lit)->metaData);
|
||||||
grpItem.push_back(gItem);
|
grpItem.push_back(gItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1148,46 +1147,42 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
||||||
std::cerr << "RsGenExchange::getGroupData() ERROR deserialising item";
|
std::cerr << "RsGenExchange::getGroupData() ERROR deserialising item";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
delete *lit;
|
delete *lit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGenExchange::getMsgData(const uint32_t &token,
|
bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||||
GxsMsgDataMap &msgItems)
|
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(mGenMtx);
|
||||||
|
NxsMsgDataResult msgResult;
|
||||||
|
bool ok = mDataAccess->getMsgData(token, msgResult);
|
||||||
|
NxsMsgDataResult::iterator mit = msgResult.begin();
|
||||||
|
|
||||||
RsStackMutex stack(mGenMtx);
|
if(ok)
|
||||||
NxsMsgDataResult msgResult;
|
{
|
||||||
bool ok = mDataAccess->getMsgData(token, msgResult);
|
for(; mit != msgResult.end(); mit++)
|
||||||
NxsMsgDataResult::iterator mit = msgResult.begin();
|
{
|
||||||
|
std::vector<RsGxsMsgItem*> gxsMsgItems;
|
||||||
|
const RsGxsGroupId& grpId = mit->first;
|
||||||
|
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
|
||||||
|
std::vector<RsNxsMsg*>::iterator vit = nxsMsgsV.begin();
|
||||||
|
for(; vit != nxsMsgsV.end(); vit++)
|
||||||
|
{
|
||||||
|
RsNxsMsg*& msg = *vit;
|
||||||
|
RsItem* item = NULL;
|
||||||
|
|
||||||
if(ok)
|
if(msg->msg.bin_len != 0)
|
||||||
{
|
item = mSerialiser->deserialise(msg->msg.bin_data, &msg->msg.bin_len);
|
||||||
for(; mit != msgResult.end(); mit++)
|
|
||||||
{
|
|
||||||
std::vector<RsGxsMsgItem*> gxsMsgItems;
|
|
||||||
const RsGxsGroupId& grpId = mit->first;
|
|
||||||
std::vector<RsNxsMsg*>& nxsMsgsV = mit->second;
|
|
||||||
std::vector<RsNxsMsg*>::iterator vit
|
|
||||||
= nxsMsgsV.begin();
|
|
||||||
for(; vit != nxsMsgsV.end(); vit++)
|
|
||||||
{
|
|
||||||
RsNxsMsg*& msg = *vit;
|
|
||||||
RsItem* item = NULL;
|
|
||||||
|
|
||||||
if(msg->msg.bin_len != 0)
|
|
||||||
item = mSerialiser->deserialise(msg->msg.bin_data,
|
|
||||||
&msg->msg.bin_len);
|
|
||||||
|
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
RsGxsMsgItem* mItem = dynamic_cast<RsGxsMsgItem*>(item);
|
RsGxsMsgItem* mItem = dynamic_cast<RsGxsMsgItem*>(item);
|
||||||
if (mItem)
|
if (mItem)
|
||||||
{
|
{
|
||||||
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
|
mItem->meta = *((*vit)->metaData); // get meta info from nxs msg
|
||||||
gxsMsgItems.push_back(mItem);
|
gxsMsgItems.push_back(mItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1205,12 +1200,12 @@ bool RsGenExchange::getMsgData(const uint32_t &token,
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
|
||||||
msgItems[grpId] = gxsMsgItems;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ok;
|
msgItems[grpId] = gxsMsgItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
|
bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
|
||||||
|
|
|
@ -194,6 +194,7 @@ bool p3GxsChannels::getGroupData(const uint32_t &token, std::vector<RsGxsChannel
|
||||||
{
|
{
|
||||||
std::cerr << "p3GxsChannels::getGroupData() ERROR in decode";
|
std::cerr << "p3GxsChannels::getGroupData() ERROR in decode";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
delete(*vit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,11 +370,20 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vector<RsGxsCircleGr
|
||||||
for(; vit != grpData.end(); vit++)
|
for(; vit != grpData.end(); vit++)
|
||||||
{
|
{
|
||||||
RsGxsCircleGroupItem* item = dynamic_cast<RsGxsCircleGroupItem*>(*vit);
|
RsGxsCircleGroupItem* item = dynamic_cast<RsGxsCircleGroupItem*>(*vit);
|
||||||
RsGxsCircleGroup group;
|
if (item)
|
||||||
item->convertTo(group);
|
{
|
||||||
|
RsGxsCircleGroup group;
|
||||||
|
item->convertTo(group);
|
||||||
|
|
||||||
// If its cached - add that info (TODO).
|
// If its cached - add that info (TODO).
|
||||||
groups.push_back(group);
|
groups.push_back(group);
|
||||||
|
delete(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Not a RsGxsCircleGroupItem, deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,19 @@ bool p3GxsForums::getGroupData(const uint32_t &token, std::vector<RsGxsForumGrou
|
||||||
for(; vit != grpData.end(); vit++)
|
for(; vit != grpData.end(); vit++)
|
||||||
{
|
{
|
||||||
RsGxsForumGroupItem* item = dynamic_cast<RsGxsForumGroupItem*>(*vit);
|
RsGxsForumGroupItem* item = dynamic_cast<RsGxsForumGroupItem*>(*vit);
|
||||||
RsGxsForumGroup grp = item->mGroup;
|
if (item)
|
||||||
item->mGroup.mMeta = item->meta;
|
{
|
||||||
grp.mMeta = item->mGroup.mMeta;
|
RsGxsForumGroup grp = item->mGroup;
|
||||||
delete item;
|
item->mGroup.mMeta = item->meta;
|
||||||
groups.push_back(grp);
|
grp.mMeta = item->mGroup.mMeta;
|
||||||
|
delete item;
|
||||||
|
groups.push_back(grp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Not a GxsForumGrpItem, deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|
|
@ -397,53 +397,59 @@ bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep)
|
||||||
|
|
||||||
bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups)
|
bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups)
|
||||||
{
|
{
|
||||||
|
std::vector<RsGxsGrpItem*> grpData;
|
||||||
|
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||||
|
|
||||||
std::vector<RsGxsGrpItem*> grpData;
|
if(ok)
|
||||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
{
|
||||||
|
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||||
|
|
||||||
if(ok)
|
for(; vit != grpData.end(); vit++)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
RsGxsIdGroupItem* item = dynamic_cast<RsGxsIdGroupItem*>(*vit);
|
||||||
|
if (item)
|
||||||
for(; vit != grpData.end(); vit++)
|
|
||||||
{
|
|
||||||
RsGxsIdGroupItem* item = dynamic_cast<RsGxsIdGroupItem*>(*vit);
|
|
||||||
RsGxsIdGroup group = item->group;
|
|
||||||
group.mMeta = item->meta;
|
|
||||||
|
|
||||||
// Decode information from serviceString.
|
|
||||||
SSGxsIdGroup ssdata;
|
|
||||||
if (ssdata.load(group.mMeta.mServiceString))
|
|
||||||
{
|
{
|
||||||
group.mPgpKnown = ssdata.pgp.idKnown;
|
RsGxsIdGroup group = item->group;
|
||||||
group.mPgpId = ssdata.pgp.pgpId;
|
group.mMeta = item->meta;
|
||||||
|
|
||||||
|
// Decode information from serviceString.
|
||||||
|
SSGxsIdGroup ssdata;
|
||||||
|
if (ssdata.load(group.mMeta.mServiceString))
|
||||||
|
{
|
||||||
|
group.mPgpKnown = ssdata.pgp.idKnown;
|
||||||
|
group.mPgpId = ssdata.pgp.pgpId;
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
|
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
|
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\t mGpgId: " << group.mPgpId;
|
std::cerr << "\t mGpgId: " << group.mPgpId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif // DEBUG_IDS
|
#endif // DEBUG_IDS
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
group.mPgpKnown = false;
|
||||||
|
group.mPgpId = "";
|
||||||
|
|
||||||
|
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
groups.push_back(group);
|
||||||
|
delete(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
group.mPgpKnown = false;
|
std::cerr << "Not a Id Item, deleting!" << std::endl;
|
||||||
group.mPgpId = "";
|
delete(*vit);
|
||||||
|
|
||||||
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
groups.push_back(group);
|
return ok;
|
||||||
}
|
|
||||||
delete *vit ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3IdService::getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions)
|
bool p3IdService::getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions)
|
||||||
{
|
{
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
|
|
|
@ -207,18 +207,25 @@ bool p3PhotoService::getAlbum(const uint32_t& token, std::vector<RsPhotoAlbum>&
|
||||||
for(; vit != grpData.end(); vit++)
|
for(; vit != grpData.end(); vit++)
|
||||||
{
|
{
|
||||||
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
|
RsGxsPhotoAlbumItem* item = dynamic_cast<RsGxsPhotoAlbumItem*>(*vit);
|
||||||
RsPhotoAlbum album = item->album;
|
if (item)
|
||||||
item->album.mMeta = item->meta;
|
{
|
||||||
album.mMeta = item->album.mMeta;
|
RsPhotoAlbum album = item->album;
|
||||||
delete item;
|
item->album.mMeta = item->meta;
|
||||||
albums.push_back(album);
|
album.mMeta = item->album.mMeta;
|
||||||
|
delete item;
|
||||||
|
albums.push_back(album);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Not a RsGxsPhotoAlbumItem, deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos)
|
bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos)
|
||||||
{
|
{
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
|
@ -240,14 +247,14 @@ bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos)
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
RsPhotoPhoto photo = item->photo;
|
RsPhotoPhoto photo = item->photo;
|
||||||
photo.mMeta = item->meta;
|
photo.mMeta = item->meta;
|
||||||
photos[grpId].push_back(photo);
|
photos[grpId].push_back(photo);
|
||||||
delete item;
|
delete item;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
std::cerr << "Not a photo Item, deleting!" << std::endl;
|
std::cerr << "Not a photo Item, deleting!" << std::endl;
|
||||||
delete *vit;
|
delete *vit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,11 +179,19 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &g
|
||||||
for(; vit != grpData.end(); vit++)
|
for(; vit != grpData.end(); vit++)
|
||||||
{
|
{
|
||||||
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
|
RsGxsPostedGroupItem* item = dynamic_cast<RsGxsPostedGroupItem*>(*vit);
|
||||||
RsPostedGroup grp = item->mGroup;
|
if (item)
|
||||||
item->mGroup.mMeta = item->meta;
|
{
|
||||||
grp.mMeta = item->mGroup.mMeta;
|
RsPostedGroup grp = item->mGroup;
|
||||||
delete item;
|
item->mGroup.mMeta = item->meta;
|
||||||
groups.push_back(grp);
|
grp.mMeta = item->mGroup.mMeta;
|
||||||
|
delete item;
|
||||||
|
groups.push_back(grp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Not a RsGxsPostedGroupItem, deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue