[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Apr 5 03:00:39 UTC 2016
loolwsd/LOOLWSD.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
New commits:
commit 4bc26f25d51c336bf904c0b7e07a26bc486959a4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Apr 4 22:40:18 2016 -0400
loolwsd: wait for new child instances if none is available
Change-Id: If7de4ae73e9432694a0cf032b19d7e0ab9c5a9d1
Reviewed-on: https://gerrit.libreoffice.org/23824
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 9c29d63..6b05fca 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -172,8 +172,10 @@ using Poco::XML::Node;
using Poco::XML::NodeList;
/// New LOK child processes ready to host documents.
+//TODO: Move to a more sensible namespace.
static std::vector<std::shared_ptr<ChildProcess>> newChilds;
static std::mutex newChildsMutex;
+static std::condition_variable newChildsCV;
static std::map<std::string, std::shared_ptr<DocumentBroker>> docBrokers;
static std::mutex docBrokersMutex;
@@ -199,7 +201,8 @@ std::shared_ptr<ChildProcess> getNewChild()
IoUtil::writeFIFO(LOOLWSD::BrokerWritePipe, aMessage);
}
- if (available > 0)
+ const auto timeout = std::chrono::milliseconds(CHILD_TIMEOUT_SECS * 1000);
+ if (newChildsCV.wait_for(lock, timeout, [](){ return !newChilds.empty(); }))
{
auto child = newChilds.back();
newChilds.pop_back();
@@ -671,6 +674,7 @@ public:
std::unique_lock<std::mutex> lock(newChildsMutex);
newChilds.emplace_back(std::make_shared<ChildProcess>(pid, ws));
Log::info("Have " + std::to_string(newChilds.size()) + " childs.");
+ newChildsCV.notify_one();
return;
}
More information about the Libreoffice-commits
mailing list