[Libreoffice-commits] online.git: 2 commits - kit/Kit.cpp test/httpwstest.cpp wsd/DocumentBroker.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 16 01:43:26 UTC 2017


 kit/Kit.cpp            |   52 ++++++++++++++++++++++++++++++++-----------------
 test/httpwstest.cpp    |    5 +++-
 wsd/DocumentBroker.cpp |    2 -
 3 files changed, 39 insertions(+), 20 deletions(-)

New commits:
commit 6bcd793a8b2179e36b11cdadac3541dccd7628ea
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Jan 11 17:03:52 2017 -0500

    wsd: don't exit Kit process when new sessions exist
    
    When a new session is created in Kit, it means
    a new view is about to be created. However if
    in the interim the last session closes and
    view is destroyed, Kit should not exit.
    
    Instead, we unload the document and
    prepare to reload it again.
    
    Change-Id: Idbc3a663b4d6921440736499f2d439fc2b7e33dc
    Reviewed-on: https://gerrit.libreoffice.org/33115
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 1c30f2c..13bea18 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -940,15 +940,9 @@ private:
 
         _loKitDocument->setView(viewId);
         _loKitDocument->registerCallback(nullptr, nullptr);
-        _loKitDocument->destroyView(viewId);
-        _viewIdToCallbackDescr.erase(viewId);
 
-        const int viewCount = _loKitDocument->getViewsCount();
-        LOG_INF("Document [" << _url << "] session [" <<
-                sessionId << "] unloaded view [" << viewId << "]. Have " <<
-                viewCount << " view" << (viewCount != 1 ? "s." : "."));
-
-        if (viewCount <= 0)
+        int viewCount = _loKitDocument->getViewsCount();
+        if (viewCount == 1)
         {
             std::unique_lock<std::mutex> lock(_mutex);
             if (_sessions.empty())
@@ -957,17 +951,35 @@ private:
                 std::_Exit(Application::EXIT_OK);
             }
 
+            LOG_INF("Document [" << _url << "] has no more views, but has " <<
+                    _sessions.size() << " sessions still. Destroying the document.");
+            _loKitDocument.reset();
+            LOG_INF("Document [" << _url << "] session [" << sessionId << "] unloaded Document.");
             return;
         }
+        else
+        {
+            _loKitDocument->destroyView(viewId);
+        }
 
-        // Get the list of view ids from the core
-        std::vector<int> viewIds(viewCount);
-        _loKitDocument->getViewIds(viewIds.data(), viewCount);
+         _viewIdToCallbackDescr.erase(viewId);
 
-        lockLokDoc.unlock();
+        viewCount = _loKitDocument->getViewsCount();
+        LOG_INF("Document [" << _url << "] session [" <<
+                sessionId << "] unloaded view [" << viewId << "]. Have " <<
+                viewCount << " view" << (viewCount != 1 ? "s." : "."));
 
-        // Broadcast updated view info
-        notifyViewInfo(viewIds);
+        if (viewCount > 0)
+        {
+            // Get the list of view ids from the core
+            std::vector<int> viewIds(viewCount);
+            _loKitDocument->getViewIds(viewIds.data(), viewCount);
+
+            lockLokDoc.unlock();
+
+            // Broadcast updated view info
+            notifyViewInfo(viewIds);
+        }
     }
 
     std::map<int, UserInfo> getViewInfo() override
@@ -1389,9 +1401,9 @@ private:
 
                     if (!isFound)
                     {
-                        LOG_WRN("Document::ViewCallback. The message [" << viewId <<
-                                "] [" << LOKitHelper::kitCallbackTypeToString(type) <<
-                                "] [" << payload << "] is not sent to Master Session.");
+                        LOG_WRN("Document::ViewCallback. Session [" << viewId <<
+                                "] is no longer active to process [" << LOKitHelper::kitCallbackTypeToString(type) <<
+                                "] [" << payload << "] message to Master Session.");
                     }
                 }
                 else
commit 0e5a75c46b9533fab5e600e2cab04ddca43dff10
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Jan 9 21:35:47 2017 -0500

    wsd: exit the kit only when no more sessions exist
    
    Change-Id: I26cd8876fd564f537dac4fb1748aee5b4dbdff04
    Reviewed-on: https://gerrit.libreoffice.org/33114
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 526aaa2..1c30f2c 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -950,8 +950,14 @@ private:
 
         if (viewCount <= 0)
         {
-            LOG_INF("Document [" << _url << "] has no more views, exiting bluntly.");
-            std::_Exit(Application::EXIT_OK);
+            std::unique_lock<std::mutex> lock(_mutex);
+            if (_sessions.empty())
+            {
+                LOG_INF("Document [" << _url << "] has no more views, exiting bluntly.");
+                std::_Exit(Application::EXIT_OK);
+            }
+
+            return;
         }
 
         // Get the list of view ids from the core
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index c64cc9c..32635d1 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -571,11 +571,14 @@ void HTTPWSTest::testBadLoad()
 
 void HTTPWSTest::testReload()
 {
+    auto const testname = "reload ";
+
     std::string documentPath, documentURL;
     getDocumentPathAndURL("hello.odt", documentPath, documentURL);
     for (auto i = 0; i < 3; ++i)
     {
-        loadDoc(documentURL, "reload ");
+        std::cerr << testname << "loading #" << (i+1) << std::endl;
+        loadDoc(documentURL, testname);
     }
 }
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e8c08a7..cb20b14 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -633,8 +633,6 @@ size_t DocumentBroker::addSession(std::shared_ptr<ClientSession>& session)
 
     const auto count = _sessions.size();
 
-    lock.unlock();
-
     // Request a new session from the child kit.
     _childProcess->sendTextFrame(aMessage);
 


More information about the Libreoffice-commits mailing list