[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - kit/ForKit.cpp kit/Kit.cpp kit/Kit.hpp test/test.cpp test/test.hpp wsd/LOOLWSD.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Sat Oct 19 18:55:06 UTC 2019
kit/ForKit.cpp | 9 ++++++---
kit/Kit.cpp | 10 ++++++----
kit/Kit.hpp | 5 +++--
test/test.cpp | 20 +++++++++++++++-----
test/test.hpp | 7 ++++++-
wsd/LOOLWSD.cpp | 2 +-
6 files changed, 37 insertions(+), 16 deletions(-)
New commits:
commit ab5094fd253ac1b5de3fc8e671bcfc28ccfae7a4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Sep 21 14:39:32 2019 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Oct 19 20:54:47 2019 +0200
wsd: improved kit thread naming
Now the wsd docbroker thread and its peer kit
thread are trivial to match, since they are called
docbroker_xxx and kitbroker_xxx (where xxx is the
instance ID) respectively.
Also, label spare kit instances as kit_spare_xxx
to differentiate from ones with actual documents,
where xxx is a running counter to differentiate
spare instances from one another.
Now we are able to easily see (and count) the number
of spare kit instances, and match wsd and kit threads
handling a given document.
Unit-test logic updated to reflect the new thread
naming scheme.
Change-Id: I154dc8f200fbe0e65f3f5984e6dad2cef1b52e22
Reviewed-on: https://gerrit.libreoffice.org/79335
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 9b3571efb..c5f4f398c 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -250,7 +250,10 @@ static int createLibreOfficeKit(const std::string& childRoot,
// Generate a jail ID to be used for in the jail path.
const std::string jailId = Util::rng::getFilename(16);
- LOG_DBG("Forking a loolkit process with jailId: " << jailId << ".");
+ // Used to label the spare kit instances
+ static size_t spareKitId = 0;
+ ++spareKitId;
+ LOG_DBG("Forking a loolkit process with jailId: " << jailId << " as spare loolkit #" << spareKitId << ".");
const Process::PID pid = fork();
if (!pid)
@@ -277,9 +280,9 @@ static int createLibreOfficeKit(const std::string& childRoot,
}
#ifndef KIT_IN_PROCESS
- lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion);
+ lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, NoCapsForKit, NoSeccomp, queryVersion, DisplayVersion, spareKitId);
#else
- lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, true, queryVersion, DisplayVersion);
+ lokit_main(childRoot, jailId, sysTemplate, loTemplate, loSubPath, true, true, queryVersion, DisplayVersion, spareKitId);
#endif
}
else
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 3adb5347e..0681bb449 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1770,7 +1770,7 @@ private:
void run() override
{
- Util::setThreadName("lokit_" + _docId);
+ Util::setThreadName("kitbroker_" + _docId);
LOG_DBG("Thread started.");
#ifndef MOBILEAPP
@@ -2053,6 +2053,7 @@ protected:
std::string url;
URI::decode(docKey, url);
LOG_INF("New session [" << sessionId << "] request on url [" << url << "].");
+ Util::setThreadName("kitbroker_" + docId);
if (!document)
{
@@ -2127,11 +2128,12 @@ void lokit_main(
bool noCapabilities,
bool noSeccomp,
bool queryVersion,
- bool displayVersion
+ bool displayVersion,
#else
const std::string& documentUri,
- int docBrokerSocket
+ int docBrokerSocket,
#endif
+ size_t spareKitId
)
{
#ifndef MOBILEAPP
@@ -2141,7 +2143,7 @@ void lokit_main(
SigUtil::setTerminationSignals();
#endif
- Util::setThreadName("loolkit");
+ Util::setThreadName("kit_spare_" + Util::encodeId(spareKitId, 3));
// Reinitialize logging when forked.
const bool logToFile = std::getenv("LOOL_LOGFILE");
diff --git a/kit/Kit.hpp b/kit/Kit.hpp
index efd768f14..365c920e9 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -32,11 +32,12 @@ void lokit_main(
bool noCapabilities,
bool noSeccomp,
bool queryVersionInfo,
- bool displayVersion
+ bool displayVersion,
#else
const std::string& documentUri,
- int docBrokerSocket
+ int docBrokerSocket,
#endif
+ size_t spareKitId
);
bool globalPreinit(const std::string& loTemplate);
diff --git a/test/test.cpp b/test/test.cpp
index e7ed5bfcc..40ed5d6fa 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -174,7 +174,7 @@ std::vector<int> getProcPids(const char* exec_filename, bool ignoreZombies = fal
std::string statString;
Poco::StreamCopier::copyToString(stat, statString);
Poco::StringTokenizer tokens(statString, " ");
- if (tokens.count() > 3 && tokens[1] == exec_filename)
+ if (tokens.count() > 3 && Util::startsWith(tokens[1], exec_filename))
{
if (ignoreZombies)
{
@@ -202,18 +202,28 @@ std::vector<int> getProcPids(const char* exec_filename, bool ignoreZombies = fal
return pids;
}
-std::vector<int> getKitPids()
+std::vector<int> getSpareKitPids()
{
- std::vector<int> pids;
+ return getProcPids("(kit_spare_");
+}
- pids = getProcPids("(loolkit)");
+std::vector<int> getDocKitPids()
+{
+ return getProcPids("(kitbroker_");
+}
+
+std::vector<int> getKitPids()
+{
+ std::vector<int> pids = getSpareKitPids();
+ for (int pid : getDocKitPids())
+ pids.push_back(pid);
return pids;
}
int getLoolKitProcessCount()
{
- return getProcPids("(loolkit)", true).size();
+ return getKitPids().size();
}
std::vector<int> getForKitPids()
diff --git a/test/test.hpp b/test/test.hpp
index 2f85cac25..7f907673b 100644
--- a/test/test.hpp
+++ b/test/test.hpp
@@ -20,9 +20,14 @@ bool runClientTests(bool standalone, bool verbose);
// ---- Abstraction for standalone vs. WSD ----
-/// Get the list of kit PIDs
+/// Get the list of all kit PIDs
std::vector<int> getKitPids();
+/// Get the list of spare (unused) kit PIDs
+std::vector<int> getSpareKitPids();
+/// Get the list of doc (loaded) kit PIDs
+std::vector<int> getDocKitPids();
+
/// Get the PID of the forkit
std::vector<int> getForKitPids();
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 34e617ee2..c0045b228 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -516,7 +516,7 @@ std::shared_ptr<ChildProcess> getNewChild_Blocks(
// Ugly to have that static global, otoh we know there is just one LOOLWSD
// object. (Even in real Online.)
- lokit_main(uri, LOOLWSD::prisonerServerSocketFD);
+ lokit_main(uri, LOOLWSD::prisonerServerSocketFD, 1);
}).detach();
#endif
More information about the Libreoffice-commits
mailing list