wsd/AdminModel.hpp     |    8 ++++----
 wsd/DocumentBroker.cpp |   24 +++++++++++++++++-------
 2 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit b6bffd7e65eaf4ed2ed51570bcff407638ed91fb
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Mon May 4 15:18:51 2020 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Mon May 4 17:56:48 2020 +0200

    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 <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Gabriel Masei <gabriel.ma...@1and1.ro>

diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 8faceb5f3..ae88ef8cd 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -375,12 +375,12 @@ private:
     std::list<unsigned> _recvStats;
     unsigned _recvStatsSize = 200;
 
-    uint64_t _sentBytesTotal;
-    uint64_t _recvBytesTotal;
+    uint64_t _sentBytesTotal = 0;
+    uint64_t _recvBytesTotal = 0;
 
-    uint64_t _segFaultCount;
+    uint64_t _segFaultCount = 0;
 
-    pid_t _forKitPid;
+    pid_t _forKitPid = 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 f0e4a99df..e0e8369a9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -359,14 +359,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);
         }
 
         if (_storage && _lockCtx->needsRefresh(now))
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to