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

Pranav Kant pranavk at collabora.co.uk
Wed Sep 7 14:31:51 UTC 2016


 loolwsd/LOOLKit.cpp |   30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

New commits:
commit 1b0088ab697881f2f54a23366febfe6e18c6bb25
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Sep 7 11:37:12 2016 +0200

    loolwsd: Comments
    
    Change-Id: Ia4e91f18d695ac2249fa1139afbcb5b3f65f87ba

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 3d52244..e3519fb 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -936,6 +936,7 @@ private:
         }
     }
 
+    /// Notify all currently active sessions of session with given 'sessionId'
     void notifyOtherSessions(const std::string& sessionId, const std::string& message) const override
     {
         std::unique_lock<std::mutex> lock(_mutex);
@@ -953,6 +954,7 @@ private:
         }
     }
 
+    /// Notify session (with given 'sessionId') of other currently active views
     void notifyCurrentViewOfOtherViews(const std::string& sessionId) const override
     {
         std::unique_lock<std::mutex> lock(_mutex);
commit 3f421be4dab86fcfc2f48c7192cb9a2b79a74c32
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sat Sep 3 02:27:37 2016 +0530

    loolwsd: Code reuse, and don't send 'remview' message to inactive clients
    
    Use the existing function notifyOtherSessions() to broadcast the
    message.
    
    The function also takes care of sending this message only to
    active clients.
    
    Change-Id: I98d40429de17463167a67cb10ba59381a0cbc525

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index bd9928f..3d52244 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -419,7 +419,6 @@ public:
         Log::info("Document ctor for url [" + _url + "] on child [" + _jailId +
                   "] LOK_VIEW_CALLBACK=" + std::to_string(_multiView) + ".");
         assert(_loKit && _loKit->get());
-
         _callbackThread.start(*this);
     }
 
@@ -910,22 +909,12 @@ private:
         Log::info("Unloading [" + sessionId + "].");
 
         // Broadcast the demise and removal of session.
-        {
-            std::unique_lock<std::mutex> lock(_mutex);
-
-            // We should be removed by this point, otherwise
-            // our closed connection will throw, if not segfault.
-            for (const auto& pair : _connections)
-            {
-                assert(sessionId != pair.second->getSessionId() && "Unloading connection still lingering.");
-                pair.second->getSession()->sendTextFrame("remview: " + std::to_string(session.getViewId()));
-            }
+        notifyOtherSessions(sessionId, "remview: " + std::to_string(session.getViewId()));
 
-            if (_loKitDocument == nullptr)
-            {
-                Log::error("Unloading session [" + sessionId + "] without loKitDocument.");
-                return;
-            }
+        if (_loKitDocument == nullptr)
+        {
+            Log::error("Unloading session [" + sessionId + "] without loKitDocument.");
+            return;
         }
 
         --_clientViews;
commit 9edb1c2994b9ab5f6d6d75e1e715deb43a0ae3c8
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sat Sep 3 01:51:04 2016 +0530

    loolwsd: Don't send addview notification to inactive clients
    
    Change-Id: I4771e4bf12057fdc7099e9433d3b7dc2198cb265

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index b62754d..bd9928f 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -956,7 +956,7 @@ private:
             if (it.second->isRunning() && it.second->getSessionId() != sessionId)
             {
                 auto session = it.second->getSession();
-                if (session)
+                if (session && session->isActive())
                 {
                     session->sendTextFrame(message);
                 }
@@ -976,6 +976,11 @@ private:
         }
 
         auto currentSession = it->second->getSession();
+        if (!currentSession->isActive())
+        {
+            return;
+        }
+
         for (auto& connectionIt: _connections)
         {
             if (connectionIt.second->isRunning() && connectionIt.second->getSessionId() != sessionId)


More information about the Libreoffice-commits mailing list