loolwsd/DocumentBroker.cpp | 8 +++++--- loolwsd/DocumentBroker.hpp | 3 +++ loolwsd/MasterProcessSession.cpp | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-)
New commits: commit bdfda58386b7bf8a92ad6e362e8d0687ee8e00ad Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Apr 29 23:07:09 2016 -0400 loolwsd: don't autosave when document not loaded Change-Id: I44e9c2ad234ee05348b47415add3933c81fce968 Reviewed-on: https://gerrit.libreoffice.org/24525 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index aa110cc..8f50e32 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -74,6 +74,7 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic, _childProcess(childProcess), _lastSaveTime(std::chrono::steady_clock::now()), _markToDestroy(false), + _isLoaded(false), _isModified(false) { assert(!_docKey.empty()); @@ -195,10 +196,11 @@ bool DocumentBroker::autoSave(const bool force, const size_t waitTimeoutMs) Log::trace("Autosaving [" + _docKey + "]."); std::unique_lock<std::mutex> lock(_mutex); - if (_sessions.empty()) + if (_sessions.empty() || _storage == nullptr || !_isLoaded) { - // Shouldn't happen. - return false; + // Nothing to do. + Log::trace("Nothing to autosave [" + _docKey + "]."); + return true; } bool sent = false; diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp index 3a2e4d5..9bf290b 100644 --- a/loolwsd/DocumentBroker.hpp +++ b/loolwsd/DocumentBroker.hpp @@ -151,6 +151,8 @@ public: /// Loads a document from the public URI into the jail. bool load(const std::string& jailId); + bool isLoaded() const { return _isLoaded; } + void setLoaded() { _isLoaded = true; } /// Save the document to Storage if needs persisting. bool save(); @@ -226,6 +228,7 @@ private: std::unique_ptr<StorageBase> _storage; std::unique_ptr<TileCache> _tileCache; std::atomic<bool> _markToDestroy; + bool _isLoaded; bool _isModified; mutable std::mutex _mutex; std::condition_variable _saveCV; diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index c1fa22d..8d07645 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -200,6 +200,7 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length) } else if (tokens[0] == "status:") { + _docBroker->setLoaded(); _docBroker->tileCache().saveTextFile(std::string(buffer, length), "status.txt"); // Forward the status response to the client. @@ -411,6 +412,7 @@ bool MasterProcessSession::getStatus(const char *buffer, int length) Log::trace("Dispatching child to handle [getStatus]."); dispatchChild(); } + forwardToPeer(buffer, length); return true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits