wsd/LOOLWSD.cpp | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-)
New commits: commit 4f90c3e5b94b7e06a44a0d6f0decd33ddda5c733 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Jan 3 00:17:35 2017 -0500 wsd: simplify ClientSession removal and cleanup Change-Id: I934f17e978358bef487c5b470cd8cf5d4d747e5d Reviewed-on: https://gerrit.libreoffice.org/32677 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 024d3f8..7b621e5 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1064,44 +1064,26 @@ private: // Connection terminated. Destroy session. LOG_DBG("Client session [" << id << "] terminated. Cleaning up."); - { - auto docLock = docBroker->getLock(); - - // We cannot destroy it, before save, if this is the last session. - // Otherwise, we may end up removing the one and only session. - bool removedSession = false; - - // We issue a force-save when last editable (non-readonly) session is going away - const bool forceSave = docBroker->startDestroy(id); - auto sessionsCount = docBroker->getSessionsCount(); - if (sessionsCount > 1) - { - sessionsCount = docBroker->removeSession(id); - removedSession = true; - LOG_TRC(docKey << ", ws_sessions--: " << sessionsCount); - } - - // If we are the last, we must wait for the save to complete. - if (forceSave) - { - LOG_INF("Shutdown of the last editable (non-readonly) session, saving the document before tearing down."); - } + auto docLock = docBroker->getLock(); - // We need to wait until the save notification reaches us - // and Storage persists the document. - if (!docBroker->autoSave(forceSave, COMMAND_TIMEOUT_MS, docLock)) - { - LOG_ERR("Auto-save before closing failed."); - } + // We issue a force-save when last editable (non-readonly) session is going away + const bool forceSave = docBroker->startDestroy(id); + if (forceSave) + { + LOG_INF("Shutdown of the last editable (non-readonly) session, saving the document before tearing down."); + } - if (!removedSession) - { - sessionsCount = docBroker->removeSession(id); - LOG_TRC(docKey << ", ws_sessions--: " << sessionsCount); - } + // We need to wait until the save notification reaches us + // and Storage persists the document. + if (!docBroker->autoSave(forceSave, COMMAND_TIMEOUT_MS, docLock)) + { + LOG_ERR("Auto-save before closing failed."); } + const auto sessionsCount = docBroker->removeSession(id); + docLock.unlock(); + if (sessionsCount == 0) { // We've supposedly destroyed the last session and can do away with _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits