mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Merge pull request #1027 from PhenomRetroShare/Fix_UninitializedPeerMaxRates
Fix Uninitilized Peer Max Rates.
This commit is contained in:
commit
762d0258ed
@ -2080,19 +2080,24 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
|
|
||||||
bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||||
{
|
{
|
||||||
RsPgpId pgp_id ;
|
RsPgpId pgp_id ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
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())
|
||||||
return false ;
|
{
|
||||||
|
maxUp = 0;
|
||||||
|
maxDn = 0;
|
||||||
|
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) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||||
|
@ -129,20 +129,19 @@ int pqihandler::tick()
|
|||||||
|
|
||||||
if(now > mLastRateCapUpdate + 5)
|
if(now > mLastRateCapUpdate + 5)
|
||||||
{
|
{
|
||||||
// every 5 secs, update the max rates for all modules
|
// every 5 secs, update the max rates for all modules
|
||||||
|
|
||||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||||
for(std::map<RsPeerId, SearchModule *>::iterator it = mods.begin(); it != mods.end(); ++it)
|
for(std::map<RsPeerId, SearchModule *>::iterator it = mods.begin(); it != mods.end(); ++it)
|
||||||
{
|
{
|
||||||
// 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.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastRateCapUpdate = now ;
|
mLastRateCapUpdate = now ;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateRates();
|
UpdateRates();
|
||||||
|
Loading…
Reference in New Issue
Block a user