diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2022-01-31 22:14:23 -0500 |
---|---|---|
committer | Ashod Nakashian <Ashod@users.noreply.github.com> | 2022-02-08 20:46:01 -0500 |
commit | 26b6cd4463f3069ab727c745359b416d0c33d938 (patch) | |
tree | 79484bde575a967ac47e04bf8a5d97a62591a69f /wsd/DocumentBroker.cpp | |
parent | wsd: wait for the modified flag before giving up (diff) | |
download | online-26b6cd4463f3069ab727c745359b416d0c33d938.tar.gz online-26b6cd4463f3069ab727c745359b416d0c33d938.zip |
wsd: improved removeSession
Since we track active sessions in removeSession,
it's possible that the last session is not active.
In that case, we should set the unload flag while
saving. If we've removed it, we should mark to
destroy. And finally, we should only assert
that mark to destroy is set with active session,
not when we are left with disconnected ones.
Change-Id: I275aeafe67875fa75e0fad5438928f2f77b79a9a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'wsd/DocumentBroker.cpp')
-rw-r--r-- | wsd/DocumentBroker.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 7817e47e24..f677293fbd 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -2088,7 +2088,6 @@ std::size_t DocumentBroker::removeSession(const std::string& id) std::shared_ptr<ClientSession> session = it->second; const std::size_t activeSessionCount = countActiveSessions(); - const bool isLastSession = (activeSessionCount == 1); const bool lastEditableSession = (!session->isReadOnly() || session->isAllowChangeComments()) && !haveAnotherEditableSession(id); static const bool dontSaveIfUnmodified = !COOLWSD::getConfigValue<bool>("per_document.always_save_on_exit", false); @@ -2130,7 +2129,7 @@ std::size_t DocumentBroker::removeSession(const std::string& id) disconnectSessionInternal(id); // Last view going away; can destroy? - if (isLastSession) + if (activeSessionCount <= 1) { if (_saveManager.isSaving() || isAsyncUploading()) { @@ -2138,7 +2137,7 @@ std::size_t DocumentBroker::removeSession(const std::string& id) // Notice that the save and/or upload could have been triggered // earlier, and not necessarily here when removing this last session. _docState.setUnloadRequested(); - LOG_DBG("Removing last session and will unload after saving. Setting " + LOG_DBG("Removing last session and will unload after saving and uploading. Setting " "UnloadRequested flag."); } else if (_sessions.empty()) @@ -2148,8 +2147,11 @@ std::size_t DocumentBroker::removeSession(const std::string& id) LOG_DBG("No more sessions after removing last. Setting MarkToDestroy flag."); } } - else - assert(!_docState.isMarkedToDestroy()); + else if (activeSessionCount > 0) + { + assert(!_docState.isMarkedToDestroy() && + "Have active sessions while marked to destroy."); + } } catch (const std::exception& ex) { |