[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 32 wsd/DocumentBroker.hpp |7 +++ wsd/LOOLWSD.cpp| 38 ++ 3 files changed, 41 insertions(+), 36 deletions(-) New commits: commit da944760a62a82c21a32017b9c04526ea00d3cbd Author: Michael Meeks AuthorDate: Wed Mar 4 21:56:48 2020 + Commit: Michael Meeks CommitDate: Thu Mar 5 17:10:36 2020 +0100 re-factor: move createNewSession into DocumentBroker. Change-Id: I78f07a61fd79dfdd1c0d0ef21cf19218beec46ee Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90025 Tested-by: Jenkins CollaboraOffice Reviewed-by: Michael Meeks diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 74b827678..18bcdce63 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1497,6 +1497,38 @@ void DocumentBroker::finalRemoveSession(const std::string& id) } } +std::shared_ptr DocumentBroker::createNewClientSession(const WebSocketHandler* ws, + const std::string& id, + const Poco::URI& uriPublic, + const bool isReadOnly, + const std::string& hostNoTrust) +{ +try +{ +// Now we have a DocumentBroker and we're ready to process client commands. +if (ws) +{ +const std::string statusReady = "statusindicator: ready"; +LOG_TRC("Sending to Client [" << statusReady << "]."); +ws->sendMessage(statusReady); +} + +// In case of WOPI, if this session is not set as readonly, it might be set so +// later after making a call to WOPI host which tells us the permission on files +// (UserCanWrite param). +auto session = std::make_shared(id, shared_from_this(), uriPublic, isReadOnly, hostNoTrust); +session->construct(); + +return session; +} +catch (const std::exception& exc) +{ +LOG_WRN("Exception while preparing session [" << id << "]: " << exc.what()); +} + +return nullptr; +} + void DocumentBroker::addCallback(const SocketPoll::CallbackFn& fn) { _poll->addCallback(fn); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 5e3bea9aa..f56bd1e3f 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -243,6 +243,13 @@ public: /// Hard removes a session by ID, only for ClientSession. void finalRemoveSession(const std::string& id); +/// Create new client session +std::shared_ptr createNewClientSession(const WebSocketHandler* ws, + const std::string& id, + const Poco::URI& uriPublic, + const bool isReadOnly, + const std::string& hostNoTrust); + /// Thread safe termination of this broker if it has a lingering thread void joinThread(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 61b9d8f09..eb35d601c 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1780,40 +1780,6 @@ static std::shared_ptr findOrCreateDocBroker(WebSocketHandler& w return docBroker; } -static std::shared_ptr createNewClientSession(const WebSocketHandler* ws, - const std::string& id, - const Poco::URI& uriPublic, - const std::shared_ptr& docBroker, - const bool isReadOnly, - const std::string& hostNoTrust) -{ -LOG_CHECK_RET(docBroker && "Null docBroker instance", nullptr); -try -{ -// Now we have a DocumentBroker and we're ready to process client commands. -if (ws) -{ -const std::string statusReady = "statusindicator: ready"; -LOG_TRC("Sending to Client [" << statusReady << "]."); -ws->sendMessage(statusReady); -} - -// In case of WOPI, if this session is not set as readonly, it might be set so -// later after making a call to WOPI host which tells us the permission on files -// (UserCanWrite param). -auto session = std::make_shared(id, docBroker, uriPublic, isReadOnly, hostNoTrust); -session->construct(); - -return session; -} -catch (const std::exception& exc) -{ -LOG_WRN("Exception while preparing session [" << id << "]: " << exc.what()); -} - -return nullptr; -} - /// Handles the socket that the
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 74 +++-- wsd/DocumentBroker.hpp | 17 +-- wsd/LOOLWSD.cpp| 63 + 3 files changed, 89 insertions(+), 65 deletions(-) New commits: commit 948b424abbb3ee493d148896492d18186e3507f2 Author: Michael Meeks AuthorDate: Thu Dec 12 05:09:35 2019 + Commit: Michael Meeks CommitDate: Thu Dec 12 07:42:42 2019 +0100 convert-to: wait for load to complete before attempting the save. Change-Id: Iee3a8a6720bbc29fc4e113bf705f405b840e1e45 Reviewed-on: https://gerrit.libreoffice.org/85009 Reviewed-by: Michael Meeks Tested-by: Michael Meeks diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index af756c676..700a56fbf 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -2195,14 +2195,64 @@ size_t ConvertToBroker::getInstanceCount() ConvertToBroker::ConvertToBroker(const std::string& uri, const Poco::URI& uriPublic, - const std::string& docKey) -: DocumentBroker(uri, uriPublic, docKey) + const std::string& docKey, + const std::string& format, + const std::string& sOptions) : +DocumentBroker(uri, uriPublic, docKey), +_format(format), +_sOptions(sOptions) { static const int limit_convert_secs = LOOLWSD::getConfigValue("per_document.limit_convert_secs", 100); NumConverters++; _limitLifeSeconds = limit_convert_secs; } +bool ConvertToBroker::startConversion(SocketDisposition , const std::string ) +{ +std::shared_ptr docBroker = std::static_pointer_cast(shared_from_this()); + +// Create a session to load the document. +const bool isReadOnly = true; +_clientSession = std::make_shared(id, docBroker, getPublicUri(), isReadOnly, "nocliphost"); +_clientSession->construct(); + +if (!_clientSession) +return false; + +disposition.setMove([docBroker] (const std::shared_ptr ) +{ +// Perform all of this after removing the socket + +// Make sure the thread is running before adding callback. +docBroker->startThread(); + +// We no longer own this socket. +moveSocket->setThreadOwner(std::thread::id(0)); + +docBroker->addCallback([docBroker, moveSocket]() + { + auto streamSocket = std::static_pointer_cast(moveSocket); + docBroker->_clientSession->setSaveAsSocket(streamSocket); + + // Move the socket into DocBroker. + docBroker->addSocketToPoll(moveSocket); + + // First add and load the session. + docBroker->addSession(docBroker->_clientSession); + + // Load the document manually and request saving in the target format. + std::string encodedFrom; + Poco::URI::encode(docBroker->getPublicUri().getPath(), "", encodedFrom); + const std::string load = "load url=" + encodedFrom; + std::vector loadRequest(load.begin(), load.end()); + docBroker->_clientSession->handleMessage(true, WSOpCode::Text, loadRequest); + + // Save is done in the setLoaded + }); +}); +return true; +} + void ConvertToBroker::dispose() { if (!_uriOrig.empty()) @@ -2233,6 +2283,26 @@ void ConvertToBroker::removeFile(const std::string ) } } +void ConvertToBroker::setLoaded() +{ +DocumentBroker::setLoaded(); + +// FIXME: Check for security violations. +Poco::Path toPath(getPublicUri().getPath()); +toPath.setExtension(_format); +const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName(); +std::string encodedTo; +Poco::URI::encode(toJailURL, "", encodedTo); + +// Convert it to the requested format. +const std::string saveAsCmd = "saveas url=" + encodedTo + " format=" + _format + " options=" + _sOptions; + +// Send the save request ... +std::vector saveasRequest(saveAsCmd.begin(), saveAsCmd.end()); + +_clientSession->handleMessage(true, WSOpCode::Text, saveasRequest); +} + std::vector> DocumentBroker::getSessionsTestOnlyUnsafe() { std::vector> result; diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 3b8f6e844..5632c56b6 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -245,7 +245,8 @@ public: /// Thread safe termination of this broker if it has a lingering thread void joinThread(); -void setLoaded(); +/// Notify that the load has completed +virtual void setLoaded(); bool isDocumentChangedInStorage() { return _documentChangedInStorage; } @@ -518,16 +519,28 @@ private: class ConvertToBroker :
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 55 +++-- wsd/DocumentBroker.hpp |6 - wsd/LOOLWSD.cpp|1 3 files changed, 41 insertions(+), 21 deletions(-) New commits: commit 35fdc48e28f915e446bf6d78109368414335fcb9 Author: Ashod Nakashian AuthorDate: Tue Oct 22 10:28:57 2019 -0400 Commit: Ashod Nakashian CommitDate: Wed Nov 6 03:41:44 2019 +0100 wsd: upload to storage when per_document.always_save_on_exit is set Saving the document on exit is not enough, we also need to send it to the storage. We now force doing that, even when there is no modifiction to the document (i.e. a new version wasn't really saved). Reviewed-on: https://gerrit.libreoffice.org/81336 Reviewed-by: Andras Timar Tested-by: Andras Timar (cherry picked from commit f2913f20b03e916ce8a70f927ca3f5655a3768a8) Change-Id: Ic4e1b1424f32d3141e98c936a51e47c9e4b9f753 Reviewed-on: https://gerrit.libreoffice.org/81576 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 5a0926a2d..fd77b83ae 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -677,7 +677,6 @@ bool DocumentBroker::load(const std::shared_ptr& session, const s session->setUserName(username); session->setUserExtraInfo(userExtraInfo); session->setWatermarkText(watermarkText); - if(!watermarkText.empty()) session->setHash(watermarkText); else @@ -834,13 +833,21 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId, { assertCorrectThread(); -if (force) +// Force saving on exit, if enabled. +if (!force && isMarkedToDestroy()) { -LOG_TRC("Document will be saved forcefully to storage."); -_storage->forceSave(); +static const bool always_save = LOOLWSD::getConfigValue("per_document.always_save_on_exit", false); +if (always_save) +{ +LOG_TRC("Enabling forced saving to storage per always_save_on_exit config."); +_storage->forceSave(); +force = true; +} } -const bool res = saveToStorageInternal(sessionId, success, result); +constexpr bool isRename = false; +const bool res = saveToStorageInternal(sessionId, success, result, /*saveAsPath*/ std::string(), + /*saveAsFilename*/ std::string(), isRename, force); // If marked to destroy, or session is disconnected, remove. const auto it = _sessions.find(sessionId); @@ -864,22 +871,21 @@ bool DocumentBroker::saveAsToStorage(const std::string& sessionId, const std::st return saveToStorageInternal(sessionId, true, "", saveAsPath, saveAsFilename, isRename); } -bool DocumentBroker::saveToStorageInternal(const std::string& sessionId, - bool success, const std::string& result, - const std::string& saveAsPath, const std::string& saveAsFilename, const bool isRename) +bool DocumentBroker::saveToStorageInternal(const std::string& sessionId, bool success, + const std::string& result, const std::string& saveAsPath, + const std::string& saveAsFilename, const bool isRename, + const bool force) { assertCorrectThread(); // Record that we got a response to avoid timing out on saving. _lastSaveResponseTime = std::chrono::steady_clock::now(); -const bool isSaveAs = !saveAsPath.empty(); - // If save requested, but core didn't save because document was unmodified // notify the waiting thread, if any. -LOG_TRC("Saving to storage docKey [" << _docKey << "] for session [" << sessionId << -"]. Success: " << success << ", result: " << result); -if (!success && result == "unmodified" && !isRename) +LOG_TRC("Uploading to storage docKey [" << _docKey << "] for session [" << sessionId << +"]. Success: " << success << ", result: " << result << ", force: " << force); +if (!success && result == "unmodified" && !isRename && !force) { LOG_DBG("Save skipped as document [" << _docKey << "] was not modified."); _lastSaveTime = std::chrono::steady_clock::now(); @@ -890,18 +896,26 @@ bool DocumentBroker::saveToStorageInternal(const std::string& sessionId, const auto it = _sessions.find(sessionId); if (it == _sessions.end()) { -LOG_ERR("Session with sessionId [" << sessionId << "] not found while saving docKey [" << _docKey << "]."); +LOG_ERR("Session with sessionId [" +<< sessionId << "] not found while storing document docKey [" << _docKey +<< "]. The document will not be uploaded to storage at this time."); return false; } // Check that we
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 13 +++-- wsd/DocumentBroker.hpp |8 +++- wsd/LOOLWSD.cpp|6 -- 3 files changed, 22 insertions(+), 5 deletions(-) New commits: commit 5e7cac28fa74131461f6d9e25334e9cc7568f444 Author: Michael Meeks AuthorDate: Fri Oct 4 10:30:49 2019 +0100 Commit: Michael Meeks CommitDate: Fri Oct 4 11:01:45 2019 +0100 belt & braces fix erroneous popup of limit dialog The shared_ptr allows the DocumentBroker's and ConvertToBroker to linger after they are removed from the list, making ConvertToBroker::getInstanceCount potentially larger than the number of documents transiently. Fix this with a dispose method called on list removal. Also make the arithmetic signed, to avoid unfortunate wrapping. Also when the limit is large, don't show a message whatever happens. Change-Id: Id2571429de48ae75e851c3fdc49e24a02aaaf6e9 diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index ab71fe5ba..c332f7c52 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -2072,10 +2072,19 @@ ConvertToBroker::ConvertToBroker(const std::string& uri, NumConverters++; } +void ConvertToBroker::dispose() +{ +if (!_uriOrig.empty()) +{ +NumConverters--; +removeFile(_uriOrig); +_uriOrig.clear(); +} +} + ConvertToBroker::~ConvertToBroker() { -NumConverters--; -removeFile(_uriOrig); +dispose(); } void ConvertToBroker::removeFile(const std::string ) diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 576906d9e..7c66832a5 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -225,6 +225,9 @@ public: virtual ~DocumentBroker(); +/// Called when removed from the DocBrokers list +virtual void dispose() {} + /// Start processing events void startThread(); @@ -420,7 +423,7 @@ private: void getIOStats(uint64_t , uint64_t ); protected: -const std::string _uriOrig; +std::string _uriOrig; private: const Poco::URI _uriPublic; /// URL-based key. May be repeated during the lifetime of WSD. @@ -498,6 +501,9 @@ public: const std::string& docKey); virtual ~ConvertToBroker(); +/// Called when removed from the DocBrokers list +void dispose() override; + /// How many live conversions are running. static size_t getInstanceCount(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index f404798d0..b460d75d8 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -258,8 +258,9 @@ inline void shutdownLimitReached(WebSocketHandler& ws) inline void checkSessionLimitsAndWarnClients() { #if !MOBILEAPP -size_t docBrokerCount = DocBrokers.size() - ConvertToBroker::getInstanceCount(); -if (docBrokerCount > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= LOOLWSD::MaxConnections) +ssize_t docBrokerCount = DocBrokers.size() - ConvertToBroker::getInstanceCount(); +if (LOOLWSD::MaxDocuments < 1 && +(docBrokerCount > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= LOOLWSD::MaxConnections)) { const std::string info = Poco::format(PAYLOAD_INFO_LIMIT_REACHED, LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections); LOG_INF("Sending client 'limitreached' message: " << info); @@ -333,6 +334,7 @@ void cleanupDocBrokers() if (!docBroker->isAlive()) { LOG_INF("Removing DocumentBroker for docKey [" << it->first << "]."); +docBroker->dispose(); it = DocBrokers.erase(it); continue; } else { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 11 --- wsd/DocumentBroker.hpp |3 +++ wsd/LOOLWSD.cpp|9 + 3 files changed, 20 insertions(+), 3 deletions(-) New commits: commit 1845ed42af661dbb7b10a2fb4686ce2c8ef7e521 Author: Michael Meeks AuthorDate: Tue May 21 19:50:17 2019 +0100 Commit: Michael Meeks CommitDate: Wed May 22 01:57:48 2019 +0200 tdf#123482 - cleanup convert-to folder even more reliably. Problems could occur if exceptiosn thrown when parsing the input stream. Change-Id: Id82b3816450194164fc2093554c730b4a94acef1 Reviewed-on: https://gerrit.libreoffice.org/72695 Reviewed-by: Michael Meeks Tested-by: Michael Meeks diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 6779473a4..698f3dd98 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1908,13 +1908,18 @@ ConvertToBroker::ConvertToBroker(const std::string& uri, ConvertToBroker::~ConvertToBroker() { NumConverters--; -if (!_uriOrig.empty()) +removeFile(_uriOrig); +} + +void ConvertToBroker::removeFile(const std::string ) +{ +if (!uriOrig.empty()) { // Remove source file and directory -Poco::Path path = _uriOrig; +Poco::Path path = uriOrig; Poco::File(path).remove(); Poco::File(path.makeParent()).remove(); -FileUtil::removeFile(_uriOrig); +FileUtil::removeFile(uriOrig); } } diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 0642599c2..c56ced733 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -481,6 +481,9 @@ public: /// How many live conversions are running. static size_t getInstanceCount(); + +/// Cleanup path and its parent +static void removeFile(const std::string ); }; #endif diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 69e74114a..25877811a 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -572,6 +572,9 @@ class ConvertToPartHandler : public PartHandler public: std::string getFilename() const { return _filename; } +/// Afterwards someone else is responsible for cleaning that up. +void takeFile() { _filename.clear(); } + ConvertToPartHandler(bool convertTo = false) : _convertTo(convertTo) { @@ -579,6 +582,11 @@ public: virtual ~ConvertToPartHandler() { +if (!_filename.empty()) +{ +LOG_TRC("Remove un-handled temporary file '" << _filename << "'"); +ConvertToBroker::removeFile(_filename); +} } virtual void handlePart(const MessageHeader& header, std::istream& stream) override @@ -2377,6 +2385,7 @@ private: LOG_DBG("New DocumentBroker for docKey [" << docKey << "]."); auto docBroker = std::make_shared(fromPath, uriPublic, docKey); +handler.takeFile(); cleanupDocBrokers(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 29 - wsd/DocumentBroker.hpp |3 +++ wsd/LOOLWSD.cpp|3 --- 3 files changed, 27 insertions(+), 8 deletions(-) New commits: commit e877adc84bc6f90bcfa52f9f63666358e6614885 Author: Ashod NakashianDate: Mon May 22 15:04:35 2017 -0400 wsd: don't stop doc on unauthorized loading When a client connects with expired/invalid access_token, the document should remain active for other/existing clients, if any. However, if no clients exists (i.e. the first client has invalid access_token), then the document should be unloaded and cleaned up. Change-Id: Iaad95a4286325cc6ee130b37e3ad635993a71c72 Reviewed-on: https://gerrit.libreoffice.org/37916 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 73178103..17ce1be2 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -785,6 +785,25 @@ std::string DocumentBroker::getJailRoot() const size_t DocumentBroker::addSession(const std::shared_ptr& session) { +try +{ +return addSessionInternal(session); +} +catch (const std::exception& exc) +{ +LOG_ERR("Failed to add session to [" << _docKey << "] with URI [" << session->getPublicUri().toString() << "]: " << exc.what()); +if (_sessions.empty()) +{ +LOG_INF("Doc [" << _docKey << "] has no more sessions. Marking to destroy."); +_markToDestroy = true; +} + +throw; +} +} + +size_t DocumentBroker::addSessionInternal(const std::shared_ptr& session) +{ assertCorrectThread(); try @@ -815,12 +834,7 @@ size_t DocumentBroker::addSession(const std::shared_ptr& session) _markToDestroy = false; _stop = false; -// Add and attach the session. -_sessions.emplace(session->getId(), session); -session->setAttached(); - const auto id = session->getId(); -const auto count = _sessions.size(); // Request a new session from the child kit. const std::string aMessage = "session " + id + ' ' + _docKey + ' ' + _docId; @@ -829,6 +843,11 @@ size_t DocumentBroker::addSession(const std::shared_ptr& session) // Tell the admin console about this new doc Admin::instance().addDoc(_docKey, getPid(), getFilename(), id, session->getUserName()); +// Add and attach the session. +_sessions.emplace(session->getId(), session); +session->setAttached(); + +const auto count = _sessions.size(); LOG_TRC("Added " << (session->isReadOnly() ? "readonly" : "non-readonly") << " session [" << id << "] to docKey [" << _docKey << "] to have " << count << " sessions."); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 14fe17e0..23b699e4 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -350,6 +350,9 @@ private: /// Saves the doc to the storage. bool saveToStorageInternal(const std::string& sesionId, bool success, const std::string& result = ""); +/// Loads a new session and adds to the sessions container. +size_t addSessionInternal(const std::shared_ptr& session); + /// Removes a session by ID. Returns the new number of sessions. size_t removeSessionInternal(const std::string& id); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 3a877242..7c188f17 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2127,19 +2127,16 @@ private: LOG_ERR("Unauthorized Request while loading session for " << docBroker->getDocKey() << ": " << exc.what()); const std::string msg = "error: cmd=internal kind=unauthorized"; clientSession->sendMessage(msg); -docBroker->stop(); } catch (const StorageConnectionException& exc) { // Alert user about failed load const std::string msg = "error: cmd=storage kind=loadfailed"; clientSession->sendMessage(msg); -docBroker->stop(); } catch (const std::exception& exc) { LOG_ERR("Error while loading : " << exc.what()); -docBroker->stop(); } }); }); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 12 wsd/DocumentBroker.hpp |2 +- wsd/LOOLWSD.cpp| 32 +++- 3 files changed, 20 insertions(+), 26 deletions(-) New commits: commit 90127ac0e3e7d4dd90e3143c7b310249c274c1a9 Author: Michael MeeksDate: Thu Apr 6 17:58:41 2017 +0100 Let the DocBroker thread clean itself up and expire. (cherry picked from commit 2e372b70b32d4e052458547daa229c537442774f) Change-Id: I5835c83f44ef770fa6ccd2418fc6ca73e17694e4 Reviewed-on: https://gerrit.libreoffice.org/36225 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index a5a995df..0ee99738 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -241,6 +241,18 @@ void DocumentBroker::pollThread() LOG_INF("No more sessions in doc [" << _docKey << "]. Terminating."); _stop = true; } + +// Remove idle documents after 1 hour. +const bool idle = getIdleTimeSecs() >= 3600; + +// Cleanup used and dead entries. +if ((isLoaded() || _markToDestroy) && +(getSessionsCount() == 0 || !isAlive() || idle)) +{ +LOG_INF("Terminating " << (idle ? "idle" : "dead") << +" DocumentBroker for docKey [" << getDocKey() << "]."); +_stop = true; +} } LOG_INF("Finished polling doc [" << _docKey << "]. stop: " << _stop << ", continuePolling: " << diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index d05437e9..fd8d20e8 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -304,7 +304,7 @@ public: void handleTileCombinedResponse(const std::vector& payload); void destroyIfLastEditor(const std::string& id); -bool isMarkedToDestroy() const { return _markToDestroy; } +bool isMarkedToDestroy() const { return _markToDestroy || _stop; } bool handleInput(const std::vector& payload); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index e5d4cb68..439ab67e 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -235,33 +235,15 @@ void cleanupDocBrokers() { auto docBroker = it->second; -// If document busy at the moment, cleanup later. -auto lock = docBroker->getDeferredLock(); -if (lock.try_lock()) +// Remove only when not alive. +if (!docBroker->isAlive()) { -// Remove idle documents after 1 hour. -const bool idle = (docBroker->getIdleTimeSecs() >= 3600); - -// Cleanup used and dead entries. -if ((docBroker->isLoaded() || docBroker->isMarkedToDestroy()) && -(docBroker->getSessionsCount() == 0 || !docBroker->isAlive() || idle)) -{ -LOG_INF("Terminating " << (idle ? "idle" : "dead") << -" DocumentBroker for docKey [" << it->first << "]."); -docBroker->stop(); - -// Remove only when not alive. -if (!docBroker->isAlive()) -{ -LOG_INF("Removing " << (idle ? "idle" : "dead") << -" DocumentBroker for docKey [" << it->first << "]."); -it = DocBrokers.erase(it); -continue; -} -} +LOG_INF("Removing DocumentBroker for docKey [" << it->first << "]."); +it = DocBrokers.erase(it); +continue; +} else { +++it; } - -++it; } if (count != DocBrokers.size()) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp |8 +++- wsd/DocumentBroker.hpp |3 +-- wsd/LOOLWSD.cpp| 15 ++- 3 files changed, 14 insertions(+), 12 deletions(-) New commits: commit 01519eff70f1157dbbb4cb329acc7754f34a2765 Author: Michael MeeksDate: Wed Apr 5 21:31:15 2017 +0100 Always cleanup DocBrokers in the PrisonerPoll thread. This simplifies things, and keeps process management in one thread. Also - wakeup the DocumentBroker when we want to stop it. Change-Id: I597ba4b34719fc072a4b4ad3697442b5eebe5784 Reviewed-on: https://gerrit.libreoffice.org/36182 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 5a4de9e2..396bf52b 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -264,7 +264,7 @@ void DocumentBroker::pollThread() _poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5)); } -// Cleanup. +// Async cleanup. LOOLWSD::doHousekeeping(); LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << "]."); @@ -306,6 +306,12 @@ void DocumentBroker::joinThread() _poll->joinThread(); } +void DocumentBroker::stop() +{ +_stop = true; +_poll->wakeup(); +} + bool DocumentBroker::load(const std::shared_ptr& session, const std::string& jailId) { assertCorrectThread(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 0af441ff..d05437e9 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -222,8 +222,7 @@ public: void startThread(); /// Flag for termination. -//TODO: Take reason to broadcast to clients. -void stop() { _stop = true; } +void stop(); /// Thread safe termination of this broker if it has a lingering thread void joinThread(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 08a20ce7..e5d4cb68 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -226,7 +226,7 @@ void alertAllUsersInternal(const std::string& msg) /// Remove dead and idle DocBrokers. /// The client of idle document should've greyed-out long ago. /// Returns true if at least one is removed. -bool cleanupDocBrokers() +void cleanupDocBrokers() { Util::assertIsLocked(DocBrokersMutex); @@ -277,11 +277,7 @@ bool cleanupDocBrokers() LOG_END(logger); } - -return true; } - -return false; } /// Forks as many children as requested. @@ -582,7 +578,7 @@ class PrisonerPoll : public TerminatingPoll { public: PrisonerPoll() : TerminatingPoll("prisoner_poll") {} -/// Check prisoners are still alive and balaned. +/// Check prisoners are still alive and balanced. void wakeupHook() override; }; @@ -1099,12 +1095,13 @@ bool LOOLWSD::checkAndRestoreForKit() #endif } -void PrisonerPoll::wakeupHook() +void LOOLWSD::doHousekeeping() { -LOOLWSD::doHousekeeping(); +PrisonerPoll.wakeup(); } -void LOOLWSD::doHousekeeping() +/// Really do the house-keeping +void PrisonerPoll::wakeupHook() { if (!LOOLWSD::checkAndRestoreForKit()) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 28 ++-- wsd/DocumentBroker.hpp |9 ++--- wsd/LOOLWSD.cpp| 47 +-- 3 files changed, 33 insertions(+), 51 deletions(-) New commits: commit 63ab3bcfa49ec9f6efb0fa81657ea64eaf0ab007 Author: Ashod NakashianDate: Sat Apr 1 19:20:54 2017 -0400 wsd: remove queueSession and simplify session loading Change-Id: Ia03a4ed64b743da8fa7e27de853623126698b9c0 Reviewed-on: https://gerrit.libreoffice.org/36016 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 0a6d2f01..494f21f3 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -223,22 +223,6 @@ void DocumentBroker::pollThread() // Main polling loop goodness. while (!_stop && _poll->continuePolling() && !TerminationFlag && !ShutdownRequestFlag) { -// First, load new sessions. -for (const auto& pair : _sessions) -{ -try -{ -auto& session = pair.second; -if (!session->isAttached()) -addSession(session); -} -catch (const std::exception& exc) -{ -LOG_ERR("Error while adding new session to doc [" << _docKey << "]: " << exc.what()); -//TODO: Send failure to client and remove session. -} -} - _poll->poll(SocketPoll::DefaultPollTimeoutMs); if (!std::getenv("LOOL_NO_AUTOSAVE") && !_stop && @@ -746,16 +730,6 @@ std::string DocumentBroker::getJailRoot() const return Poco::Path(_childRoot, _jailId).toString(); } -size_t DocumentBroker::queueSession(std::shared_ptr& session) -{ -std::unique_lock lock(_mutex); - -_sessions.emplace(session->getId(), session); -_poll->wakeup(); - -return _sessions.size(); -} - size_t DocumentBroker::addSession(const std::shared_ptr& session) { assert(isCorrectThread()); @@ -788,6 +762,8 @@ size_t DocumentBroker::addSession(const std::shared_ptr& session) _markToDestroy = false; _stop = false; +// Add and attach the session. +_sessions.emplace(session->getId(), session); session->setAttached(); const auto id = session->getId(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index a7473531..915db5a6 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -266,10 +266,8 @@ public: std::string getJailRoot() const; -/// Queue a new session to be attached asynchronously. -/// @return amount of session we have after all the queued ones will be -/// created. -size_t queueSession(std::shared_ptr& session); +/// Add a new session. Returns the new number of sessions. +size_t addSession(const std::shared_ptr& session); /// Removes a session by ID. Returns the new number of sessions. size_t removeSession(const std::string& id, bool destroyIfLast = false); @@ -354,9 +352,6 @@ private: /// Forward a message from child session to its respective client session. bool forwardToClient(const std::shared_ptr& payload); -/// Add a new session. Returns the new number of sessions. -size_t addSession(const std::shared_ptr& session); - /// The thread function that all of the I/O for all sessions /// associated with this document. void pollThread(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index db5f55a2..05c6e1da 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1324,8 +1324,6 @@ static std::shared_ptr createNewClientSession(const WebSocketHand // (UserCanWrite param). auto session = std::make_shared(id, docBroker, uriPublic, isReadOnly); -docBroker->queueSession(session); - return session; } catch (const std::exception& exc) @@ -1860,17 +1858,18 @@ private: auto clientSession = createNewClientSession(nullptr, _id, uriPublic, docBroker, isReadOnly); if (clientSession) { +clientSession->setSaveAsSocket(socket); + // Transfer the client socket to the DocumentBroker. // Move the socket into DocBroker. docBroker->addSocketToPoll(socket); socketOwnership = SocketHandlerInterface::SocketOwnership::MOVED; -clientSession->setSaveAsSocket(socket); - -docBroker->startThread(); - -docBroker->addCallback([&]() +docBroker->addCallback([&, clientSession]() { +// First add and load the session. +docBroker->addSession(clientSession); + // Load the
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp |5 - wsd/DocumentBroker.hpp |8 wsd/LOOLWSD.cpp|6 +- 3 files changed, 5 insertions(+), 14 deletions(-) New commits: commit 388d7b1dbf1a5c2d155c0149247b3a319114f8b0 Author: Ashod NakashianDate: Sun Mar 12 14:12:36 2017 -0400 wsd: TerminatingPoll always starts its own thread Since all TerminatingPoll instances need to fire a thread, no reason to do it manually and risk races. Now TerminatingPoll does it in the ctor. Change-Id: I59850ad48b3789f3a23d01abb05a7f28e5717031 Reviewed-on: https://gerrit.libreoffice.org/35114 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 1b47d68..fa8ba94 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -163,11 +163,6 @@ DocumentBroker::DocumentBroker(const std::string& uri, _stop = false; } -void DocumentBroker::startThread() -{ -_poll->startThread(); -} - // The inner heart of the DocumentBroker - our poll loop. void DocumentBroker::pollThread() { diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 2d30802..2a9c152 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -44,7 +44,10 @@ class TerminatingPoll : public SocketPoll { public: TerminatingPoll(const std::string ) : -SocketPoll(threadName) {} +SocketPoll(threadName) +{ +startThread(); +} bool continuePolling() override { @@ -220,9 +223,6 @@ public: ~DocumentBroker(); -/// Start processing events -void startThread(); - /// Loads a document from the public URI into the jail. bool load(std::shared_ptr& session, const std::string& jailId); bool isLoaded() const { return _isLoaded; } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index a459bf4..98250b4 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2167,7 +2167,6 @@ private: void handleClientWsUpgrade(const Poco::Net::HTTPRequest& request, const std::string& url) { -// requestHandler = new ClientRequestHandler(); LOG_INF("Client WS request" << request.getURI() << ", url: " << url); // First Upgrade. @@ -2221,9 +2220,9 @@ private: _clientSession->onConnect(socket); docBroker->addSocketToPoll(socket); } -docBroker->startThread(); } } + if (!docBroker || !_clientSession) LOG_WRN("Failed to connect DocBroker and Client Session."); } @@ -2349,14 +2348,11 @@ public: void startPrisoners(const int port) { PrisonerPoll.insertNewSocket(findPrisonerServerPort(port)); -PrisonerPoll.startThread(); } void start(const int port) { _acceptPoll.insertNewSocket(findServerPort(port)); -_acceptPoll.startThread(); -WebServerPoll.startThread(); } void stop() ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp | 34 ++ wsd/DocumentBroker.hpp | 10 +- wsd/LOOLWSD.cpp|4 ++-- 3 files changed, 13 insertions(+), 35 deletions(-) New commits: commit cbd00bf7c8600afb0f7ec09a8ad90f1b5ed2f298 Author: Ashod NakashianDate: Sun Mar 12 13:56:42 2017 -0400 wsd: simplify DocumentBroker construction DocumentBrokerPoll is always owned by a single DocumentBroker instance, so we can hold a reference to it. This eliminates the need to hold a shared_ptr to the owner which, in turn, eliminates the need for a create wrapper. Change-Id: I954c9dddcc3b2cfdd5dfcc8248ab3d47a897f684 Reviewed-on: https://gerrit.libreoffice.org/35113 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index c4c3307..1b47d68 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -114,23 +114,22 @@ std::string DocumentBroker::getDocKey(const Poco::URI& uri) } /// The Document Broker Poll - one of these in a thread per document -class DocumentBroker::DocumentBrokerPoll : public TerminatingPoll +class DocumentBroker::DocumentBrokerPoll final : public TerminatingPoll { -std::shared_ptr _docBroker; +/// The DocumentBroker owning us. +DocumentBroker& _docBroker; + public: -DocumentBrokerPoll(const std::string ) -: TerminatingPoll(threadName) -{ -} -void setDocumentBroker(const std::shared_ptr ) +DocumentBrokerPoll(const std::string , DocumentBroker& docBroker) : +TerminatingPoll(threadName), +_docBroker(docBroker) { -_docBroker = docBroker; } virtual void pollingThread() { -assert (_docBroker); -_docBroker->pollThread(); +// Delegate to the docBroker. +_docBroker.pollThread(); } }; @@ -152,7 +151,7 @@ DocumentBroker::DocumentBroker(const std::string& uri, _cursorPosY(0), _cursorWidth(0), _cursorHeight(0), -_poll(new DocumentBrokerPoll("docbrk_poll")), +_poll(new DocumentBrokerPoll("docbrk_poll", *this)), _tileVersion(0), _debugRenderedTileCount(0) { @@ -164,19 +163,6 @@ DocumentBroker::DocumentBroker(const std::string& uri, _stop = false; } -std::shared_ptr DocumentBroker::create( -const std::string& uri, -const Poco::URI& uriPublic, -const std::string& docKey, -const std::string& childRoot) -{ -std::shared_ptr docBroker = std::make_shared(uri, uriPublic, docKey, childRoot); - -docBroker->_poll->setDocumentBroker(docBroker); - -return docBroker; -} - void DocumentBroker::startThread() { _poll->startThread(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 0ca4ab7..2d30802 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -212,19 +212,11 @@ public: /// Dummy document broker that is marked to destroy. DocumentBroker(); -/// Use create - not this constructor ... -/// FIXME: friend with make_shared etc. +/// Construct DocumentBroker with URI, docKey, and root path. DocumentBroker(const std::string& uri, const Poco::URI& uriPublic, const std::string& docKey, const std::string& childRoot); -public: -static std::shared_ptr create( - const std::string& uri, - const Poco::URI& uriPublic, - const std::string& docKey, - const std::string& childRoot); - ~DocumentBroker(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index eb06f5f..a459bf4 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1296,7 +1296,7 @@ static std::shared_ptr createDocBroker(WebSocketHandler& ws, // Set the one we just created. LOG_DBG("New DocumentBroker for docKey [" << docKey << "]."); -auto docBroker = DocumentBroker::create(uri, uriPublic, docKey, LOOLWSD::ChildRoot); +auto docBroker = std::make_shared(uri, uriPublic, docKey, LOOLWSD::ChildRoot); DocBrokers.emplace(docKey, docBroker); LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting [" << docKey << "]."); @@ -1958,7 +1958,7 @@ private: std::unique_lock docBrokersLock(DocBrokersMutex); LOG_DBG("New DocumentBroker for docKey [" << docKey << "]."); -auto docBroker = DocumentBroker::create(fromPath, uriPublic, docKey, LOOLWSD::ChildRoot); +auto docBroker = std::make_shared(fromPath, uriPublic, docKey, LOOLWSD::ChildRoot); cleanupDocBrokers(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
wsd/DocumentBroker.cpp |2 +- wsd/DocumentBroker.hpp |8 ++-- wsd/LOOLWSD.cpp| 10 ++ 3 files changed, 13 insertions(+), 7 deletions(-) New commits: commit 65d2036d63fa9304b1c8a88f18f946ba02bb1001 Author: Ashod NakashianDate: Sun Jan 1 18:16:56 2017 -0500 wsd: use chrono instead of time_t While time_t is much simpler, it's too opaque. The new chrono library is type-safe and does conversion correctly, as well as guarantees monotonity and other desirable properties. Change-Id: Id41c44c397a31d73e894e8f1715ff18f2b67df53 Reviewed-on: https://gerrit.libreoffice.org/32627 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index af13b73..dd15f06 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1089,7 +1089,7 @@ void DocumentBroker::closeDocument(const std::string& reason) void DocumentBroker::updateLastActivityTime() { -_lastActivity = std::time(nullptr); +_lastActivity = std::chrono::steady_clock::now(); Admin::instance().updateLastActivityTime(_docKey); } diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index d913adc..54eb3be 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -301,7 +301,11 @@ public: void updateLastActivityTime(); -std::time_t getIdleTime() const { return std::time(nullptr) - _lastActivity; } +std::size_t getIdleTimeSecs() const +{ +const auto duration = (std::chrono::steady_clock::now() - _lastActivity); +return std::chrono::duration_cast(duration).count(); +} private: /// Sends the .uno:Save command to LoKit. @@ -346,7 +350,7 @@ private: int _debugRenderedTileCount; -std::time_t _lastActivity; +std::chrono::steady_clock::time_point _lastActivity; static constexpr auto IdleSaveDurationMs = 30 * 1000; static constexpr auto AutoSaveDurationMs = 300 * 1000; diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 3a07668..0268407 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -274,7 +274,7 @@ bool cleanupDocBrokers() auto lock = docBroker->getLock(); // Remove idle documents after 1 hour. -const bool idle = (docBroker->getIdleTime() >= 3600); +const bool idle = (docBroker->getIdleTimeSecs() >= 3600); // Cleanup used and dead entries. if (docBroker->isLoaded() && @@ -2086,11 +2086,12 @@ int LOOLWSD::main(const std::vector& /*args*/) LOG_INF("Starting master server listening on " << ClientPortNumber); srv.start(); + #if ENABLE_DEBUG time_t startTimeSpan = time(nullptr); #endif -time_t last30SecCheck = time(nullptr); +auto last30SecCheckTime = std::chrono::steady_clock::now(); int status = 0; while (!TerminationFlag && !SigUtil::isShuttingDown()) { @@ -2173,7 +2174,8 @@ int LOOLWSD::main(const std::vector& /*args*/) // Nothing more to do this round. } else if (!std::getenv("LOOL_NO_AUTOSAVE") && - (time(nullptr) >= last30SecCheck + 30)) + std::chrono::duration_cast +(std::chrono::steady_clock::now() - last30SecCheckTime).count() >= 30) { try { @@ -2190,7 +2192,7 @@ int LOOLWSD::main(const std::vector& /*args*/) LOG_ERR("Exception: " << exc.what()); } -last30SecCheck = time(nullptr); +last30SecCheckTime = std::chrono::steady_clock::now(); } else { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits