wsd/LOOLWSD.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
New commits: commit 46ef41a6874ad6acc1a1761dc0e54483acd6dceb Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Jan 1 16:02:38 2017 -0500 wsd: force spawning children on startup Otherwise we throttle spawning to allow time to fork the process. If we don't wait we can bomb a loaded server and bring it down. However during startup this is not necessary as there are no in-flight spawn requests. Change-Id: I1beac94571f6d8d96136d32c81310bea6547242b Reviewed-on: https://gerrit.libreoffice.org/32622 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 02a27c9..2fb7987 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -343,7 +343,7 @@ static bool cleanupChildren() return removed; } -static void rebalanceChildren(int balance); +static void rebalanceChildren(int balance, const bool force); /// Called on startup only. static void preForkChildren() @@ -355,7 +355,7 @@ static void preForkChildren() UnitWSD::get().preSpawnCount(numPreSpawn); --numPreSpawn; // ForKit always spawns one child at startup. - rebalanceChildren(numPreSpawn); + rebalanceChildren(numPreSpawn, true); // Force on startup. // Wait until we have at least one child. const auto timeout = std::chrono::milliseconds(CHILD_TIMEOUT_MS); @@ -364,7 +364,7 @@ static void preForkChildren() /// Proactively spawn children processes /// to load documents with alacrity. -static void prespawnChildren() +static void prespawnChildren(const bool force) { // First remove dead DocBrokers, if possible. std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex); @@ -378,10 +378,10 @@ static void prespawnChildren() } const int numPreSpawn = LOOLWSD::NumPreSpawnedChildren; - rebalanceChildren(numPreSpawn); + rebalanceChildren(numPreSpawn, force); } -static void rebalanceChildren(int balance) +static void rebalanceChildren(int balance, const bool force) { Util::assertIsLocked(DocBrokersMutex); Util::assertIsLocked(NewChildrenMutex); @@ -402,7 +402,7 @@ static void rebalanceChildren(int balance) balance -= available; balance -= OutstandingForks; - if (balance > 0 && (rebalance || durationMs >= CHILD_TIMEOUT_MS)) + if (balance > 0 && (force || rebalance || durationMs >= CHILD_TIMEOUT_MS)) { LOG_DBG("prespawnChildren: Have " << available << " spare " << (available == 1 ? "child" : "children") << @@ -437,7 +437,7 @@ static std::shared_ptr<ChildProcess> getNewChild() { int numPreSpawn = LOOLWSD::NumPreSpawnedChildren; ++numPreSpawn; // Replace the one we'll dispatch just now. - rebalanceChildren(numPreSpawn); + rebalanceChildren(numPreSpawn, false); const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS); if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); })) @@ -2205,7 +2205,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/) } // Make sure we have sufficient reserves. - prespawnChildren(); + prespawnChildren(false); } #if ENABLE_DEBUG _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits