[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 16 01:52:18 UTC 2017
wsd/LOOLWSD.cpp | 57 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 23 deletions(-)
New commits:
commit a06c23e18ab572dfc701188a13576f38e1933c28
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Jan 9 23:39:57 2017 -0500
wsd: refactor create new DocBroker
Change-Id: I3d099bfbd60d68ea0f6fcd38ddaddd4d74c1f017
Reviewed-on: https://gerrit.libreoffice.org/33120
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 4081966..7fda19e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -971,29 +971,7 @@ private:
if (!docBroker)
{
- static_assert(MAX_DOCUMENTS > 0, "MAX_DOCUMENTS must be positive");
- if (DocBrokers.size() + 1 > MAX_DOCUMENTS)
- {
- LOG_ERR("Maximum number of open documents reached.");
- shutdownLimitReached(*ws);
- return nullptr;
- }
-
- // Request a kit process for this doc.
- auto child = getNewChild();
- if (!child)
- {
- // Let the client know we can't serve now.
- LOG_ERR("Failed to get new child. Service Unavailable.");
- throw WebSocketErrorMessageException(SERVICE_UNAVAILABLE_INTERNAL_ERROR);
- }
-
- // Set the one we just created.
- LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
- docBroker = std::make_shared<DocumentBroker>(uriPublic, docKey, LOOLWSD::ChildRoot, child);
- child->setDocumentBroker(docBroker);
- DocBrokers.emplace(docKey, docBroker);
- LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting [" << docKey << "].");
+ docBroker = createNewDocBroker(docKey, ws, uriPublic);
}
// Validate the broker.
@@ -1009,6 +987,39 @@ private:
return docBroker;
}
+ static std::shared_ptr<DocumentBroker> createNewDocBroker(const std::string& docKey,
+ std::shared_ptr<LOOLWebSocket>& ws,
+ const Poco::URI& uriPublic)
+ {
+ Util::assertIsLocked(DocBrokersMutex);
+
+ static_assert(MAX_DOCUMENTS > 0, "MAX_DOCUMENTS must be positive");
+ if (DocBrokers.size() + 1 > MAX_DOCUMENTS)
+ {
+ LOG_ERR("Maximum number of open documents reached.");
+ shutdownLimitReached(*ws);
+ return nullptr;
+ }
+
+ // Request a kit process for this doc.
+ auto child = getNewChild();
+ if (!child)
+ {
+ // Let the client know we can't serve now.
+ LOG_ERR("Failed to get new child. Service Unavailable.");
+ throw WebSocketErrorMessageException(SERVICE_UNAVAILABLE_INTERNAL_ERROR);
+ }
+
+ // Set the one we just created.
+ LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
+ auto docBroker = std::make_shared<DocumentBroker>(uriPublic, docKey, LOOLWSD::ChildRoot, child);
+ child->setDocumentBroker(docBroker);
+ DocBrokers.emplace(docKey, docBroker);
+ LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting [" << docKey << "].");
+
+ return docBroker;
+ }
+
/// Process GET requests.
static void processGetRequest(const std::string& uri, std::shared_ptr<LOOLWebSocket>& ws, const std::string& id,
const Poco::URI& uriPublic, const std::shared_ptr<DocumentBroker>& docBroker, const bool isReadOnly)
More information about the Libreoffice-commits
mailing list