common/Util.cpp | 7 ++++++- wsd/AdminModel.cpp | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-)
New commits: commit b8160c1c1a6534857310c3e0119f1f38af22c30e Author: Ashod Nakashian <ashod.nakash...@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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@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()); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits