wsd/LOOLWSD.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
New commits: commit ca551065d9b553adf02305d97d0210f43ef9ef4d Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Wed Dec 21 10:33:48 2016 -0500 wsd: don't reuse DocBrokers iterator to insert Simplifies the code and makes it less error prone. Also add more logging on modifying DocBrokers. Change-Id: I861495912eb4994a32b1ccaccc181fb1aad26e1f Reviewed-on: https://gerrit.libreoffice.org/32294 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 76fe06c..e5ea3dd 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -564,6 +564,7 @@ private: // FIXME: What if the same document is already open? Need a fake dockey here? LOG_DBG("New DocumentBroker for docKey [" << docKey << "]."); DocBrokers.emplace(docKey, docBroker); + LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting."); // Load the document. std::shared_ptr<LOOLWebSocket> ws; @@ -781,8 +782,8 @@ private: cleanupDocBrokers(); // Lookup this document. - auto it = DocBrokers.lower_bound(docKey); - if (it != DocBrokers.end() && it->first == docKey) + auto it = DocBrokers.find(docKey); + if (it != DocBrokers.end()) { // Get the DocumentBroker from the Cache. LOG_DBG("Found DocumentBroker with docKey [" << docKey << "]."); @@ -837,8 +838,8 @@ private: // Retake the lock and recheck if another thread created the DocBroker. docBrokersLock.lock(); - it = DocBrokers.lower_bound(docKey); - if (it != DocBrokers.end() && it->first == docKey) + it = DocBrokers.find(docKey); + if (it != DocBrokers.end()) { // Get the DocumentBroker from the Cache. LOG_DBG("Found DocumentBroker for docKey [" << docKey << "]."); @@ -881,7 +882,8 @@ private: LOG_DBG("New DocumentBroker for docKey [" << docKey << "]."); docBroker = std::make_shared<DocumentBroker>(uriPublic, docKey, LOOLWSD::ChildRoot, child); child->setDocumentBroker(docBroker); - DocBrokers.insert(it, std::make_pair(docKey, docBroker)); + DocBrokers.emplace(docKey, docBroker); + LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting."); } // Validate the broker. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits