loolwsd/LOOLWSD.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
New commits:
commit 21bf2ff12995fc82dbe8bee438a7017831ec2aea
Author: Ashod Nakashian <[email protected]>
Date: Sat May 7 12:16:09 2016 -0400
loolwsd: give children time to settle after forking before checking
Change-Id: If29d564f16a29f94791c28f5cb03be2ebf7219f3
Reviewed-on: https://gerrit.libreoffice.org/24740
Reviewed-by: Ashod Nakashian <[email protected]>
Tested-by: Ashod Nakashian <[email protected]>
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index fdaaf78..2495b50 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -154,6 +154,7 @@ static bool NoCapsForKit = false;
static std::vector<std::shared_ptr<ChildProcess>> newChildren;
static std::mutex newChildrenMutex;
static std::condition_variable newChildrenCV;
+static std::chrono::steady_clock::time_point lastForkRequestTime;
static std::map<std::string, std::shared_ptr<DocumentBroker>> docBrokers;
static std::mutex docBrokersMutex;
// Sessions to pre-spawned child processes that have connected but are not yet
assigned a
@@ -175,6 +176,7 @@ static void forkChildren(const int number)
const std::string aMessage = "spawn " + std::to_string(number) + "\n";
Log::debug("MasterToForKit: " + aMessage.substr(0, aMessage.length() -
1));
IoUtil::writeFIFO(LOOLWSD::ForKitWritePipe, aMessage);
+ lastForkRequestTime = std::chrono::steady_clock::now();
}
}
@@ -197,6 +199,13 @@ static void prespawnChildren()
return;
}
+ const auto duration = (std::chrono::steady_clock::now() -
lastForkRequestTime);
+ if
(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() <=
CHILD_TIMEOUT_SECS * 1000)
+ {
+ // Not enough time passed to balance children.
+ return;
+ }
+
for (int i = newChildren.size() - 1; i >= 0; --i)
{
if (!newChildren[i]->isAlive())
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits