wsd/LOOLWSD.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
New commits: commit 156493efc34113d9a373b3e0d0669f8814232cee Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Apr 11 23:18:33 2017 -0400 wsd: avoid miscounting outstanding child forks The number of outstanding child forks can become negative if more children are spawned than requested. This prevents such a scenario from permanently preventing WSD from spawning new children, which happens when OutstandingForks is negative. Change-Id: Ief1e56d7b4a079e097ca2d18bd90a01d935f6b30 Reviewed-on: https://gerrit.libreoffice.org/36437 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 1752dd74d61aeb17c826be28b167d3e7169d0189) Reviewed-on: https://gerrit.libreoffice.org/36438 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index d5a7fd0b..57c63523 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -332,7 +332,7 @@ static int rebalanceChildren(int balance) const auto duration = (std::chrono::steady_clock::now() - LastForkRequestTime); const auto durationMs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count(); - if (OutstandingForks > 0 && durationMs >= CHILD_TIMEOUT_MS) + if (OutstandingForks != 0 && durationMs >= CHILD_TIMEOUT_MS) { // Children taking too long to spawn. // Forget we had requested any, and request anew. @@ -371,6 +371,10 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child) std::unique_lock<std::mutex> lock(NewChildrenMutex); --OutstandingForks; + // Prevent from going -ve if we have unexpected children. + if (OutstandingForks < 0) + ++OutstandingForks; + NewChildren.emplace_back(child); const auto count = NewChildren.size(); LOG_INF("Have " << count << " spare " << _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits