[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLWSD.cpp loolwsd/PrisonerSession.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Nov 7 06:29:30 UTC 2016


 loolwsd/LOOLWSD.cpp         |    6 +++---
 loolwsd/PrisonerSession.cpp |   24 ++++++++++++++----------
 2 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 52b8a11554498190d68c741e1ca66bc9bf5eeff8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Nov 5 18:00:44 2016 -0400

    loolwsd: lock -> docBrokersLock
    
    Change-Id: Ia1e1e65003967edf092508211be5f3953239e0f6
    Reviewed-on: https://gerrit.libreoffice.org/30627
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index d67a5a0..9b91e1c 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -503,7 +503,7 @@ private:
 
                     // This lock could become a bottleneck.
                     // In that case, we can use a pool and index by publicPath.
-                    std::unique_lock<std::mutex> lock(DocBrokersMutex);
+                    std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
 
                     cleanupDocBrokers();
 
@@ -518,7 +518,7 @@ private:
                     auto sessionsCount = docBroker->addSession(session);
                     LOG_TRC(docKey << ", ws_sessions++: " << sessionsCount);
 
-                    lock.unlock();
+                    docBrokersLock.unlock();
 
                     std::string encodedFrom;
                     URI::encode(docBroker->getPublicUri().getPath(), "", encodedFrom);
@@ -557,7 +557,7 @@ private:
                         LOG_ERR("Failed to get save-as url: " << ex.what());
                     }
 
-                    lock.lock();
+                    docBrokersLock.lock();
                     sessionsCount = docBroker->removeSession(id);
                     if (sessionsCount == 0)
                     {
commit 0dec678b16c9fb31f7be1e0795c54d6799a438a6
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Nov 5 17:48:36 2016 -0400

    loolwsd: PrisonerSession logs updated
    
    Change-Id: I3cae4d77be1c556abef64e0ced05747ef41ddb23
    Reviewed-on: https://gerrit.libreoffice.org/30626
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp
index 06bd90e..76e074c 100644
--- a/loolwsd/PrisonerSession.cpp
+++ b/loolwsd/PrisonerSession.cpp
@@ -39,17 +39,17 @@ PrisonerSession::PrisonerSession(const std::string& id,
     _docBroker(std::move(docBroker)),
     _curPart(0)
 {
-    Log::info("PrisonerSession ctor [" + getName() + "].");
+    LOG_INF("PrisonerSession ctor [" << getName() << "].");
 }
 
 PrisonerSession::~PrisonerSession()
 {
-    Log::info("~PrisonerSession dtor [" + getName() + "].");
+    LOG_INF("~PrisonerSession dtor [" << getName() << "].");
 }
 
 bool PrisonerSession::_handleInput(const char *buffer, int length)
 {
-    Log::trace(getName() + ": handling [" + getAbbreviatedMessage(buffer, length)+ "].");
+    LOG_TRC(getName() + ": handling [" << getAbbreviatedMessage(buffer, length) << "].");
     const std::string firstLine = getFirstLine(buffer, length);
     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
@@ -65,7 +65,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
     if (tokens[0] == "unocommandresult:")
     {
         const std::string stringMsg(buffer, length);
-        Log::info(getName() + ": Command: " + stringMsg);
+        LOG_INF(getName() << ": Command: " << stringMsg);
         const auto index = stringMsg.find_first_of('{');
         if (index != std::string::npos)
         {
@@ -90,6 +90,10 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
                 return true;
             }
         }
+        else
+        {
+            LOG_WRN("Expected json unocommandresult. Ignoring: " << stringMsg);
+        }
     }
     else if (tokens[0] == "error:")
     {
@@ -105,7 +109,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
                     errorKind == "wrongpassword")
                 {
                     forwardToPeer(_peer, buffer, length, isBinary);
-                    Log::warn("Document load failed: " + errorKind);
+                    LOG_WRN("Document load failed: " << errorKind);
                     return false;
                 }
             }
@@ -122,7 +126,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
         std::string url;
         if (!getTokenString(tokens[1], "url", url))
         {
-            Log::error("Bad syntax for: " + firstLine);
+            LOG_ERR("Bad syntax for: " << firstLine);
             return false;
         }
 
@@ -139,7 +143,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
             else
             {
                 // Blank for failure.
-                Log::debug("SaveAs produced no output, producing blank url.");
+                LOG_DBG("SaveAs produced no output, producing blank url.");
                 url.clear();
             }
         }
@@ -221,7 +225,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
             }
             else
             {
-                Log::error("Unable to parse " + firstLine);
+                LOG_ERR("Unable to parse " << firstLine);
             }
         }
         else if (tokens[0] == "renderfont:")
@@ -230,7 +234,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
             if (tokens.count() < 2 ||
                 !getTokenString(tokens[1], "font", font))
             {
-                Log::error("Bad syntax for: " + firstLine);
+                LOG_ERR("Bad syntax for: " << firstLine);
                 return false;
             }
 
@@ -240,7 +244,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
     }
     else
     {
-        Log::info("Ignoring notification on password protected document: " + firstLine);
+        LOG_INF("Ignoring notification on password protected document: " << firstLine);
     }
 
     // Detect json messages, since we must send those as text even though they are multiline.


More information about the Libreoffice-commits mailing list