wsd/LOOLWSD.cpp | 57 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 23 deletions(-)
New commits: commit a06c23e18ab572dfc701188a13576f38e1933c28 Author: Ashod Nakashian <[email protected]> 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 <[email protected]> Tested-by: Ashod Nakashian <[email protected]> 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) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
