[Libreoffice-commits] online.git: common/Util.cpp wsd/AdminModel.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 16 01:49:25 UTC 2017


 common/Util.cpp    |    7 ++++++-
 wsd/AdminModel.cpp |    8 ++------
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit b8160c1c1a6534857310c3e0119f1f38af22c30e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 15 13:32:07 2017 -0500

    wsd: return 0 when fail to proc get memory
    
    Change-Id: Ie7f0fdc031a71c76484705cfb2feee1744bbbd8b
    Reviewed-on: https://gerrit.libreoffice.org/33119
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/common/Util.cpp b/common/Util.cpp
index d3181da..48c0acf 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -127,6 +127,11 @@ namespace Util
 
     int getMemoryUsage(const Poco::Process::PID pid)
     {
+        if (pid == -1)
+        {
+            return 0;
+        }
+
         try
         {
             //TODO: Instead of RSS, return PSS
@@ -152,7 +157,7 @@ namespace Util
             LOG_WRN("Trying to find memory of invalid/dead PID " << pid);
         }
 
-        return -1;
+        return 0;
     }
 
     std::string replace(const std::string& s, const std::string& a, const std::string& b)
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 680c647..5f61175 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -132,15 +132,11 @@ std::string AdminModel::query(const std::string& command)
 unsigned AdminModel::getTotalMemoryUsage()
 {
     unsigned totalMem = 0;
-    for (auto& it: _documents)
+    for (const auto& it : _documents)
     {
         if (!it.second.isExpired())
         {
-            const int mem = Util::getMemoryUsage(it.second.getPid());
-            if (mem > 0)
-            {
-                totalMem += mem;
-            }
+            totalMem += Util::getMemoryUsage(it.second.getPid());
         }
     }
 


More information about the Libreoffice-commits mailing list