summaryrefslogtreecommitdiff
path: root/kit
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-09-21 14:39:32 -0400
committerAshod Nakashian <ashnakash@gmail.com>2019-09-22 20:23:27 +0200
commit720c26176a09d8622cb7a8414b555b6f4f986d58 (patch)
tree9c2f6c35e30e49efc904c0a22bc7b0ff4365209b /kit
parent08d7ddcb22a09583b7026e01079f6a0b3ff836e0 (diff)
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/79328 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'kit')
-rw-r--r--kit/ForKit.cpp9
-rw-r--r--kit/Kit.cpp9
-rw-r--r--kit/Kit.hpp5
3 files changed, 14 insertions, 9 deletions
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 81bff060e..2eea47725 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 beebb8aa2..b2a4a8b23 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -490,7 +490,6 @@ public:
// Shrink cache when we exceed the size to maximize
// the chance of hitting these entries in the future.
_cacheSize -= it->second.getData()->size();
-
it = _cache.erase(it);
}
else
@@ -2262,6 +2261,7 @@ protected:
std::string url;
URI::decode(docKey, url);
LOG_INF("New session [" << sessionId << "] request on url [" << url << "].");
+ Util::setThreadName("kitbroker_" + docId);
if (!document)
document = std::make_shared<Document>(_loKit, _jailId, docKey, docId, url, _queue, shared_from_this());
@@ -2428,11 +2428,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
)
{
#if !MOBILEAPP
@@ -2442,7 +2443,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 0f8d90d6c..5c94c1342 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -35,11 +35,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);