loolwsd/DocumentBroker.cpp | 21 +++++++++++++++++++++ loolwsd/DocumentBroker.hpp | 3 +++ loolwsd/LOOLWSD.cpp | 11 ++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-)
New commits: commit 27bed804d5c33ed5c49fc648ccc9b1bb2a3c54a7 Author: Jan Holesovsky <ke...@collabora.com> Date: Thu Sep 15 12:41:57 2016 +0200 bccu#2005: Make sure we don't create 2 jails for the same document. When 2 users opened the document at the very same time, it happened that new jails / instances were created for the document twice. As a solution, insert a dummy (marked to destroy) document into the map of DocumentBrokers, which will lead into synchronization between the two instances. [I suppose the synchronization did not work previously either, as emplace() does not seem to modify the value when the key is already in the map.] diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 043218f..ff3fc1b 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -97,6 +97,27 @@ std::string DocumentBroker::getDocKey(const Poco::URI& uri) return docKey; } +DocumentBroker::DocumentBroker() : + _uriPublic(), + _docKey(), + _childRoot(), + _cacheRoot(), + _childProcess(), + _lastSaveTime(std::chrono::steady_clock::now()), + _markToDestroy(true), + _lastEditableSession(true), + _cursorPosX(0), + _cursorPosY(0), + _cursorWidth(0), + _cursorHeight(0), + _isLoaded(false), + _isModified(false), + _isEditLockHeld(false), + _tileVersion(0) +{ + Log::info("Empty DocumentBroker (marked to destroy) created."); +} + DocumentBroker::DocumentBroker(const Poco::URI& uriPublic, const std::string& docKey, const std::string& childRoot, diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp index fd28ed8..301f896 100644 --- a/loolwsd/DocumentBroker.hpp +++ b/loolwsd/DocumentBroker.hpp @@ -136,6 +136,9 @@ public: static std::string getDocKey(const Poco::URI& uri); + /// Dummy document broker that is marked to destroy. + DocumentBroker(); + DocumentBroker(const Poco::URI& uriPublic, const std::string& docKey, const std::string& childRoot, diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index c2c7068..91746f8 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -565,6 +565,15 @@ private: docBroker = it->second; assert(docBroker); } + else + { + // Store a dummy (marked to destroy) document broker until we + // have the real one, so that the other requests block + Log::debug("Inserting a dummy DocumentBroker for docKey [" + docKey + "] temporarily."); + + std::shared_ptr<DocumentBroker> tempBroker = std::make_shared<DocumentBroker>(); + docBrokers.emplace(docKey, tempBroker); + } } if (docBroker) @@ -645,7 +654,7 @@ private: if (newDoc) { std::unique_lock<std::mutex> lock(docBrokersMutex); - docBrokers.emplace(docKey, docBroker); + docBrokers[docKey] = docBroker; } // Check if readonly session is required _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits