Fixed bandwidth sometimes being wrongly measured.
This commit is contained in:
parent
ed982b9eb3
commit
6babfe64c6
5 changed files with 10 additions and 16 deletions
|
@ -209,6 +209,12 @@ Socket::Connection::Connection() {
|
||||||
Blocking = false;
|
Blocking = false;
|
||||||
} //Socket::Connection basic constructor
|
} //Socket::Connection basic constructor
|
||||||
|
|
||||||
|
|
||||||
|
void Socket::Connection::resetCounter(){
|
||||||
|
up = 0;
|
||||||
|
down = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// Internally used call to make an file descriptor blocking or not.
|
/// Internally used call to make an file descriptor blocking or not.
|
||||||
void setFDBlocking(int FD, bool blocking) {
|
void setFDBlocking(int FD, bool blocking) {
|
||||||
int flags = fcntl(FD, F_GETFL, 0);
|
int flags = fcntl(FD, F_GETFL, 0);
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace Socket {
|
||||||
unsigned int connTime();///< Returns the time this socket has been connected.
|
unsigned int connTime();///< Returns the time this socket has been connected.
|
||||||
uint64_t dataUp(); ///< Returns total amount of bytes sent.
|
uint64_t dataUp(); ///< Returns total amount of bytes sent.
|
||||||
uint64_t dataDown(); ///< Returns total amount of bytes received.
|
uint64_t dataDown(); ///< Returns total amount of bytes received.
|
||||||
|
void resetCounter(); ///< Resets the up/down bytes counter to zero.
|
||||||
std::string getStats(std::string C); ///< Returns a std::string of stats, ended by a newline.
|
std::string getStats(std::string C); ///< Returns a std::string of stats, ended by a newline.
|
||||||
friend class Server;
|
friend class Server;
|
||||||
bool Error; ///< Set to true if a socket error happened.
|
bool Error; ///< Set to true if a socket error happened.
|
||||||
|
|
|
@ -640,11 +640,6 @@ long long Controller::statSession::getBpsUp(unsigned long long t){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller::statStorage::statStorage(){
|
|
||||||
removeDown = 0;
|
|
||||||
removeUp = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if there is data available for timestamp t.
|
/// Returns true if there is data available for timestamp t.
|
||||||
bool Controller::statStorage::hasDataFor(unsigned long long t) {
|
bool Controller::statStorage::hasDataFor(unsigned long long t) {
|
||||||
if (!log.size()){return false;}
|
if (!log.size()){return false;}
|
||||||
|
@ -674,13 +669,8 @@ void Controller::statStorage::update(IPC::statExchange & data) {
|
||||||
statLog tmp;
|
statLog tmp;
|
||||||
tmp.time = data.time();
|
tmp.time = data.time();
|
||||||
tmp.lastSecond = data.lastSecond();
|
tmp.lastSecond = data.lastSecond();
|
||||||
tmp.down = data.down() - removeDown;
|
tmp.down = data.down();
|
||||||
tmp.up = data.up() - removeUp;
|
tmp.up = data.up();
|
||||||
if (!log.size() && tmp.down + tmp.up > COUNTABLE_BYTES){
|
|
||||||
//substract the start values if they are too high - this is a resumed connection of some sort
|
|
||||||
removeDown = tmp.down;
|
|
||||||
removeUp = tmp.up;
|
|
||||||
}
|
|
||||||
log[data.now()] = tmp;
|
log[data.now()] = tmp;
|
||||||
//wipe data older than approx. STAT_CUTOFF seconds
|
//wipe data older than approx. STAT_CUTOFF seconds
|
||||||
/// \todo Remove least interesting data first.
|
/// \todo Remove least interesting data first.
|
||||||
|
|
|
@ -62,11 +62,7 @@ namespace Controller {
|
||||||
|
|
||||||
|
|
||||||
class statStorage {
|
class statStorage {
|
||||||
private:
|
|
||||||
long long removeUp;
|
|
||||||
long long removeDown;
|
|
||||||
public:
|
public:
|
||||||
statStorage();
|
|
||||||
void update(IPC::statExchange & data);
|
void update(IPC::statExchange & data);
|
||||||
bool hasDataFor(unsigned long long);
|
bool hasDataFor(unsigned long long);
|
||||||
statLog & getDataFor(unsigned long long);
|
statLog & getDataFor(unsigned long long);
|
||||||
|
|
|
@ -241,6 +241,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
if (statsPage.getData()){
|
if (statsPage.getData()){
|
||||||
statsPage.finish();
|
statsPage.finish();
|
||||||
|
myConn.resetCounter();
|
||||||
}
|
}
|
||||||
statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true);
|
statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true);
|
||||||
if (nProxy.userClient.getData()){
|
if (nProxy.userClient.getData()){
|
||||||
|
|
Loading…
Add table
Reference in a new issue