mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
fixed some leaking memory issues in loadList() methods, and also increased consistency by not returning non empty list with deleted items inside
This commit is contained in:
parent
48750cdb51
commit
8a41554754
@ -1199,6 +1199,7 @@ bool p3ChatService::loadList(std::list<RsItem*>& load)
|
|||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,6 +1052,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
|
|
||||||
/* assemble a list of dirs to clean (union of cache dirs) */
|
/* assemble a list of dirs to clean (union of cache dirs) */
|
||||||
std::list<std::string> cacheDirs;
|
std::list<std::string> cacheDirs;
|
||||||
|
@ -279,6 +279,11 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
/* error */
|
/* error */
|
||||||
std::cerr << "p3BitDht::loadList() Error only expecting 1 item";
|
std::cerr << "p3BitDht::loadList() Error only expecting 1 item";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
for(std::list<RsItem*>::iterator it=load.begin();it!=load.end();++it)
|
||||||
|
delete *it ;
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RsItem *item = load.front();
|
RsItem *item = load.front();
|
||||||
@ -290,6 +295,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
/* error */
|
/* error */
|
||||||
std::cerr << "p3BitDht::loadList() Error expecting item = config";
|
std::cerr << "p3BitDht::loadList() Error expecting item = config";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
delete item ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +399,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
setRelayMode(mode);
|
setRelayMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2224,6 +2224,7 @@ bool ftController::loadList(std::list<RsItem *>& load)
|
|||||||
/* cleanup */
|
/* cleanup */
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,8 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
|||||||
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
||||||
setWatchPeriod(t);
|
setWatchPeriod(t);
|
||||||
}
|
}
|
||||||
|
delete *it ;
|
||||||
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
||||||
@ -348,10 +350,13 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
|||||||
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
||||||
|
|
||||||
dirList.push_back(info) ;
|
dirList.push_back(info) ;
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set directories */
|
/* set directories */
|
||||||
setSharedDirectories(dirList);
|
setSharedDirectories(dirList);
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,6 +484,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
|||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2095,6 +2095,7 @@ bool p3GRouter::loadList(std::list<RsItem*>& items)
|
|||||||
#ifdef GROUTER_DEBUG
|
#ifdef GROUTER_DEBUG
|
||||||
debugDump();
|
debugDump();
|
||||||
#endif
|
#endif
|
||||||
|
items.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
bool p3GRouter::saveList(bool& cleanup,std::list<RsItem*>& items)
|
bool p3GRouter::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||||
|
@ -310,6 +310,18 @@ RsGxsNetService::~RsGxsNetService()
|
|||||||
it->second.clear() ;
|
it->second.clear() ;
|
||||||
}
|
}
|
||||||
mTransactions.clear() ;
|
mTransactions.clear() ;
|
||||||
|
|
||||||
|
delete mGrpServerUpdateItem ;
|
||||||
|
|
||||||
|
for(ClientGrpMap::iterator it = mClientGrpUpdateMap.begin();it!=mClientGrpUpdateMap.end();++it)
|
||||||
|
delete it->second ;
|
||||||
|
|
||||||
|
mClientGrpUpdateMap.clear() ;
|
||||||
|
|
||||||
|
for(std::map<RsGxsGroupId, RsGxsServerMsgUpdateItem*>::iterator it(mServerMsgUpdateMap.begin());it!=mServerMsgUpdateMap.end();)
|
||||||
|
delete it->second ;
|
||||||
|
|
||||||
|
mServerMsgUpdateMap.clear() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1310,9 +1322,7 @@ public:
|
|||||||
else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
|
else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
|
||||||
{
|
{
|
||||||
if(mServerGrpUpdateItem == NULL)
|
if(mServerGrpUpdateItem == NULL)
|
||||||
{
|
|
||||||
mServerGrpUpdateItem = gsui;
|
mServerGrpUpdateItem = gsui;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Error! More than one server group update item exists!" << std::endl;
|
std::cerr << "Error! More than one server group update item exists!" << std::endl;
|
||||||
@ -1320,7 +1330,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
std::cerr << "Type not expected!" << std::endl;
|
std::cerr << "Type not expected!" << std::endl;
|
||||||
|
delete item ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1336,9 +1349,11 @@ bool RsGxsNetService::loadList(std::list<RsItem *> &load)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mNxsMutex) ;
|
RS_STACK_MUTEX(mNxsMutex) ;
|
||||||
|
|
||||||
|
// The delete is done in StoreHere, if necessary
|
||||||
|
|
||||||
std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mGrpServerUpdateItem));
|
std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mGrpServerUpdateItem));
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
for(ClientMsgMap::iterator it = mClientMsgUpdateMap.begin();it!=mClientMsgUpdateMap.end();++it)
|
for(ClientMsgMap::iterator it = mClientMsgUpdateMap.begin();it!=mClientMsgUpdateMap.end();++it)
|
||||||
for(std::map<RsGxsGroupId,RsGxsMsgUpdateItem::MsgUpdateInfo>::const_iterator it2(it->second->msgUpdateInfos.begin());it2!=it->second->msgUpdateInfos.end();++it2)
|
for(std::map<RsGxsGroupId,RsGxsMsgUpdateItem::MsgUpdateInfo>::const_iterator it2(it->second->msgUpdateInfos.begin());it2!=it->second->msgUpdateInfos.end();++it2)
|
||||||
{
|
{
|
||||||
|
@ -20,8 +20,8 @@ class RsCacheService: public CacheSource, public CacheStore, public p3Config
|
|||||||
// Functions from p3config
|
// Functions from p3config
|
||||||
//
|
//
|
||||||
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
||||||
virtual bool saveList(bool&, std::list<RsItem*>&) { return false ;}
|
virtual bool saveList(bool&, std::list<RsItem*>&) =0;
|
||||||
virtual bool loadList(std::list<RsItem*>&) { return false ;}
|
virtual bool loadList(std::list<RsItem*>&) =0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t _tick_delay_in_seconds ;
|
uint32_t _tick_delay_in_seconds ;
|
||||||
|
@ -17,8 +17,8 @@ class RsPQIService: public p3Service, public p3Config
|
|||||||
// Functions from p3config
|
// Functions from p3config
|
||||||
//
|
//
|
||||||
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
||||||
virtual bool saveList(bool&, std::list<RsItem*>&) { return false ;}
|
virtual bool saveList(bool&, std::list<RsItem*>&) =0 ;
|
||||||
virtual bool loadList(std::list<RsItem*>&) { return false ;}
|
virtual bool loadList(std::list<RsItem*>&) =0 ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t _tick_delay_in_seconds ;
|
uint32_t _tick_delay_in_seconds ;
|
||||||
|
@ -715,6 +715,7 @@ bool AuthGPG::loadList(std::list<RsItem*>& load)
|
|||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1705,6 +1705,7 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
|||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,8 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
|||||||
RsHistoryMsgItem *msgItem;
|
RsHistoryMsgItem *msgItem;
|
||||||
std::list<RsItem*>::iterator it;
|
std::list<RsItem*>::iterator it;
|
||||||
|
|
||||||
for (it = load.begin(); it != load.end(); ++it) {
|
for (it = load.begin(); it != load.end(); ++it)
|
||||||
|
{
|
||||||
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
||||||
|
|
||||||
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
||||||
@ -381,6 +382,7 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2360,6 +2360,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||||||
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,12 +1180,13 @@ bool p3ServiceControl::loadList(std::list<RsItem *>& loadList)
|
|||||||
{
|
{
|
||||||
RsServicePermissionItem *item = dynamic_cast<RsServicePermissionItem*>(*it) ;
|
RsServicePermissionItem *item = dynamic_cast<RsServicePermissionItem*>(*it) ;
|
||||||
|
|
||||||
if(item == NULL)
|
if(item != NULL)
|
||||||
continue ;
|
mServicePermissionMap[item->mServiceId] = *item ;
|
||||||
|
|
||||||
mServicePermissionMap[item->mServiceId] = *item ;
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadList.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,6 +885,7 @@ bool p3BanList::loadList(std::list<RsItem*>& load)
|
|||||||
delete *it ;
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,6 +793,7 @@ bool p3GxsReputation::loadList(std::list<RsItem *>& loadList)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadList.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
|||||||
RsGxsIdLocalInfoItem *lii;
|
RsGxsIdLocalInfoItem *lii;
|
||||||
|
|
||||||
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
|
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
|
||||||
|
{
|
||||||
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
|
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
|
||||||
{
|
{
|
||||||
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
|
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
|
||||||
@ -282,7 +283,11 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
|||||||
|
|
||||||
mContacts = lii->mContacts ;
|
mContacts = lii->mContacts ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
|
}
|
||||||
|
|
||||||
|
items.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
|
|||||||
RsMsgSrcId* msi;
|
RsMsgSrcId* msi;
|
||||||
RsMsgParentId* msp;
|
RsMsgParentId* msp;
|
||||||
RsMsgGRouterMap* grm;
|
RsMsgGRouterMap* grm;
|
||||||
// RsPublicMsgInviteConfigItem* msv;
|
// RsPublicMsgInviteConfigItem* msv;
|
||||||
|
|
||||||
std::list<RsMsgItem*> items;
|
std::list<RsMsgItem*> items;
|
||||||
std::list<RsItem*>::iterator it;
|
std::list<RsItem*>::iterator it;
|
||||||
@ -552,150 +552,155 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
|
|||||||
std::map<uint32_t, RsPeerId> srcIdMsgMap;
|
std::map<uint32_t, RsPeerId> srcIdMsgMap;
|
||||||
std::map<uint32_t, RsPeerId>::iterator srcIt;
|
std::map<uint32_t, RsPeerId>::iterator srcIt;
|
||||||
|
|
||||||
// load items and calculate next unique msgId
|
// load items and calculate next unique msgId
|
||||||
for(it = load.begin(); it != load.end(); ++it)
|
for(it = load.begin(); it != load.end(); ++it)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (NULL != (mitem = dynamic_cast<RsMsgItem *>(*it)))
|
if (NULL != (mitem = dynamic_cast<RsMsgItem *>(*it)))
|
||||||
{
|
{
|
||||||
/* STORE MsgID */
|
/* STORE MsgID */
|
||||||
if (mitem->msgId >= mMsgUniqueId) {
|
if (mitem->msgId >= mMsgUniqueId) {
|
||||||
mMsgUniqueId = mitem->msgId + 1;
|
mMsgUniqueId = mitem->msgId + 1;
|
||||||
}
|
}
|
||||||
items.push_back(mitem);
|
items.push_back(mitem);
|
||||||
}
|
}
|
||||||
else if (NULL != (grm = dynamic_cast<RsMsgGRouterMap *>(*it)))
|
else if (NULL != (grm = dynamic_cast<RsMsgGRouterMap *>(*it)))
|
||||||
{
|
{
|
||||||
// merge.
|
// merge.
|
||||||
for(std::map<GRouterMsgPropagationId,uint32_t>::const_iterator it(grm->ongoing_msgs.begin());it!=grm->ongoing_msgs.end();++it)
|
for(std::map<GRouterMsgPropagationId,uint32_t>::const_iterator it(grm->ongoing_msgs.begin());it!=grm->ongoing_msgs.end();++it)
|
||||||
_ongoing_messages.insert(*it) ;
|
_ongoing_messages.insert(*it) ;
|
||||||
}
|
}
|
||||||
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
|
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
|
||||||
{
|
{
|
||||||
// delete standard tags as they are now save in config
|
// delete standard tags as they are now save in config
|
||||||
if(mTags.end() == (tagIt = mTags.find(mtt->tagId)))
|
if(mTags.end() == (tagIt = mTags.find(mtt->tagId)))
|
||||||
{
|
{
|
||||||
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete mTags[mtt->tagId];
|
delete mTags[mtt->tagId];
|
||||||
mTags.erase(tagIt);
|
mTags.erase(tagIt);
|
||||||
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
mTags.insert(std::pair<uint32_t, RsMsgTagType* >(mtt->tagId, mtt));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(NULL != (mti = dynamic_cast<RsMsgTags *>(*it)))
|
else if(NULL != (mti = dynamic_cast<RsMsgTags *>(*it)))
|
||||||
{
|
{
|
||||||
mMsgTags.insert(std::pair<uint32_t, RsMsgTags* >(mti->msgId, mti));
|
mMsgTags.insert(std::pair<uint32_t, RsMsgTags* >(mti->msgId, mti));
|
||||||
}
|
}
|
||||||
else if(NULL != (msi = dynamic_cast<RsMsgSrcId *>(*it)))
|
else if(NULL != (msi = dynamic_cast<RsMsgSrcId *>(*it)))
|
||||||
{
|
{
|
||||||
srcIdMsgMap.insert(std::pair<uint32_t, RsPeerId>(msi->msgId, msi->srcId));
|
srcIdMsgMap.insert(std::pair<uint32_t, RsPeerId>(msi->msgId, msi->srcId));
|
||||||
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi)); // does not need to be kept
|
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi)); // does not need to be kept
|
||||||
}
|
}
|
||||||
else if(NULL != (msp = dynamic_cast<RsMsgParentId *>(*it)))
|
else if(NULL != (msp = dynamic_cast<RsMsgParentId *>(*it)))
|
||||||
{
|
{
|
||||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msp->msgId, msp));
|
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msp->msgId, msp));
|
||||||
}
|
}
|
||||||
|
|
||||||
RsConfigKeyValueSet *vitem = NULL ;
|
RsConfigKeyValueSet *vitem = NULL ;
|
||||||
|
|
||||||
if(NULL != (vitem = dynamic_cast<RsConfigKeyValueSet*>(*it)))
|
if(NULL != (vitem = dynamic_cast<RsConfigKeyValueSet*>(*it)))
|
||||||
for(std::list<RsTlvKeyValue>::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
{
|
||||||
{
|
for(std::list<RsTlvKeyValue>::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||||
if(kit->key == "DISTANT_MESSAGES_ENABLED")
|
{
|
||||||
{
|
if(kit->key == "DISTANT_MESSAGES_ENABLED")
|
||||||
|
{
|
||||||
#ifdef MSG_DEBUG
|
#ifdef MSG_DEBUG
|
||||||
std::cerr << "Loaded config default nick name for distant chat: " << kit->value << std::endl ;
|
std::cerr << "Loaded config default nick name for distant chat: " << kit->value << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
mShouldEnableDistantMessaging = (kit->value == "YES") ;
|
mShouldEnableDistantMessaging = (kit->value == "YES") ;
|
||||||
}
|
}
|
||||||
if(kit->key == "DISTANT_MESSAGE_PERMISSION_FLAGS")
|
if(kit->key == "DISTANT_MESSAGE_PERMISSION_FLAGS")
|
||||||
{
|
{
|
||||||
#ifdef MSG_DEBUG
|
#ifdef MSG_DEBUG
|
||||||
std::cerr << "Loaded distant message permission flags: " << kit->value << std::endl ;
|
std::cerr << "Loaded distant message permission flags: " << kit->value << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
if (!kit->value.empty())
|
if (!kit->value.empty())
|
||||||
{
|
{
|
||||||
std::istringstream is(kit->value) ;
|
std::istringstream is(kit->value) ;
|
||||||
|
|
||||||
uint32_t tmp ;
|
uint32_t tmp ;
|
||||||
is >> tmp ;
|
is >> tmp ;
|
||||||
|
|
||||||
if(tmp < 3)
|
if(tmp < 3)
|
||||||
mDistantMessagePermissions = tmp ;
|
mDistantMessagePermissions = tmp ;
|
||||||
else
|
else
|
||||||
std::cerr << "(EE) Invalid value read for DistantMessagePermission flags in config: " << tmp << std::endl;
|
std::cerr << "(EE) Invalid value read for DistantMessagePermission flags in config: " << tmp << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
delete *it ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
load.clear() ;
|
||||||
|
|
||||||
// sort items into lists
|
// sort items into lists
|
||||||
std::list<RsMsgItem*>::iterator msgIt;
|
std::list<RsMsgItem*>::iterator msgIt;
|
||||||
for (msgIt = items.begin(); msgIt != items.end(); ++msgIt)
|
for (msgIt = items.begin(); msgIt != items.end(); ++msgIt)
|
||||||
{
|
{
|
||||||
mitem = *msgIt;
|
mitem = *msgIt;
|
||||||
|
|
||||||
/* STORE MsgID */
|
/* STORE MsgID */
|
||||||
if (mitem->msgId == 0) {
|
if (mitem->msgId == 0) {
|
||||||
mitem->msgId = getNewUniqueMsgId();
|
mitem->msgId = getNewUniqueMsgId();
|
||||||
}
|
}
|
||||||
|
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
srcIt = srcIdMsgMap.find(mitem->msgId);
|
srcIt = srcIdMsgMap.find(mitem->msgId);
|
||||||
if(srcIt != srcIdMsgMap.end()) {
|
if(srcIt != srcIdMsgMap.end()) {
|
||||||
mitem->PeerId(srcIt->second);
|
mitem->PeerId(srcIt->second);
|
||||||
srcIdMsgMap.erase(srcIt);
|
srcIdMsgMap.erase(srcIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* switch depending on the PENDING
|
/* switch depending on the PENDING
|
||||||
* flags
|
* flags
|
||||||
*/
|
*/
|
||||||
if (mitem -> msgFlags & RS_MSG_FLAGS_PENDING)
|
if (mitem -> msgFlags & RS_MSG_FLAGS_PENDING)
|
||||||
{
|
{
|
||||||
|
|
||||||
//std::cerr << "MSG_PENDING";
|
//std::cerr << "MSG_PENDING";
|
||||||
//std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
//mitem->print(std::cerr);
|
//mitem->print(std::cerr);
|
||||||
|
|
||||||
msgOutgoing[mitem->msgId] = mitem;
|
msgOutgoing[mitem->msgId] = mitem;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imsg[mitem->msgId] = mitem;
|
imsg[mitem->msgId] = mitem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
/* remove missing msgId in mSrcIds */
|
/* remove missing msgId in mSrcIds */
|
||||||
for (srcIt = srcIdMsgMap.begin(); srcIt != srcIdMsgMap.end(); ++srcIt) {
|
for (srcIt = srcIdMsgMap.begin(); srcIt != srcIdMsgMap.end(); ++srcIt) {
|
||||||
std::map<uint32_t, RsMsgSrcId*>::iterator it = mSrcIds.find(srcIt->first);
|
std::map<uint32_t, RsMsgSrcId*>::iterator it = mSrcIds.find(srcIt->first);
|
||||||
if (it != mSrcIds.end()) {
|
if (it != mSrcIds.end()) {
|
||||||
delete(it->second);
|
delete(it->second);
|
||||||
mSrcIds.erase(it);
|
mSrcIds.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove missing msgId in mParentId */
|
/* remove missing msgId in mParentId */
|
||||||
std::map<uint32_t, RsMsgParentId *>::iterator mit = mParentId.begin();
|
std::map<uint32_t, RsMsgParentId *>::iterator mit = mParentId.begin();
|
||||||
while (mit != mParentId.end()) {
|
while (mit != mParentId.end()) {
|
||||||
if (imsg.find(mit->first) == imsg.end()) {
|
if (imsg.find(mit->first) == imsg.end()) {
|
||||||
if (msgOutgoing.find(mit->first) == msgOutgoing.end()) {
|
if (msgOutgoing.find(mit->first) == msgOutgoing.end()) {
|
||||||
/* not found */
|
/* not found */
|
||||||
mParentId.erase(mit++);
|
mParentId.erase(mit++);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++mit;
|
++mit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3MsgService::loadWelcomeMsg()
|
void p3MsgService::loadWelcomeMsg()
|
||||||
|
@ -309,42 +309,34 @@ bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3StatusService::loadList(std::list<RsItem*>& load){
|
bool p3StatusService::loadList(std::list<RsItem*>& load)
|
||||||
|
{
|
||||||
// load your status from last rs session
|
// load your status from last rs session
|
||||||
StatusInfo own_info;
|
StatusInfo own_info;
|
||||||
std::list<RsItem*>::const_iterator it = load.begin();
|
|
||||||
|
|
||||||
if(it == load.end()){
|
|
||||||
std::cerr << "p3StatusService::loadList(): Failed to load " << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; it != load.end(); ++it){
|
|
||||||
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
|
|
||||||
|
|
||||||
|
|
||||||
if(own_status != NULL){
|
for(std::list<RsItem*>::const_iterator it = load.begin() ; it != load.end(); ++it)
|
||||||
|
{
|
||||||
|
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
|
||||||
|
|
||||||
own_info.id = mServiceCtrl->getOwnId();
|
if(own_status != NULL)
|
||||||
own_info.status = own_status->status;
|
{
|
||||||
own_info.time_stamp = own_status->sendTime;
|
own_info.id = mServiceCtrl->getOwnId();
|
||||||
delete own_status;
|
own_info.status = own_status->status;
|
||||||
|
own_info.time_stamp = own_status->sendTime;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mStatusMtx);
|
RsStackMutex stack(mStatusMtx);
|
||||||
std::pair<RsPeerId, StatusInfo> pr(mServiceCtrl->getOwnId(), own_info);
|
std::pair<RsPeerId, StatusInfo> pr(mServiceCtrl->getOwnId(), own_info);
|
||||||
mStatusInfoMap.insert(pr);
|
mStatusInfoMap.insert(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
}
|
||||||
}else{
|
|
||||||
std::cerr << "p3StatusService::loadList " << "Failed to load list "
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
delete *it ;
|
||||||
return false;
|
}
|
||||||
|
load.clear() ;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -728,6 +728,7 @@ bool p3turtle::loadList(std::list<RsItem*>& load)
|
|||||||
|
|
||||||
delete vitem ;
|
delete vitem ;
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
int p3turtle::getMaxTRForwardRate() const
|
int p3turtle::getMaxTRForwardRate() const
|
||||||
|
@ -783,7 +783,8 @@ bool p3VOIP::loadList(std::list<RsItem*>& load)
|
|||||||
|
|
||||||
delete vitem ;
|
delete vitem ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user