[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/DocumentBroker.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Apr 20 08:32:55 UTC 2017


 wsd/DocumentBroker.cpp |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

New commits:
commit a8b8ca067acd888ad5376fca497862e595f795a2
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Apr 20 00:10:30 2017 -0400

    wsd: stop the DocBroker when saving session is last
    
    When a session is disconnecting and we use it to save
    (because the other sessions are not viable for saving),
    then we need to correctly detect if by the time
    saving is done there are no other sessions left.
    
    Otherwise, we end up thinking there are other sessions
    when the others had been disconnected during saving.
    
    Change-Id: I55687376f5237a495ae163b53f51ee1d2414d770
    Reviewed-on: https://gerrit.libreoffice.org/36711
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 2a0253b76be3e329af55d0ab80157544eea2253e)
    Reviewed-on: https://gerrit.libreoffice.org/36714
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 94a49a1d..1afd30f0 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -562,16 +562,13 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId,
 
     const bool res = saveToStorageInternal(sessionId, success, result);
 
+    // We've saved and can safely destroy this session.
+    removeSessionInternal(sessionId);
+
     // 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)
+    // Otherwise, check that we are (which we might be by now).
+    if (_markToDestroy || _sessions.empty())
     {
-        // We've saved and can safely destroy.
-        removeSessionInternal(sessionId);
-
         // Stop so we get cleaned up and removed.
         _stop = true;
     }
@@ -866,7 +863,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);
@@ -1230,7 +1228,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)


More information about the Libreoffice-commits mailing list