[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 2 06:15:32 UTC 2017
wsd/LOOLWSD.cpp | 70 +++++++++++++++++++++++++++-----------------------------
1 file changed, 34 insertions(+), 36 deletions(-)
New commits:
commit 228eb98f4c757288e011a4af5dc6bc1d4770be5c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 1 18:25:19 2017 -0500
wsd: move rebalanceChildren and avoid declaration
Change-Id: Ie8e7e1e28f5496cf5376622cb8f24696e45cb5fc
Reviewed-on: https://gerrit.libreoffice.org/32628
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 0268407..f8e2c3c 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -353,7 +353,40 @@ static bool cleanupChildren()
return removed;
}
-static bool rebalanceChildren(int balance, const bool force);
+/// 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, const bool force)
+{
+ Util::assertIsLocked(DocBrokersMutex);
+ Util::assertIsLocked(NewChildrenMutex);
+
+ // Do the cleanup first.
+ const bool rebalance = cleanupChildren();
+
+ const auto duration = (std::chrono::steady_clock::now() - LastForkRequestTime);
+ const auto durationMs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
+ if (durationMs >= CHILD_TIMEOUT_MS)
+ {
+ // Children taking too long to spawn.
+ // Forget we had requested any, and request anew.
+ OutstandingForks = 0;
+ }
+
+ const auto available = NewChildren.size();
+ balance -= available;
+ balance -= OutstandingForks;
+
+ if (balance > 0 && (force || rebalance || durationMs >= CHILD_TIMEOUT_MS))
+ {
+ LOG_DBG("prespawnChildren: Have " << available << " spare " <<
+ (available == 1 ? "child" : "children") <<
+ ", forking " << balance << " more.");
+ return forkChildren(balance);
+ }
+
+ return false;
+}
/// Called on startup only.
static void preForkChildren()
@@ -392,41 +425,6 @@ static bool prespawnChildren(const bool force)
return rebalanceChildren(numPreSpawn, force);
}
-/// 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, const bool force)
-{
- Util::assertIsLocked(DocBrokersMutex);
- Util::assertIsLocked(NewChildrenMutex);
-
- // Do the cleanup first.
- const bool rebalance = cleanupChildren();
-
- const auto duration = (std::chrono::steady_clock::now() - LastForkRequestTime);
- const auto durationMs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
- if (durationMs >= CHILD_TIMEOUT_MS)
- {
- // Children taking too long to spawn.
- // Forget we had requested any, and request anew.
- OutstandingForks = 0;
- }
-
- const auto available = NewChildren.size();
- balance -= available;
- balance -= OutstandingForks;
-
- if (balance > 0 && (force || rebalance || durationMs >= CHILD_TIMEOUT_MS))
- {
- LOG_DBG("prespawnChildren: Have " << available << " spare " <<
- (available == 1 ? "child" : "children") <<
- ", forking " << balance << " more.");
- return forkChildren(balance);
- }
-
- return false;
-}
-
static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
{
std::unique_lock<std::mutex> lock(NewChildrenMutex);
More information about the Libreoffice-commits
mailing list