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

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


 wsd/LOOLWSD.cpp |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 78f3a4d9b9df3e3aa216fdfb22404e221873e346
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 1 15:53:29 2017 -0500

    wsd: refactor and reuse child forking
    
    Change-Id: Ie5e5966896a728edf032c046bda65c7c9553c27c
    Reviewed-on: https://gerrit.libreoffice.org/32620
    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 f46df92..ac62fcf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -343,6 +343,8 @@ static bool cleanupChildren()
     return removed;
 }
 
+static void rebalanceChildren(int balance);
+
 /// Called on startup only.
 static void preForkChildren()
 {
@@ -353,14 +355,14 @@ static void preForkChildren()
     UnitWSD::get().preSpawnCount(numPreSpawn);
 
     --numPreSpawn; // ForKit always spawns one child at startup.
-    forkChildren(numPreSpawn);
+    rebalanceChildren(numPreSpawn);
 
     // Wait until we have at least one child.
     const auto timeout = std::chrono::milliseconds(CHILD_TIMEOUT_MS);
     NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); });
 }
 
-/// Proatively spawn children processes
+/// Proactively spawn children processes
 /// to load documents with alacrity.
 static void prespawnChildren()
 {
@@ -375,6 +377,15 @@ static void prespawnChildren()
         return;
     }
 
+    const int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
+    rebalanceChildren(numPreSpawn);
+}
+
+static void rebalanceChildren(int balance)
+{
+    Util::assertIsLocked(DocBrokersMutex);
+    Util::assertIsLocked(NewChildrenMutex);
+
     // Do the cleanup first.
     const bool rebalance = cleanupChildren();
 
@@ -388,7 +399,6 @@ static void prespawnChildren()
     }
 
     const auto available = NewChildren.size();
-    int balance = LOOLWSD::NumPreSpawnedChildren;
     balance -= available;
     balance -= OutstandingForks;
 


More information about the Libreoffice-commits mailing list