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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Jan 3 05:59:15 UTC 2017


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

New commits:
commit 5cfef7e76b57f5eb44cd0d973ceb5c2e8902ff5f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Jan 3 00:13:28 2017 -0500

    wsd: construct ClientSession under try
    
    In the rare event that it fails, we will
    cleanup the DocBrokers correctly.
    
    Change-Id: I6f5346c9ec5021bdadc8a01ed389951ca18d07a3
    Reviewed-on: https://gerrit.libreoffice.org/32676
    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 13ab14f..024d3f8 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1010,16 +1010,15 @@ private:
         LOG_CHECK_RET(docBroker && "Null docBroker instance", );
         const auto docKey = docBroker->getDocKey();
 
-        // 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)
-        auto session = std::make_shared<ClientSession>(id, ws, docBroker, uriPublic, isReadOnly);
-
-        // Above this point exceptions are safe and will auto-cleanup.
-        // Below this, we need to cleanup internal references.
+        std::shared_ptr<ClientSession> session;
         try
         {
-            // Now the bridge between the client and kit process is connected
+            // In case of WOPI, 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).
+            session = std::make_shared<ClientSession>(id, ws, docBroker, uriPublic, isReadOnly);
+
+            // Now we have a DocumentBroker and we're ready to process client commands.
             const std::string statusReady = "statusindicator: ready";
             LOG_TRC("Sending to Client [" << statusReady << "].");
             ws->sendFrame(statusReady.data(), statusReady.size());
@@ -1051,6 +1050,7 @@ private:
             return;
         }
 
+        LOG_CHECK_RET(session && "Null ClientSession instance", );
         try
         {
             // Let messages flow.


More information about the Libreoffice-commits mailing list