Merge pull request #1027 from PhenomRetroShare/Fix_UninitializedPeerMaxRates

Fix Uninitilized Peer Max Rates.
This commit is contained in:
csoler 2017-09-12 17:40:54 +02:00 committed by GitHub
commit 762d0258ed
2 changed files with 29 additions and 25 deletions

View File

@ -2088,10 +2088,15 @@ bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& ma
std::map<RsPeerId, peerState>::const_iterator it = mFriendList.find(pid) ; std::map<RsPeerId, peerState>::const_iterator it = mFriendList.find(pid) ;
if(it == mFriendList.end()) if(it == mFriendList.end())
{
maxUp = 0;
maxDn = 0;
return false ; return false ;
}
pgp_id = it->second.gpg_id ; pgp_id = it->second.gpg_id ;
} }
return getMaxRates(pgp_id,maxUp,maxDn) ; return getMaxRates(pgp_id,maxUp,maxDn) ;
} }

View File

@ -136,9 +136,8 @@ int pqihandler::tick()
{ {
// This is rather inelegant, but pqihandler has searchModules that are dynamically allocated, so the max rates // This is rather inelegant, but pqihandler has searchModules that are dynamically allocated, so the max rates
// need to be updated from inside. // need to be updated from inside.
uint32_t maxUp,maxDn ; uint32_t maxUp = 0,maxDn =0 ;
rsPeers->getPeerMaximumRates(it->first,maxUp,maxDn); if (rsPeers->getPeerMaximumRates(it->first,maxUp,maxDn) )
it->second->pqi->setRateCap(maxDn,maxUp);// mind the order! Dn first, than Up. it->second->pqi->setRateCap(maxDn,maxUp);// mind the order! Dn first, than Up.
} }