[Libreoffice-commits] online.git: kit/Kit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 2 05:56:05 UTC 2017


 kit/Kit.cpp |   37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

New commits:
commit c4d368149e74379a5c66eb5d468aeaa16121fc44
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Dec 23 16:19:05 2016 -0500

    wsd: simplify session purging
    
    Change-Id: Ied5206dc524c8ff772c175ec4c78c23b9a305a32
    Reviewed-on: https://gerrit.libreoffice.org/32602
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f40b56c..92a097b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -502,7 +502,6 @@ public:
     size_t purgeSessions()
     {
         std::vector<std::shared_ptr<ChildSession>> deadSessions;
-        size_t numRunning = 0;
         size_t num_sessions = 0;
         {
             std::unique_lock<std::mutex> lock(_mutex, std::defer_lock);
@@ -516,35 +515,25 @@ public:
             // bluntly exit, no need to clean up our own data structures. Also, there is a bug that
             // causes the deadSessions.clear() call below to crash in some situations when the last
             // session is being removed.
-            for (auto it = _sessions.cbegin(); it != _sessions.cend(); ++it)
+            for (auto it = _sessions.cbegin(); it != _sessions.cend(); )
             {
-                if (!it->second->isCloseFrame())
-                    numRunning++;
-            }
-
-            if (numRunning > 0)
-            {
-                for (auto it = _sessions.cbegin(); it != _sessions.cend(); )
+                if (it->second->isCloseFrame())
                 {
-                    if (it->second->isCloseFrame())
-                    {
-                        deadSessions.push_back(it->second);
-                        it = _sessions.erase(it);
-                    }
-                    else
-                    {
-                        ++it;
-                    }
+                    deadSessions.push_back(it->second);
+                    it = _sessions.erase(it);
+                }
+                else
+                {
+                    ++it;
                 }
             }
 
             num_sessions = _sessions.size();
-        }
-
-        if (numRunning == 0)
-        {
-            LOG_INF("No more sessions, exiting bluntly");
-            std::_Exit(Application::EXIT_OK);
+            if (num_sessions == 0)
+            {
+                LOG_INF("No more sessions, exiting bluntly");
+                std::_Exit(Application::EXIT_OK);
+            }
         }
 
         // Don't destroy sessions while holding our lock.


More information about the Libreoffice-commits mailing list