mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 15:00:36 -04:00
Merge pull request #1509 from RetroPooh/trafcount
display session traffic
This commit is contained in:
commit
43a5312194
12 changed files with 59 additions and 11 deletions
|
@ -186,7 +186,7 @@ class NetInterface;
|
|||
class PQInterface: public RateInterface
|
||||
{
|
||||
public:
|
||||
explicit PQInterface(const RsPeerId &id) :peerId(id) { return; }
|
||||
explicit PQInterface(const RsPeerId &id) :peerId(id), traf_in(0), traf_out(0) { return; }
|
||||
virtual ~PQInterface() { return; }
|
||||
|
||||
/*!
|
||||
|
@ -228,6 +228,22 @@ class PQInterface: public RateInterface
|
|||
const sockaddr_storage & /*remote_peer_address*/)
|
||||
{ return 0; }
|
||||
|
||||
virtual uint64_t getTraffic(bool in)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
if (in)
|
||||
{
|
||||
ret = traf_in;
|
||||
traf_in = 0;
|
||||
return ret;
|
||||
}
|
||||
ret = traf_out;
|
||||
traf_out = 0;
|
||||
return ret;
|
||||
}
|
||||
uint64_t traf_in;
|
||||
uint64_t traf_out;
|
||||
|
||||
private:
|
||||
|
||||
RsPeerId peerId;
|
||||
|
|
|
@ -83,6 +83,8 @@ pqihandler::pqihandler() : coreMtx("pqihandler")
|
|||
rateMax_in = 0.01;
|
||||
rateTotal_in = 0.0 ;
|
||||
rateTotal_out = 0.0 ;
|
||||
traffInSum = 0;
|
||||
traffOutSum = 0;
|
||||
last_m = time(NULL) ;
|
||||
nb_ticks = 0 ;
|
||||
mLastRateCapUpdate = 0 ;
|
||||
|
@ -371,6 +373,9 @@ int pqihandler::UpdateRates()
|
|||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
float crate_in = mod -> pqi -> getRate(true);
|
||||
|
||||
traffInSum += mod -> pqi -> getTraffic(true);
|
||||
traffOutSum += mod -> pqi -> getTraffic(false);
|
||||
|
||||
#ifdef PQI_HDL_DEBUG_UR
|
||||
if(crate_in > 0.0)
|
||||
|
@ -540,4 +545,8 @@ void pqihandler::locked_StoreCurrentRates(float in, float out)
|
|||
rateTotal_out = out;
|
||||
}
|
||||
|
||||
|
||||
void pqihandler::GetTraffic(uint64_t &in, uint64_t &out)
|
||||
{
|
||||
in = traffInSum;
|
||||
out = traffOutSum;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@ class pqihandler: public P3Interface, public pqiPublisher
|
|||
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||
|
||||
uint64_t traffInSum;
|
||||
uint64_t traffOutSum;
|
||||
void GetTraffic(uint64_t &in, uint64_t &out);
|
||||
|
||||
protected:
|
||||
/* check to be overloaded by those that can
|
||||
* generates warnings otherwise
|
||||
|
|
|
@ -637,6 +637,13 @@ float pqiperson::getRate(bool in)
|
|||
return activepqi -> getRate(in);
|
||||
}
|
||||
|
||||
uint64_t pqiperson::getTraffic(bool in)
|
||||
{
|
||||
if ((!active) || (activepqi == NULL))
|
||||
return 0;
|
||||
return activepqi -> getTraffic(in);
|
||||
}
|
||||
|
||||
void pqiperson::setMaxRate(bool in, float val)
|
||||
{
|
||||
RS_STACK_MUTEX(mPersonMtx);
|
||||
|
|
|
@ -143,6 +143,7 @@ public:
|
|||
virtual int getQueueSize(bool in);
|
||||
virtual void getRates(RsBwRates &rates);
|
||||
virtual float getRate(bool in);
|
||||
virtual uint64_t getTraffic(bool in);
|
||||
virtual void setMaxRate(bool in, float val);
|
||||
virtual void setRateCap(float val_in, float val_out);
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,
|
||||
|
|
|
@ -216,6 +216,7 @@ float pqistreamer::getRate(bool b)
|
|||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
return RateInterface::getRate(b) ;
|
||||
}
|
||||
|
||||
void pqistreamer::setMaxRate(bool b,float f)
|
||||
{
|
||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
|
@ -1226,7 +1227,7 @@ void pqistreamer::outSentBytes_locked(uint32_t outb)
|
|||
mTotalSent += outb;
|
||||
mCurrSent += outb;
|
||||
mAvgSentCount += outb;
|
||||
|
||||
PQInterface::traf_out += outb;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1243,7 +1244,7 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
|
|||
mTotalRead += inb;
|
||||
mCurrRead += inb;
|
||||
mAvgReadCount += inb;
|
||||
|
||||
PQInterface::traf_in += inb;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -409,6 +409,7 @@ public:
|
|||
* @return returns 1 on succes and 0 otherwise
|
||||
*/
|
||||
virtual int GetCurrentDataRates( float &inKb, float &outKb ) = 0;
|
||||
virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -560,4 +560,8 @@ int p3ServerConfig::GetCurrentDataRates( float &inKb, float &outKb )
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int p3ServerConfig::GetTrafficSum(uint64_t &inb, uint64_t &outb )
|
||||
{
|
||||
mPqiHandler->GetTraffic(inb, outb);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ virtual bool setOperatingMode(const std::string &opModeStr);
|
|||
virtual int SetMaxDataRates( int downKb, int upKb );
|
||||
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
||||
virtual int GetCurrentDataRates( float &inKb, float &outKb );
|
||||
virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb );
|
||||
|
||||
/********************* ABOVE is RsConfig Interface *******/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue