[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sat Dec 31 23:23:22 UTC 2016
wsd/LOOLWSD.cpp | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
New commits:
commit 8481e9c21d1f0b8435b96c35fa95aaec2100803b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Dec 21 18:11:38 2016 -0500
wsd: improved logging of child process management
Change-Id: Iaa1f333e3fe427219f244f913834a46a80377032
Reviewed-on: https://gerrit.libreoffice.org/32549
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 607372f..dc22e7f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -329,7 +329,7 @@ static bool cleanupChildren()
{
if (!NewChildren[i]->isAlive())
{
- LOG_WRN("Removing unused dead child [" << NewChildren[i]->getPid() << "].");
+ LOG_WRN("Removing dead spare child [" << NewChildren[i]->getPid() << "].");
NewChildren.erase(NewChildren.begin() + i);
removed = true;
}
@@ -382,12 +382,16 @@ static void prespawnChildren()
OutstandingForks = 0;
}
+ const auto available = NewChildren.size();
int balance = LOOLWSD::NumPreSpawnedChildren;
- balance -= NewChildren.size();
+ balance -= available;
balance -= OutstandingForks;
- if (rebalance || durationMs >= CHILD_TIMEOUT_MS)
+ if (balance > 0 && (rebalance || durationMs >= CHILD_TIMEOUT_MS))
{
+ LOG_DBG("prespawnChildren: Have " << available << " spare " <<
+ (available == 1 ? "child" : "children") <<
+ ", forking " << balance << " more.");
forkChildren(balance);
}
}
@@ -399,9 +403,10 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
--OutstandingForks;
NewChildren.emplace_back(child);
const auto count = NewChildren.size();
+ LOG_INF("Have " << count << " spare " <<
+ (count == 1 ? "child" : "children") << " after adding.");
lock.unlock();
- LOG_INF("Have " << count << " " << (count == 1 ? "child." : "children."));
NewChildrenCV.notify_one();
return count;
}
@@ -430,14 +435,21 @@ static std::shared_ptr<ChildProcess> getNewChild()
balance = std::max(balance, 0);
}
- LOG_DBG("getNewChild: Have " << available << " children, forking " << balance);
- forkChildren(balance);
+ if (balance > 0)
+ {
+ LOG_DBG("getNewChild: Have " << available << " spare " <<
+ (available == 1 ? "child" : "children") <<
+ ", forking " << balance << " more.");
+ forkChildren(balance);
+ }
const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
{
auto child = NewChildren.back();
NewChildren.pop_back();
+ LOG_DBG("getNewChild: Have " << available << " spare " <<
+ (available == 1 ? "child" : "children") << " after poping.");
// Validate before returning.
if (child && child->isAlive())
More information about the Libreoffice-commits
mailing list