wsd/ClientSession.cpp | 9 +++------ wsd/DocumentBroker.cpp | 29 +++++++++++++++++------------ wsd/DocumentBroker.hpp | 2 +- wsd/LOOLWSD.cpp | 2 +- wsd/TestStubs.cpp | 2 +- 5 files changed, 23 insertions(+), 21 deletions(-)
New commits: commit d53ce5511dfe7989954f5ec4f882799607a6b662 Author: Ashod Nakashian <[email protected]> Date: Sun Jan 14 11:16:10 2018 -0500 wsd: const and cosmetics Non-functional changes. Change-Id: I7c52386e2f870d29fd62c6dae6f37f4a58c2396b Reviewed-on: https://gerrit.libreoffice.org/47882 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 5b0881bf..9fdf8ba7 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -586,8 +586,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt } // Save to Storage and log result. - std::string id = getId(); - docBroker->saveToStorage(id, success, result); + docBroker->saveToStorage(getId(), success, result); if (!isCloseFrame()) forwardToClient(payload); @@ -714,8 +713,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt LOG_TRC("Removing save-as ClientSession after conversion."); // Remove us. - std::string id = getId(); - docBroker->removeSession(id); + docBroker->removeSession(getId()); // Now terminate. docBroker->stop(); @@ -876,8 +874,7 @@ void ClientSession::onDisconnect() // We issue a force-save when last editable (non-readonly) session is going away // and defer destroying the last session and the docBroker. - std::string id = getId(); - docBroker->removeSession(id, true); + docBroker->removeSession(getId(), true); } catch (const UnauthorizedRequestException& exc) { diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 97ef771f..deb2cfc9 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -177,7 +177,7 @@ void DocumentBroker::startThread() _poll->startThread(); } -void DocumentBroker::assertCorrectThread() +void DocumentBroker::assertCorrectThread() const { _poll->assertCorrectThread(); } @@ -226,15 +226,15 @@ void DocumentBroker::pollThread() _childProcess->setDocumentBroker(shared_from_this()); LOG_INF("Doc [" << _docKey << "] attached to child [" << _childProcess->getPid() << "]."); - auto last30SecCheckTime = std::chrono::steady_clock::now(); - static const bool AutoSaveEnabled = !std::getenv("LOOL_NO_AUTOSAVE"); static const size_t IdleDocTimeoutSecs = LOOLWSD::getConfigValue<int>( "per_document.idle_timeout_secs", 3600); + // Used to accumulate B/W deltas. uint64_t adminSent = 0; uint64_t adminRecv = 0; auto lastBWUpdateTime = std::chrono::steady_clock::now(); + auto last30SecCheckTime = std::chrono::steady_clock::now(); // Main polling loop goodness. while (!_stop && _poll->continuePolling() && !TerminationFlag) @@ -254,7 +254,7 @@ void DocumentBroker::pollThread() // connection drop transiently reduces this. (sent > adminSent ? (sent - adminSent): uint64_t(0)), (recv > adminRecv ? (recv - adminRecv): uint64_t(0))); - LOG_INF("Doc [" << _docKey << "] added sent: " << sent << " recv: " << recv << " bytes to totals"); + LOG_DBG("Doc [" << _docKey << "] added sent: " << sent << " recv: " << recv << " bytes to totals"); adminSent = sent; adminRecv = recv; } @@ -263,7 +263,7 @@ void DocumentBroker::pollThread() std::chrono::duration_cast<std::chrono::milliseconds> (now - _lastSaveRequestTime).count() <= COMMAND_TIMEOUT_MS) { - // We are saving, nothing more to do but wait. + // We are saving, nothing more to do but wait (until we save or we timeout). continue; } @@ -668,6 +668,7 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId, LOG_TRC("Document will be saved forcefully to storage."); _storage->forceSave(); } + const bool res = saveToStorageInternal(sessionId, success, result); // If marked to destroy, or session is disconnected, remove. @@ -1071,14 +1072,18 @@ size_t DocumentBroker::removeSessionInternal(const std::string& id) // Remove. The caller must have a reference to the session // in question, lest we destroy from underneith them. _sessions.erase(it); - const auto count = _sessions.size(); - LOG_TRC("Removed " << (readonly ? "readonly" : "non-readonly") << - " session [" << id << "] from docKey [" << - _docKey << "] to have " << count << " sessions."); - for (const auto& pair : _sessions) + + auto logger = Log::trace(); + if (logger.enabled()) { - LOG_TRC("Session: " << pair.second->getName()); + logger << "Removed " << (readonly ? "readonly" : "non-readonly") + << " session [" << id << "] from docKey [" + << _docKey << "] to have " << count << " sessions:"; + for (const auto& pair : _sessions) + logger << pair.second->getId() << ' '; + + LOG_END(logger); } // Let the child know the client has disconnected. @@ -1641,7 +1646,7 @@ void DocumentBroker::dumpState(std::ostream& os) os << "\n doc id: " << _docId; os << "\n num sessions: " << _sessions.size(); os << "\n last editable?: " << _lastEditableSession; - std::time_t t = std::chrono::system_clock::to_time_t( + const std::time_t t = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() + (_lastSaveTime - std::chrono::steady_clock::now())); os << "\n last saved: " << std::ctime(&t); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 0e278150..4b4b458d 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -266,7 +266,7 @@ public: /// Are we running in either shutdown, or the polling thread. /// Asserts in the debug builds, otherwise just logs. - void assertCorrectThread(); + void assertCorrectThread() const; /// Pretty print internal state to a stream. void dumpState(std::ostream& os); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 289df5aa..0750a0b2 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1420,7 +1420,7 @@ static std::shared_ptr<DocumentBroker> findOrCreateDocBroker(WebSocketHandler& w std::shared_ptr<DocumentBroker> docBroker; // Lookup this document. - auto it = DocBrokers.find(docKey); + const auto it = DocBrokers.find(docKey); if (it != DocBrokers.end() && it->second) { // Get the DocumentBroker from the Cache. diff --git a/wsd/TestStubs.cpp b/wsd/TestStubs.cpp index 434d8e2c..963bf961 100644 --- a/wsd/TestStubs.cpp +++ b/wsd/TestStubs.cpp @@ -15,6 +15,6 @@ #include "DocumentBroker.hpp" -void DocumentBroker::assertCorrectThread() {} +void DocumentBroker::assertCorrectThread() const {} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
