diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-05-04 15:18:51 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-05-06 07:57:53 +0200 |
commit | ff826e6f1efc9cdd14990f5bea1de30f86ec2d73 (patch) | |
tree | 7e479da4ebb0281e2a3add813a1978e3b438000e | |
parent | 538265a7447b6ee6167d21a47d9dad05afa3f818 (diff) |
admin: cleanup sent/recv accounting - and initialize the totals.
Change-Id: I96265c5d0e7b18d9ae19efa0ce7477aead75dbf7
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93422
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Gabriel Masei <gabriel.masei@1and1.ro>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93439
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | wsd/AdminModel.hpp | 4 | ||||
-rw-r--r-- | wsd/DocumentBroker.cpp | 24 |
2 files changed, 19 insertions, 9 deletions
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp index 4c22182ba..bf1e76128 100644 --- a/wsd/AdminModel.hpp +++ b/wsd/AdminModel.hpp @@ -303,8 +303,8 @@ private: std::list<unsigned> _recvStats; unsigned _recvStatsSize = 100; - uint64_t _sentBytesTotal; - uint64_t _recvBytesTotal; + uint64_t _sentBytesTotal = 0; + uint64_t _recvBytesTotal = 0; /// We check the owner even in the release builds, needs to be always correct. std::thread::id _owner; diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 75d9387ed..ae7d2ecf5 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -300,14 +300,24 @@ void DocumentBroker::pollThread() lastBWUpdateTime = now; uint64_t sent, recv; getIOStats(sent, recv); + + uint64_t deltaSent = 0, deltaRecv = 0; + + // connection drop transiently reduces this. + if (sent > adminSent) + { + deltaSent = sent - adminSent; + adminSent = sent; + } + if (recv > deltaRecv) + { + deltaRecv = recv - adminRecv; + adminRecv = recv; + } + LOG_TRC("Doc [" << _docKey << "] added stats sent: +" << deltaSent << ", recv: +" << deltaRecv << " bytes to totals."); + // send change since last notification. - Admin::instance().addBytes(getDocKey(), - // connection drop transiently reduces this. - (sent > adminSent ? (sent - adminSent): uint64_t(0)), - (recv > adminRecv ? (recv - adminRecv): uint64_t(0))); - adminSent = sent; - adminRecv = recv; - LOG_TRC("Doc [" << _docKey << "] added stats sent: " << sent << ", recv: " << recv << " bytes to totals."); + Admin::instance().addBytes(getDocKey(), deltaSent, deltaRecv); } #endif |