From 52d0c6616613355bb40c218fd4b910e011cbc46f Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 26 May 2016 18:24:25 +0200 Subject: [PATCH] Prevent re-initialized connections from counting bytes too eagerly. --- src/controller/controller_statistics.cpp | 14 ++++++++++++-- src/controller/controller_statistics.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 238e8962..48846053 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -636,6 +636,11 @@ 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. bool Controller::statStorage::hasDataFor(unsigned long long t) { if (!log.size()){return false;} @@ -665,8 +670,13 @@ void Controller::statStorage::update(IPC::statExchange & data) { statLog tmp; tmp.time = data.time(); tmp.lastSecond = data.lastSecond(); - tmp.down = data.down(); - tmp.up = data.up(); + tmp.down = data.down() - removeDown; + tmp.up = data.up() - removeUp; + 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; //wipe data older than approx. STAT_CUTOFF seconds /// \todo Remove least interesting data first. diff --git a/src/controller/controller_statistics.h b/src/controller/controller_statistics.h index a9dddda5..c38d07d7 100644 --- a/src/controller/controller_statistics.h +++ b/src/controller/controller_statistics.h @@ -62,7 +62,11 @@ namespace Controller { class statStorage { + private: + long long removeUp; + long long removeDown; public: + statStorage(); void update(IPC::statExchange & data); bool hasDataFor(unsigned long long); statLog & getDataFor(unsigned long long);