[Libreoffice-commits] online.git: 2 commits - common/Util.cpp wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Mar 15 10:29:41 UTC 2019


 common/Util.cpp        |    8 ++++++--
 wsd/ClientSession.cpp  |    2 ++
 wsd/DocumentBroker.cpp |   16 ++++++++++++++++
 wsd/DocumentBroker.hpp |    8 ++++----
 wsd/LOOLWSD.cpp        |    5 +++--
 5 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit 5627c767abe256303c584d3663ada716c1c1d199
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Mar 15 10:51:19 2019 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Mar 15 11:27:38 2019 +0100

    Anonymization: don't log when it is disabled.
    
    Also fix unexpected concatenation error in Poco::URI::encode generating
    eg. authorid=localhost0 xauthorid=localhost0localhost0 in the output.
    
    Change-Id: I560e47e31884eeb1c662f468436ed7541cfb082d

diff --git a/common/Util.cpp b/common/Util.cpp
index 0ca96021a..ab21e0c96 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -658,7 +658,9 @@ namespace Util
         if (plain.empty() || anonymized.empty())
             return;
 
-        LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "].");
+        auto &log = Log::logger();
+        if (log.trace() && plain != anonymized)
+            LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "].");
 
         std::unique_lock<std::mutex> lock(AnonymizedMutex);
 
@@ -673,7 +675,9 @@ namespace Util
             const auto it = AnonymizedStrings.find(text);
             if (it != AnonymizedStrings.end())
             {
-                LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "].");
+                auto &log = Log::logger();
+                if (log.trace() && text != it->second)
+                    LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "].");
                 return it->second;
             }
         }
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 6b61765ae..7f5938bb1 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -419,12 +419,14 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
             std::string encodedUserId;
             Poco::URI::encode(getUserId(), "", encodedUserId);
             oss << " authorid=" << encodedUserId;
+            encodedUserId = "";
             Poco::URI::encode(LOOLWSD::anonymizeUsername(getUserId()), "", encodedUserId);
             oss << " xauthorid=" << encodedUserId;
 
             std::string encodedUserName;
             Poco::URI::encode(getUserName(), "", encodedUserName);
             oss << " author=" << encodedUserName;
+            encodedUserName = "";
             Poco::URI::encode(LOOLWSD::anonymizeUsername(getUserName()), "", encodedUserName);
             oss << " xauthor=" << encodedUserName;
         }
commit d8bb92cdcf83216ae5a56b8602cbd9f7c72b4975
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Mar 12 15:41:54 2019 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Mar 15 11:27:31 2019 +0100

    Don't count convert-to connections vs. the document count.
    
    Change-Id: I350905fb98c503ae8f22a377e4af5cbcb9f3c52d

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 3194d4f58..cc4068bc3 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1847,8 +1847,24 @@ void DocumentBroker::getIOStats(uint64_t &sent, uint64_t &recv)
     }
 }
 
+static std::atomic<size_t> NumConverters;
+
+size_t ConvertToBroker::getInstanceCount()
+{
+    return NumConverters;
+}
+
+ConvertToBroker::ConvertToBroker(const std::string& uri,
+                                 const Poco::URI& uriPublic,
+                                 const std::string& docKey)
+    : DocumentBroker(uri, uriPublic, docKey)
+{
+    NumConverters++;
+}
+
 ConvertToBroker::~ConvertToBroker()
 {
+    NumConverters--;
     if (!_uriOrig.empty())
     {
         // Remove source file and directory
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index bde8b24e4..134ad8b77 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -476,11 +476,11 @@ public:
     /// Construct DocumentBroker with URI and docKey
     ConvertToBroker(const std::string& uri,
                     const Poco::URI& uriPublic,
-                    const std::string& docKey)
-        : DocumentBroker(uri, uriPublic, docKey)
-    {
-    }
+                    const std::string& docKey);
     virtual ~ConvertToBroker();
+
+    /// How many live conversions are running.
+    static size_t getInstanceCount();
 };
 
 #endif
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 1f0e4dc0a..b3f1bfaf3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -254,8 +254,8 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 inline void checkSessionLimitsAndWarnClients()
 {
 #if !MOBILEAPP
-
-    if (DocBrokers.size() > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= LOOLWSD::MaxConnections)
+    size_t docBrokerCount = DocBrokers.size() - ConvertToBroker::getInstanceCount();
+    if (docBrokerCount > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= LOOLWSD::MaxConnections)
     {
         const std::string info = Poco::format(PAYLOAD_INFO_LIMIT_REACHED, LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
         LOG_INF("Sending client 'limitreached' message: " << info);
@@ -2948,6 +2948,7 @@ public:
                   << "[ " << DocBrokers.size() << " ]:\n";
         for (auto &i : DocBrokers)
             i.second->dumpState(os);
+        os << "Converter count: " << ConvertToBroker::getInstanceCount() << "\n";
 
         Socket::InhibitThreadChecks = false;
         SocketPoll::InhibitThreadChecks = false;


More information about the Libreoffice-commits mailing list