[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp

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


 loolwsd/DocumentBroker.cpp |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 71f2f4921d4edd344d7742ee3b737faf4d3f46e7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Nov 6 22:11:35 2016 -0500

    loolwsd: better use named variable than it->second
    
    Change-Id: Ia336b9001911dfd2cf1c19c1536f52bed7684a2a
    Reviewed-on: https://gerrit.libreoffice.org/30639
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index cbc710c..1613aec 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -38,7 +38,7 @@ void ChildProcess::socketProcessor()
         [this](const std::vector<char>& payload)
         {
             const auto message = LOOLProtocol::getAbbreviatedMessage(payload);
-            LOG_WRN("Recv from child " << this->_pid <<
+            LOG_TRC("Recv from child " << this->_pid <<
                     ": [" << message << "].");
 
             if (UnitWSD::get().filterChildMessage(payload))
@@ -179,13 +179,14 @@ bool DocumentBroker::load(const std::string& sessionId, const std::string& jailI
     }
 
     auto it = _sessions.find(sessionId);
-    if (it == _sessions.end())
+    if (it == _sessions.end() || !it->second)
     {
         LOG_ERR("Session with sessionId [" << sessionId << "] not found while loading");
         return false;
     }
 
-    const Poco::URI& uriPublic = it->second->getPublicUri();
+    auto session = it->second;
+    const Poco::URI& uriPublic = session->getPublicUri();
     LOG_DBG("Loading from URI: " << uriPublic.toString());
 
     _jailId = jailId;
@@ -232,12 +233,12 @@ bool DocumentBroker::load(const std::string& sessionId, const std::string& jailI
         if (!wopifileinfo._userCanWrite)
         {
             LOG_DBG("Setting the session as readonly");
-            it->second->setReadOnly();
+            session->setReadOnly();
         }
 
         if (!wopifileinfo._postMessageOrigin.empty())
         {
-            it->second->sendTextFrame("wopi: postmessageorigin " + wopifileinfo._postMessageOrigin);
+            session->sendTextFrame("wopi: postmessageorigin " + wopifileinfo._postMessageOrigin);
         }
 
         getInfoCallDuration = wopifileinfo._callDuration;
@@ -250,8 +251,8 @@ bool DocumentBroker::load(const std::string& sessionId, const std::string& jailI
     }
 
     LOG_DBG("Setting username [" << username << "] and userId [" << userid << "] for session [" << sessionId << "]");
-    it->second->setUserId(userid);
-    it->second->setUserName(username);
+    session->setUserId(userid);
+    session->setUserName(username);
 
     // Get basic file information from the storage
     const auto fileInfo = _storage->getFileInfo();
@@ -283,7 +284,7 @@ bool DocumentBroker::load(const std::string& sessionId, const std::string& jailI
         callDuration += getInfoCallDuration;
         const std::string msg = "stats: wopiloadduration " + std::to_string(callDuration.count());
         LOG_TRC("Sending to Client [" << msg << "].");
-        it->second->sendTextFrame(msg);
+        session->sendTextFrame(msg);
     }
 
     return true;


More information about the Libreoffice-commits mailing list