[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun Jan 1 04:18:45 UTC 2017


 wsd/LOOLWSD.cpp |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 759564368d9dbd24bf1ad65ebfb52f080aa81e38
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Dec 23 22:43:38 2016 -0500

    wsd: reorganize DocBrokers lookup
    
    Avoid unnecessary code under lock
    or when DocBrokers is updated,
    which requires removal on exception.
    
    Change-Id: Id01aed42cd66616b910b7e16a8a1ed6c1d1e74b9
    Reviewed-on: https://gerrit.libreoffice.org/32558
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8a031df..5575907 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -787,27 +787,36 @@ private:
         LOG_INF("Sanitized url [" << uri << "] to [" << uriPublic.toString() <<
                 "] and mapped to docKey [" << docKey << "].");
 
-        std::shared_ptr<DocumentBroker> docBroker;
+        // Check if readonly session is required
+        bool isReadOnly = false;
+        for (const auto& param : uriPublic.getQueryParameters())
+        {
+            LOG_DBG("Query param: " << param.first << ", value: " << param.second);
+            if (param.first == "permission" && param.second == "readonly")
+            {
+                isReadOnly = true;
+            }
+        }
 
         std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
 
+        cleanupDocBrokers();
+
         if (TerminationFlag)
         {
             LOG_ERR("Termination flag set. No loading new session [" << id << "]");
             return;
         }
 
-        cleanupDocBrokers();
+        std::shared_ptr<DocumentBroker> docBroker;
 
         // Lookup this document.
         auto it = DocBrokers.find(docKey);
-        if (it != DocBrokers.end())
+        if (it != DocBrokers.end() && it->second)
         {
             // Get the DocumentBroker from the Cache.
             LOG_DBG("Found DocumentBroker with docKey [" << docKey << "].");
             docBroker = it->second;
-            assert(docBroker);
-
             if (docBroker->isMarkedToDestroy())
             {
                 // Let the waiting happen in parallel to new requests.
@@ -916,15 +925,6 @@ private:
 
         docBrokersLock.unlock();
 
-        // Check if readonly session is required
-        bool isReadOnly = false;
-        for (const auto& param : uriPublic.getQueryParameters())
-        {
-            LOG_DBG("Query param: " << param.first << ", value: " << param.second);
-            if (param.first == "permission")
-                isReadOnly = param.second == "readonly";
-        }
-
         // In case of WOPI and if this session is not set as readonly, it might be set so
         // later after making a call to WOPI host which tells us the permission on files
         // (UserCanWrite param)


More information about the Libreoffice-commits mailing list