[Libreoffice-commits] online.git: kit/Kit.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Apr 3 05:11:48 UTC 2017


 kit/Kit.cpp            |   20 +++++++++++++++-----
 wsd/DocumentBroker.cpp |    8 +++++---
 wsd/DocumentBroker.hpp |    6 ++++++
 3 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit c9365ad67961aee7b4be0b23883c973c38c088e1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Apr 2 15:55:56 2017 -0400

    wsd: log the DocBroker ID in the Kit as well
    
    This matches the document between WSD and kit,
    making logs much easier to read.
    
    Change-Id: If55a9eb84b4a22d2dc4dd53f5f6ab322ebc3646e
    Reviewed-on: https://gerrit.libreoffice.org/36028
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 6131ba40..35a48673 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -445,12 +445,14 @@ public:
     Document(const std::shared_ptr<lok::Office>& loKit,
              const std::string& jailId,
              const std::string& docKey,
+             const std::string& docId,
              const std::string& url,
              std::shared_ptr<TileQueue> tileQueue,
              const std::shared_ptr<LOOLWebSocket>& ws)
       : _loKit(loKit),
         _jailId(jailId),
         _docKey(docKey),
+        _docId(docId),
         _url(url),
         _tileQueue(std::move(tileQueue)),
         _ws(ws),
@@ -461,7 +463,9 @@ public:
         _stop(false),
         _isLoading(0)
     {
-        LOG_INF("Document ctor for url [" << _url << "] on child [" << _jailId << "].");
+        LOG_INF("Document ctor for [" << _docKey <<
+                "] url [" << _url << "] on child [" << _jailId <<
+                "] and id [" << _docId << "].");
         assert(_loKit);
 
         _callbackThread.start(*this);
@@ -469,8 +473,10 @@ public:
 
     ~Document()
     {
-        LOG_INF("~Document dtor for url [" << _url << "] on child [" << _jailId <<
-                "]. There are " << _sessions.size() << " views.");
+        LOG_INF("~Document dtor for [" << _docKey <<
+                "] url [" << _url << "] on child [" << _jailId <<
+                "] and id [" << _docId << "]. There are " <<
+                _sessions.size() << " views.");
 
         // Wait for the callback worker to finish.
         _stop = true;
@@ -1357,7 +1363,7 @@ private:
 
     void run() override
     {
-        Util::setThreadName("lok_handler");
+        Util::setThreadName("lokit_" + _docId);
 
         LOG_DBG("Thread started.");
 
@@ -1515,7 +1521,10 @@ private:
 private:
     std::shared_ptr<lok::Office> _loKit;
     const std::string _jailId;
+    /// URL-based key. May be repeated during the lifetime of WSD.
     const std::string _docKey;
+    /// Short numerical ID. Unique during the lifetime of WSD.
+    const std::string _docId;
     const std::string _url;
     std::string _jailedUrl;
     std::string _renderOpts;
@@ -1795,6 +1804,7 @@ void lokit_main(const std::string& childRoot,
                     {
                         const std::string& sessionId = tokens[1];
                         const std::string& docKey = tokens[2];
+                        const std::string& docId = tokens[3];
 
                         std::string url;
                         URI::decode(docKey, url);
@@ -1802,7 +1812,7 @@ void lokit_main(const std::string& childRoot,
 
                         if (!document)
                         {
-                            document = std::make_shared<Document>(loKit, jailId, docKey, url, queue, ws);
+                            document = std::make_shared<Document>(loKit, jailId, docKey, docId, url, queue, ws);
                         }
 
                         // Validate and create session.
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 494f21f3..259ca5aa 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -133,6 +133,8 @@ public:
     }
 };
 
+std::atomic<unsigned> DocumentBroker::DocBrokerId(1);
+
 DocumentBroker::DocumentBroker(const std::string& uri,
                                const Poco::URI& uriPublic,
                                const std::string& docKey,
@@ -140,6 +142,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
     _uriOrig(uri),
     _uriPublic(uriPublic),
     _docKey(docKey),
+    _docId(Util::encodeId(DocBrokerId++, 3)),
     _childRoot(childRoot),
     _cacheRoot(getCachePath(uriPublic.toString())),
     _lastSaveTime(std::chrono::steady_clock::now()),
@@ -177,8 +180,7 @@ bool DocumentBroker::isCorrectThread()
 // The inner heart of the DocumentBroker - our poll loop.
 void DocumentBroker::pollThread()
 {
-    static std::atomic<unsigned> DocBrokerId(1);
-    Util::setThreadName("docbroker_" + Util::encodeId(DocBrokerId++, 3));
+    Util::setThreadName("docbroker_" + _docId);
 
     LOG_INF("Starting docBroker polling thread for docKey [" << _docKey << "].");
 
@@ -770,7 +772,7 @@ size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session)
     const auto count = _sessions.size();
 
     // Request a new session from the child kit.
-    const std::string aMessage = "session " + id + ' ' + _docKey;
+    const std::string aMessage = "session " + id + ' ' + _docKey + ' ' + _docId;
     _childProcess->sendTextFrame(aMessage);
 
     // Tell the admin console about this new doc
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 915db5a6..60bf536d 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -359,7 +359,10 @@ private:
 private:
     const std::string _uriOrig;
     const Poco::URI _uriPublic;
+    /// URL-based key. May be repeated during the lifetime of WSD.
     const std::string _docKey;
+    /// Short numerical ID. Unique during the lifetime of WSD.
+    const std::string _docId;
     const std::string _childRoot;
     const std::string _cacheRoot;
     std::shared_ptr<ChildProcess> _childProcess;
@@ -405,6 +408,9 @@ private:
     std::chrono::steady_clock::time_point _threadStart;
     std::chrono::milliseconds _loadDuration;
 
+    /// Unique DocBroker ID for tracing and debugging.
+    static std::atomic<unsigned> DocBrokerId;
+
     static constexpr auto IdleSaveDurationMs = 30 * 1000;
     static constexpr auto AutoSaveDurationMs = 300 * 1000;
 };


More information about the Libreoffice-commits mailing list