Add in storage of the current Data Rate to pqihandler.cc.

Add in interface for the Data Rates.
Increase DHT Bootstrap buckets to 8.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@590 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-06-10 00:47:24 +00:00
parent 20aa2a031b
commit e42ce13454
6 changed files with 56 additions and 13 deletions

View File

@ -63,7 +63,7 @@
#define DHT_DEFAULT_WAITTIME 1 /* Std sleep break period */ #define DHT_DEFAULT_WAITTIME 1 /* Std sleep break period */
#define DHT_NUM_BOOTSTRAP_BINS 4 #define DHT_NUM_BOOTSTRAP_BINS 8
#define DHT_MIN_BOOTSTRAP_REQ_PERIOD 30 #define DHT_MIN_BOOTSTRAP_REQ_PERIOD 30
void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out); void printDhtPeerEntry(dhtPeerEntry *ent, std::ostream &out);

View File

@ -573,18 +573,20 @@ int pqihandler::UpdateRates()
} }
extra_bw_out += crate_out - avg_rate_out; extra_bw_out += crate_out - avg_rate_out;
} }
// std::cerr << "\tSM(" << mod -> smi << ")"; //std::cerr << "\tSM(" << mod -> smi << ")";
// std::cerr << "In A: " << mod -> pqi -> getMaxRate(true); std::cerr << "In A: " << mod -> pqi -> getMaxRate(true);
// std::cerr << " C: " << crate_in; std::cerr << " C: " << crate_in;
// std::cerr << " && Out A: " << mod -> pqi -> getMaxRate(false); std::cerr << " && Out A: " << mod -> pqi -> getMaxRate(false);
// std::cerr << " C: " << crate_out << std::endl; std::cerr << " C: " << crate_out << std::endl;
} }
// std::cerr << "Totals (In) Used B/W " << used_bw_in; std::cerr << "Totals (In) Used B/W " << used_bw_in;
// std::cerr << " Excess B/W " << extra_bw_in; std::cerr << " Excess B/W " << extra_bw_in;
// std::cerr << " Available B/W " << avail_in << std::endl; std::cerr << " Available B/W " << avail_in << std::endl;
// std::cerr << "Totals (Out) Used B/W " << used_bw_out; std::cerr << "Totals (Out) Used B/W " << used_bw_out;
// std::cerr << " Excess B/W " << extra_bw_out; std::cerr << " Excess B/W " << extra_bw_out;
// std::cerr << " Available B/W " << avail_out << std::endl; std::cerr << " Available B/W " << avail_out << std::endl;
StoreCurrentRates(used_bw_in, used_bw_out);
if (used_bw_in > avail_in) if (used_bw_in > avail_in)
{ {
@ -706,7 +708,20 @@ int pqihandler::UpdateRates()
} }
} }
return 1; return 1;
} }
void pqihandler::getCurrentRates(float &in, float &out)
{
in = rateTotal_in;
out = rateTotal_out;
}
void pqihandler::StoreCurrentRates(float in, float out)
{
rateTotal_in = in;
rateTotal_out = out;
}

View File

@ -78,6 +78,9 @@ float getMaxIndivRate(bool in);
void setMaxRate(bool in, float val); void setMaxRate(bool in, float val);
float getMaxRate(bool in); float getMaxRate(bool in);
void getCurrentRates(float &in, float &out);
protected: protected:
/* check to be overloaded by those that can /* check to be overloaded by those that can
* generates warnings otherwise * generates warnings otherwise
@ -100,12 +103,15 @@ void SortnStoreItem(RsItem *item);
// rate control. // rate control.
int UpdateRates(); int UpdateRates();
void StoreCurrentRates(float in, float out);
float rateIndiv_in; float rateIndiv_in;
float rateIndiv_out; float rateIndiv_out;
float rateMax_in; float rateMax_in;
float rateMax_out; float rateMax_out;
float rateTotal_in;
float rateTotal_out;
}; };
inline void pqihandler::setMaxIndivRate(bool in, float val) inline void pqihandler::setMaxIndivRate(bool in, float val)

View File

@ -259,6 +259,7 @@ virtual int ConfigRemoveSharedDir( std::string dir ) = 0;
virtual int ConfigSetIncomingDir( std::string dir ) = 0; virtual int ConfigSetIncomingDir( std::string dir ) = 0;
virtual int ConfigSetDataRates( int total, int indiv ) = 0; virtual int ConfigSetDataRates( int total, int indiv ) = 0;
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
virtual int ConfigSetBootPrompt( bool on ) = 0; virtual int ConfigSetBootPrompt( bool on ) = 0;
virtual void ConfigFinalSave( ) = 0; virtual void ConfigFinalSave( ) = 0;
virtual void rsGlobalShutDown( ) = 0; virtual void rsGlobalShutDown( ) = 0;

View File

@ -265,6 +265,25 @@ int RsServer::ConfigSetDataRates( int total, int indiv ) /* in kbrates */
} }
int RsServer::ConfigGetDataRates( float &inKb, float &outKb ) /* in kbrates */
{
/* fill the rsiface class */
RsIface &iface = getIface();
/* lock Mutexes */
lockRsCore(); /* LOCK */
iface.lockData(); /* LOCK */
pqih -> getCurrentRates(inKb, outKb);
/* unlock Mutexes */
iface.unlockData(); /* UNLOCK */
unlockRsCore(); /* UNLOCK */
return 1;
}
int RsServer::ConfigSetBootPrompt( bool on ) int RsServer::ConfigSetBootPrompt( bool on )
{ {
@ -315,7 +334,7 @@ int RsServer::UpdateAllConfig()
config.uPnPState = mConnMgr->getUPnPState(); config.uPnPState = mConnMgr->getUPnPState();
config.uPnPActive = mConnMgr->getUPnPEnabled(); config.uPnPActive = mConnMgr->getUPnPEnabled();
config.DHTPeers = 20; config.DHTPeers = 20;
config.DHTActive = mConnMgr->getDHTEnabled();; config.DHTActive = mConnMgr->getDHTEnabled();
/* Notify of Changes */ /* Notify of Changes */
iface.setChanged(RsIface::Config); iface.setChanged(RsIface::Config);

View File

@ -249,6 +249,8 @@ virtual int ConfigSetIncomingDir( std::string dir );
//virtual int ConfigSetExtName( std::string addr ); //virtual int ConfigSetExtName( std::string addr );
//virtual int ConfigSetLanConfig( bool fire, bool forw ); //virtual int ConfigSetLanConfig( bool fire, bool forw );
virtual int ConfigGetDataRates(float &inKb, float &outKb);
virtual int ConfigSetDataRates( int total, int indiv ); virtual int ConfigSetDataRates( int total, int indiv );
virtual int ConfigSetBootPrompt( bool on ); virtual int ConfigSetBootPrompt( bool on );