[Libreoffice-commits] online.git: wsd/ClientSession.cpp

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 18 14:17:20 UTC 2020


 wsd/ClientSession.cpp |    3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f32c1f2febf7d3a3bdf0c7b0afa70d69a24cc761
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Mar 18 09:20:31 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Mar 18 15:17:02 2020 +0100

    wsd: improve lifecycle in ClientSession::onDisconnect()
    
    Once unit-bad-doc-load completes (with success in exitTest()), sometimes
    we have an error during shutdown.
    
    The reason seems to be that ClientSession::onDisconnect() calls
    DocumentBroker::removeSession(), which may delete the ClientSession, so
    by time time isCloseFrame() is called, we have trouble.
    
    Fix the problem by keeping a reference to self before calling
    removeSession().
    
    Change-Id: If5b409822563ba5a45d453329516671065d8f054
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90681
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 29e420dad..f336eeec0 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1638,6 +1638,9 @@ void ClientSession::onDisconnect()
     docBroker->assertCorrectThread();
     const std::string docKey = docBroker->getDocKey();
 
+    // Keep self alive, so that our own dtor runs only at the end of this function. Without this,
+    // removeSession() may destroy us and then we can't call our own member functions anymore.
+    std::shared_ptr<ClientSession> session = client_from_this();
     try
     {
         // Connection terminated. Destroy session.


More information about the Libreoffice-commits mailing list