wsd/DocumentBroker.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
New commits: commit 39bdf75907b4340e03fb14556a704ba15a0bf627 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Apr 21 00:00:51 2017 -0400 wsd: stop the DocBroker when saving session is last Change-Id: Iad72aeea56ab8ba64eb72e18b861b3cf67224d08 Reviewed-on: https://gerrit.libreoffice.org/36768 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 461fd045..bb96bea9 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -562,16 +562,14 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId, const bool res = saveToStorageInternal(sessionId, success, result); - // If marked to destroy, then this was the last session. - // FIXME: If during that last save another client connects - // to this doc, the _markToDestroy will be reset and we - // will leak the last session. Need to mark the session as - // dead and cleanup somehow. - if (_markToDestroy) - { - // We've saved and can safely destroy. + // If marked to destroy, or session is disconnected, remove. + const auto it = _sessions.find(sessionId); + if (_markToDestroy || (it != _sessions.end() && it->second->isCloseFrame())) removeSessionInternal(sessionId); + // If marked to destroy, then this was the last session. + if (_markToDestroy || _sessions.empty()) + { // Stop so we get cleaned up and removed. _stop = true; } @@ -866,7 +864,8 @@ size_t DocumentBroker::removeSession(const std::string& id, bool destroyIfLast) try { LOG_INF("Removing session [" << id << "] on docKey [" << _docKey << - "]. Have " << _sessions.size() << " sessions."); + "]. Have " << _sessions.size() << " sessions. markToDestroy: " << _markToDestroy << + ", LastEditableSession: " << _lastEditableSession); if (!_lastEditableSession || !autoSave(true)) return removeSessionInternal(id); @@ -1231,7 +1230,8 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id) // Last view going away, can destroy. _markToDestroy = (_sessions.size() <= 1); LOG_DBG("startDestroy on session [" << id << "] on docKey [" << _docKey << - "], markToDestroy: " << _markToDestroy << ", lastEditableSession: " << _lastEditableSession); + "], sessions: " << _sessions.size() << " markToDestroy: " << _markToDestroy << + ", lastEditableSession: " << _lastEditableSession); } void DocumentBroker::setModified(const bool value) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits