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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Jan 17 04:13:33 UTC 2017


 wsd/LOOLWSD.cpp |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 73cd57d09cbcf01dd29e74ea895b035180803f34
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Jan 16 23:09:55 2017 -0500

    wsd: not spawnining is not failure to rebalance children
    
    Change-Id: Iab29073a610ba19f3c25584fbdd08a7407258e1b
    Reviewed-on: https://gerrit.libreoffice.org/33201
    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 c9f9e7c..01e929e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -307,7 +307,8 @@ bool cleanupDocBrokers()
 }
 
 /// Forks as many children as requested.
-/// Returns true only if at least one child was requested to spawn.
+/// Returns the number of children requested to spawn,
+/// -1 for error.
 static bool forkChildren(const int number)
 {
     Util::assertIsLocked(DocBrokersMutex);
@@ -328,13 +329,14 @@ static bool forkChildren(const int number)
         {
             OutstandingForks += number;
             LastForkRequestTime = std::chrono::steady_clock::now();
-            return true;
+            return number;
         }
 
         LOG_ERR("No forkit pipe while rebalancing children.");
+        return -1; // Fail.
     }
 
-    return false;
+    return 0;
 }
 
 /// Cleans up dead children.
@@ -359,8 +361,9 @@ static bool cleanupChildren()
 
 /// Decides how many children need spawning and spanws.
 /// When force is true, no check of elapsed time since last request is done.
-/// Returns true only if at least one child was requested to spawn.
-static bool rebalanceChildren(int balance)
+/// Returns the number of children requested to spawn,
+/// -1 for error.
+static int rebalanceChildren(int balance)
 {
     Util::assertIsLocked(DocBrokersMutex);
     Util::assertIsLocked(NewChildrenMutex);
@@ -391,7 +394,7 @@ static bool rebalanceChildren(int balance)
         return forkChildren(balance);
     }
 
-    return true;
+    return 0;
 }
 
 /// Called on startup only.
@@ -445,7 +448,7 @@ static bool prespawnChildren()
     }
 
     const int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
-    return rebalanceChildren(numPreSpawn);
+    return (rebalanceChildren(numPreSpawn) > 0);
 }
 
 static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
@@ -475,7 +478,7 @@ static std::shared_ptr<ChildProcess> getNewChild()
         LOG_DBG("getNewChild: Rebalancing children.");
         int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
         ++numPreSpawn; // Replace the one we'll dispatch just now.
-        if (!rebalanceChildren(numPreSpawn))
+        if (rebalanceChildren(numPreSpawn) < 0)
         {
             // Fatal. Let's fail and retry at a higher level.
             LOG_DBG("getNewChild: rebalancing of children failed.");


More information about the Libreoffice-commits mailing list