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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Mar 14 03:05:14 UTC 2016


 loolwsd/LOOLBroker.cpp |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 2a11e1840abba7f85cdec12a0d314886ad7534a3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Mar 11 17:26:48 2016 -0500

    loolwsd: improved creating kit sessions
    
    Change-Id: Icc49dc37296fcc87928fc5d4fa4a6a18c3413deb
    Reviewed-on: https://gerrit.libreoffice.org/23210
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index aedd8f7..7cf211d 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -329,23 +329,33 @@ public:
             const auto child = findChild(url);
             if (child)
             {
-                if (child->getUrl() == url)
-                    Log::debug("Found URL [" + url + "] hosted on child [" + std::to_string(child->getPid()) + "].");
+                const auto childPid = std::to_string(child->getPid());
+                const auto isEmptyChild = child->getUrl().empty();
+                if (isEmptyChild)
+                    Log::debug("Found URL [" + url + "] hosted on child [" + childPid + "].");
                 else
-                    Log::debug("URL [" + url + "] is not hosted. Using empty child [" + std::to_string(child->getPid()) + "].");
+                    Log::debug("URL [" + url + "] is not hosted. Using empty child [" + childPid + "].");
 
-                if (!createThread(child->getPid(), session, url))
+                if (createThread(child->getPid(), session, url))
                 {
-                    Log::error("Error creating thread [" + session + "] for URL [" + url + "].");
+                    child->setUrl(url);
+                    Log::debug("Child [" + childPid + "] now hosts [" + url + "] for session [" + session + "].");
+                    return;
                 }
 
-                child->setUrl(url);
+                Log::error("Error creating thread [" + session + "] for URL [" + url + "] on child [" + childPid + "].");
+                if (isEmptyChild)
+                {
+                    // This is probably a child in bad state. Rid of it and create new.
+                    removeChild(child->getPid());
+                }
             }
             else
             {
                 Log::info("No children available. Creating more.");
-                ++forkCounter;
             }
+
+            ++forkCounter;
         }
         else if (tokens[0] == "kill" && tokens.count() == 2)
         {


More information about the Libreoffice-commits mailing list