wsd/ClientSession.cpp | 4 +++- wsd/ClientSession.hpp | 10 +++++++++- wsd/DocumentBroker.cpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)
New commits: commit f326a058d41f6a0cc334f8458d98ca68cc40f189 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Thu Apr 20 00:08:13 2017 -0400 wsd: rely only on loaded sessions for saving If a session is not loaded, it might never do so. We should skip them when deciding whether to save using a disconnecting session or rely on another. This is to avoid failing to save when the remaining sessions never really load the document at all, and are therefore useless. Change-Id: I4e7127e12960a31e9f66e835bb63fb2347390711 Reviewed-on: https://gerrit.libreoffice.org/36710 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 414f8b94..8be60603 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -37,7 +37,8 @@ ClientSession::ClientSession(const std::string& id, _docBroker(docBroker), _uriPublic(uriPublic), _isDocumentOwner(false), - _isAttached(false) + _isAttached(false), + _isLoaded(false) { const size_t curConnections = ++LOOLWSD::NumConnections; LOG_INF("ClientSession ctor [" << getName() << "], current number of connections: " << curConnections); @@ -631,6 +632,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt } else if (tokens[0] == "status:") { + setLoaded(); docBroker->setLoaded(); // Forward the status response to the client. diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp index 396f45c9..81c55c70 100644 --- a/wsd/ClientSession.hpp +++ b/wsd/ClientSession.hpp @@ -34,10 +34,14 @@ public: void setReadOnly() override; - /// Returns true if a document is loaded (i.e. we got status message). + /// Returns true if this session is added to a DocBroker. bool isAttached() const { return _isAttached; } void setAttached() { _isAttached = true; } + /// Returns true if this session has loaded a view (i.e. we got status message). + bool isLoaded() const { return _isLoaded; } + void setLoaded() { _isLoaded = true; } + const std::string getUserId() const { return _userId; } const std::string getUserName() const {return _userName; } void setUserId(const std::string& userId) { _userId = userId; } @@ -140,8 +144,12 @@ private: /// The socket to which the converted (saveas) doc is sent. std::shared_ptr<StreamSocket> _saveAsSocket; + /// If we are added to a DocBroker. bool _isAttached; + /// If we have loaded a view. + bool _isLoaded; + /// Wopi FileInfo object std::unique_ptr<WopiStorage::WOPIFileInfo> _wopiFileInfo; diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 31ab6598..bb76ea33 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1218,6 +1218,7 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id) for (const auto& it : _sessions) { if (it.second->getId() != id && + it.second->isLoaded() && !it.second->isReadOnly()) { // Found another editable. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits