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

Henry Castro hcastro at collabora.com
Thu Jan 7 19:38:54 PST 2016


 loolwsd/LOOLKit.cpp |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

New commits:
commit 2c7b4490ec7f877f891096a6ad108e5b87364adf
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Jan 7 23:23:41 2016 -0400

    loolwsd: ensure to remove the connection of unloaded document

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index ba7ab62..8ac56d3 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -560,6 +560,24 @@ public:
         }
     }
 
+    void purgeSessions()
+    {
+        for (auto it =_connections.cbegin(); it != _connections.cend(); )
+        {
+            if (!it->second->isRunning())
+            {
+                _connections.erase(it++);
+                continue;
+            }
+            it++;
+        }
+    }
+
+    bool hasConnections()
+    {
+        return _connections.size() > 0;
+    }
+
 private:
 
     void onLoad(LibreOfficeKitDocument *loKitDocument, const int viewId)
@@ -703,6 +721,18 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s
 
                     if (tokens[0] == "search")
                     {
+                        // remove document that is unloaded
+                        for (auto it =_documents.cbegin(); it != _documents.cend(); )
+                        {
+                            it->second->purgeSessions();
+                            if (!it->second->hasConnections())
+                            {
+                                _documents.erase(it++);
+                                continue;
+                            }
+                            it++;
+                        }
+
                         if (_documents.empty())
                         {
                             aResponse += "empty \r\n";


More information about the Libreoffice-commits mailing list