[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-2' - wsd/Admin.cpp wsd/AdminModel.cpp wsd/AdminModel.hpp
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 14 18:39:53 UTC 2020
wsd/Admin.cpp | 11 ++++++++++-
wsd/AdminModel.cpp | 13 +++++++++++++
wsd/AdminModel.hpp | 2 ++
3 files changed, 25 insertions(+), 1 deletion(-)
New commits:
commit d5ea6213c20a3c254cdbe0021aa906ad594da125
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Apr 8 09:03:07 2020 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Apr 14 20:39:31 2020 +0200
admin: only kill document pids
unit-admin is currently disabled, so... how to reproduce:
Edit loleaflet/admin/src/AdminSocketOverview.js to try to kill e.g. pid
0.
Expected result:
[ admin ] WRN Invalid PID to kill (not a document pid)| wsd/Admin.cpp:168
Change-Id: I06dda68b38096689c1b9327cefba2cbfc96805f8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91868
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
(cherry picked from commit 60908ed88cf970b0457a8feba5239a3420d6850d)
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92175
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index ca72ecd61..88b9268df 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -157,7 +157,16 @@ void AdminSocketHandler::handleMessage(const std::vector<char> &payload)
{
const int pid = std::stoi(tokens[1]);
LOG_INF("Admin request to kill PID: " << pid);
- SigUtil::killChild(pid);
+
+ std::set<pid_t> pids = model.getDocumentPids();
+ if (pids.find(pid) != pids.end())
+ {
+ SigUtil::killChild(pid);
+ }
+ else
+ {
+ LOG_WRN("Invalid PID to kill (not a document pid)");
+ }
}
catch (std::invalid_argument& exc)
{
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index f8302f842..22e402a83 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -1016,4 +1016,17 @@ void AdminModel::getMetrics(std::ostringstream &oss)
PrintDocActExpMetrics(oss, "view_load_duration", "milliseconds", docStats._viewLoadDuration);
}
+std::set<pid_t> AdminModel::getDocumentPids() const
+{
+ std::set<pid_t> pids;
+
+ for (const auto& it : _documents)
+ {
+ const Document& document = it.second;
+ pids.insert(document.getPid());
+ }
+
+ return pids;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index f683cd45c..be5d9dd0f 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -320,6 +320,8 @@ public:
void getMetrics(std::ostringstream &oss);
+ std::set<pid_t> getDocumentPids() const;
+
static int getPidsFromProcName(const std::regex& procNameRegEx, std::vector<int> *pids);
private:
More information about the Libreoffice-commits
mailing list