cleaned the MaxUpRate branch from unused code

This commit is contained in:
csoler 2016-06-11 17:54:11 -04:00
parent 83a143476e
commit ef4455ac9c
4 changed files with 3 additions and 40 deletions

View File

@ -130,10 +130,7 @@ int pqihandler::tick()
uint32_t maxUp,maxDn ; uint32_t maxUp,maxDn ;
rsPeers->getPeerMaximumRates(it->first,maxUp,maxDn); rsPeers->getPeerMaximumRates(it->first,maxUp,maxDn);
std::cerr << "Updating searchModule " << it->first << " max rates to " << maxUp << " - " << maxDn << std::endl; it->second->pqi->setRateCap(maxDn,maxUp);// mind the order! Dn first, than Up.
it->second->mMaxDnRate = maxDn ;
it->second->mMaxUpRate = maxUp ;
} }
last_print_time = now ; last_print_time = now ;
@ -520,11 +517,6 @@ int pqihandler::UpdateRates()
if (mod -> pqi -> getMaxRate(false) > avail_out) mod -> pqi -> setMaxRate(false, avail_out); if (mod -> pqi -> getMaxRate(false) > avail_out) mod -> pqi -> setMaxRate(false, avail_out);
if (mod -> pqi -> getMaxRate(true) < max_in_effective) mod -> pqi -> setMaxRate(true, max_in_effective); if (mod -> pqi -> getMaxRate(true) < max_in_effective) mod -> pqi -> setMaxRate(true, max_in_effective);
if (mod -> pqi -> getMaxRate(true) > avail_in) mod -> pqi -> setMaxRate(true, avail_in); if (mod -> pqi -> getMaxRate(true) > avail_in) mod -> pqi -> setMaxRate(true, avail_in);
// Caps the allowed max speeds to the user defined values, leaving more space for other peers.
if(mod->mMaxUpRate > 0 && mod->pqi->getMaxRate(false) > mod->mMaxUpRate) mod->pqi->setMaxRate(false, mod->mMaxUpRate) ;
if(mod->mMaxDnRate > 0 && mod->pqi->getMaxRate(true ) > mod->mMaxDnRate) mod->pqi->setMaxRate(true , mod->mMaxDnRate) ;
} }
return 1; return 1;

View File

@ -39,12 +39,10 @@
class SearchModule class SearchModule
{ {
public: public:
SearchModule() { mMaxUpRate=0;mMaxDnRate=0;} SearchModule() : pqi(NULL) {}
RsPeerId peerid ; RsPeerId peerid ;
PQInterface *pqi; PQInterface *pqi;
uint32_t mMaxUpRate ; // max allowed speeds in kB/s
uint32_t mMaxDnRate ;
}; };
// Presents a P3 Face to the world! // Presents a P3 Face to the world!
@ -75,7 +73,7 @@ class pqihandler: public P3Interface, public pqiPublisher
#endif #endif
// rate control. // rate control.
void setMaxRate(const RsPeerId& pid,bool in, uint32_t val_kBs); //void setMaxRate(const RsPeerId& pid,bool in, uint32_t val_kBs);
void setMaxRate(bool in, float val); void setMaxRate(bool in, float val);
float getMaxRate(bool in); float getMaxRate(bool in);
@ -126,24 +124,6 @@ protected:
float ticks_per_sec ; float ticks_per_sec ;
}; };
inline void pqihandler::setMaxRate(const RsPeerId& pid,bool in,uint32_t val_kBs)
{
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
std::map<RsPeerId, SearchModule *>::iterator it = mods.find(pid);
if(it == mods.end())
{
std::cerr << "(EE) no search module for pid " << pid << ": cannot set max rate" << std::endl;
return ;
}
if(in)
it->second->mMaxDnRate = val_kBs ;
else
it->second->mMaxUpRate = val_kBs ;
}
inline void pqihandler::setMaxRate(bool in, float val) inline void pqihandler::setMaxRate(bool in, float val)
{ {
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/

View File

@ -503,14 +503,6 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
return true; return true;
} }
int p3ServerConfig::SetMaxDataRates(const RsPeerId& pid, int downKb, int upKb ) /* in kbrates */
{
mPqiHandler->setMaxRate(pid,true,downKb) ;
mPqiHandler->setMaxRate(pid,false,upKb) ;
return true ;
}
/* handle data rates. /* handle data rates.
* Mutex must be handled at the lower levels: TODO */ * Mutex must be handled at the lower levels: TODO */

View File

@ -95,7 +95,6 @@ virtual bool setOperatingMode(uint32_t opMode);
virtual int SetMaxDataRates( int downKb, int upKb ); virtual int SetMaxDataRates( int downKb, int upKb );
virtual int GetMaxDataRates( int &downKb, int &upKb ); virtual int GetMaxDataRates( int &downKb, int &upKb );
virtual int GetCurrentDataRates( float &inKb, float &outKb ); virtual int GetCurrentDataRates( float &inKb, float &outKb );
virtual int SetMaxDataRates(const RsPeerId& pid, int downKb, int upKb );
/********************* ABOVE is RsConfig Interface *******/ /********************* ABOVE is RsConfig Interface *******/