[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Mar 27 01:15:13 UTC 2017
wsd/LOOLWSD.cpp | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
New commits:
commit 94f0663a4513f74421d87a16edd783f9ac9f55c1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu Dec 1 22:04:43 2016 -0500
loolwsd: guarantee DocBrokersMutex locked when alerting
We now guarantee that forkChildren will be invoked
under DocBrokersMutex lock.
This eliminates the case when alertAllUsersInternal
is invoked when this mutex isn't locked.
Change-Id: Ibb259bbb4f380300a90ad2fc7affe6013dd71fef
Reviewed-on: https://gerrit.libreoffice.org/35345
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 673758cc..11b37694 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -270,6 +270,7 @@ bool cleanupDocBrokers()
static void forkChildren(const int number)
{
+ Util::assertIsLocked(DocBrokersMutex);
Util::assertIsLocked(NewChildrenMutex);
if (number > 0)
@@ -332,12 +333,8 @@ static void preForkChildren()
static void prespawnChildren()
{
// First remove dead DocBrokers, if possible.
- std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex, std::defer_lock);
- if (docBrokersLock.try_lock())
- {
- cleanupDocBrokers();
- docBrokersLock.unlock();
- }
+ std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
+ cleanupDocBrokers();
std::unique_lock<std::mutex> lock(NewChildrenMutex, std::defer_lock);
if (!lock.try_lock())
@@ -384,6 +381,7 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
static std::shared_ptr<ChildProcess> getNewChild()
{
+ Util::assertIsLocked(DocBrokersMutex);
std::unique_lock<std::mutex> lock(NewChildrenMutex);
namespace chrono = std::chrono;
@@ -518,6 +516,13 @@ private:
{
LOG_INF("Conversion request for URI [" << fromPath << "].");
+ auto uriPublic = DocumentBroker::sanitizeURI(fromPath);
+ const auto docKey = DocumentBroker::getDocKey(uriPublic);
+
+ // This lock could become a bottleneck.
+ // In that case, we can use a pool and index by publicPath.
+ std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
+
// Request a kit process for this doc.
auto child = getNewChild();
if (!child)
@@ -526,16 +531,10 @@ private:
throw std::runtime_error("Failed to spawn lokit child.");
}
- auto uriPublic = DocumentBroker::sanitizeURI(fromPath);
- const auto docKey = DocumentBroker::getDocKey(uriPublic);
LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
auto docBroker = std::make_shared<DocumentBroker>(uriPublic, docKey, LOOLWSD::ChildRoot, child);
child->setDocumentBroker(docBroker);
- // This lock could become a bottleneck.
- // In that case, we can use a pool and index by publicPath.
- std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
-
cleanupDocBrokers();
// FIXME: What if the same document is already open? Need a fake dockey here?
More information about the Libreoffice-commits
mailing list