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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 2 06:09:06 UTC 2017


 wsd/LOOLWSD.cpp |   26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

New commits:
commit e55be929b0f36e3b85e73db40a1d10fede67004e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 1 15:54:56 2017 -0500

    wsd: reuse rebalanceChildren in getNewChild
    
    Change-Id: Ib5e2750e3b3f49c649c2d14fb5016e427b535912
    Reviewed-on: https://gerrit.libreoffice.org/32621
    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 ac62fcf..02a27c9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -435,34 +435,16 @@ static std::shared_ptr<ChildProcess> getNewChild()
     const auto startTime = chrono::steady_clock::now();
     do
     {
-        // Do the cleanup first.
-        cleanupChildren();
-
-        const int available = NewChildren.size();
-        int balance = LOOLWSD::NumPreSpawnedChildren;
-        if (available == 0)
-        {
-            LOG_WRN("getNewChild: No available child. Sending spawn request to forkit and failing.");
-        }
-        else
-        {
-            balance -= available - 1; // Minus the one we'll dispatch just now.
-            balance = std::max(balance, 0);
-        }
-
-        if (balance > 0)
-        {
-            LOG_DBG("getNewChild: Have " << available << " spare " <<
-                    (available == 1 ? "child" : "children") <<
-                    ", forking " << balance << " more.");
-            forkChildren(balance);
-        }
+        int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
+        ++numPreSpawn; // Replace the one we'll dispatch just now.
+        rebalanceChildren(numPreSpawn);
 
         const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
         if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
         {
             auto child = NewChildren.back();
             NewChildren.pop_back();
+            const auto available = NewChildren.size();
             LOG_DBG("getNewChild: Have " << available << " spare " <<
                     (available == 1 ? "child" : "children") << " after poping [" << child->getPid() << "].");
 


More information about the Libreoffice-commits mailing list