loolwsd/LOOLForKit.cpp |   11 +++++++++--
 loolwsd/LOOLWSD.cpp    |   12 ++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 6a907a7a7f70a1ab3d8d99643decb419d684c43f
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sat Apr 9 16:53:33 2016 -0400

    loolwsd: preFork is done once by ForKit already and sanity check count
    
    Change-Id: I8ee843e35198ef88bdf191c11a2a738fae6e6c30
    Reviewed-on: https://gerrit.libreoffice.org/23947
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index 66f313c..e5ff99b 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -71,8 +71,15 @@ private:
         if (tokens[0] == "spawn" && tokens.count() == 2)
         {
             const auto count = std::stoi(tokens[1]);
-            Log::info("Spawning " + tokens[1] + " children on request.");
-            ForkCounter = count;
+            if (count > 0)
+            {
+                Log::info("Spawning " + tokens[1] + " children per request.");
+                ForkCounter = count;
+            }
+            else
+            {
+                Log::warn("Cannot spawn " + std::to_string(count) + " children 
as requested.");
+            }
         }
     }
 
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index b70d110..9dd8755 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -152,13 +152,16 @@ static std::condition_variable newChildrenCV;
 static std::map<std::string, std::shared_ptr<DocumentBroker>> docBrokers;
 static std::mutex docBrokersMutex;
 
-static void forkChildren(int number)
+static void forkChildren(const int number)
 {
     assert(!newChildrenMutex.try_lock()); // check it is held.
 
-    const std::string aMessage = "spawn " + std::to_string(number) + "\n";
-    Log::debug("MasterToForKit: " + aMessage.substr(0, aMessage.length() - 1));
-    IoUtil::writeFIFO(LOOLWSD::ForKitWritePipe, aMessage);
+    if (number > 0)
+    {
+        const std::string aMessage = "spawn " + std::to_string(number) + "\n";
+        Log::debug("MasterToForKit: " + aMessage.substr(0, aMessage.length() - 
1));
+        IoUtil::writeFIFO(LOOLWSD::ForKitWritePipe, aMessage);
+    }
 }
 
 static void preForkChildren()
@@ -166,6 +169,7 @@ static void preForkChildren()
     std::unique_lock<std::mutex> lock(newChildrenMutex);
     int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
     UnitWSD::get().preSpawnCount(numPreSpawn);
+    --numPreSpawn; // ForKit always spawns one child at startup.
     forkChildren(numPreSpawn);
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to