[Libreoffice-commits] online.git: loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat Mar 26 16:53:25 UTC 2016


 loolwsd/LOOLBroker.cpp |    7 +++++++
 loolwsd/LOOLKit.cpp    |   18 ++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

New commits:
commit a35006cdefe6a0b515e039761f644b524e114a78
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Mar 25 14:19:56 2016 -0400

    loolwsd: no need to lock in destructor
    
    Change-Id: I1650bc5b44c23f1de8b5f65e621da43f1a2755eb
    Reviewed-on: https://gerrit.libreoffice.org/23529
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 890bf04..e2ac062 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -143,15 +143,22 @@ namespace
         std::lock_guard<std::recursive_mutex> lock(forkMutex);
 
         std::shared_ptr<ChildProcess> child;
+        Log::trace() << "Finding child for url [" << url << "] in "
+                     << _childProcesses.size() << " childs." << Log::end;
         for (const auto& it : _childProcesses)
         {
+            Log::trace() << "Child [" << it.second->getPid()
+                         << "] url [" << url << "]." << Log::end;
             if (it.second->getUrl() == url)
             {
                 return it.second;
             }
 
             if (it.second->getUrl().empty())
+            {
+                // Empty one, but keep going, we might find ours.
                 child = it.second;
+            }
         }
 
         return child;
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index e4fa310..3831390 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -368,8 +368,6 @@ public:
             }
         }
 
-        std::unique_lock<std::mutex> lock(_mutex);
-
         // Destroy all connections and views.
         _connections.clear();
 
@@ -961,7 +959,10 @@ void lokit_main(const std::string& childRoot,
                     }
 
                     if (isUsedKit && _documents.empty())
+                    {
+                        Log::info("Document closed. Flagging for termination.");
                         TerminationFlag = true;
+                    }
                 }
                 else
                 if (ready < 0)
@@ -1012,7 +1013,7 @@ void lokit_main(const std::string& childRoot,
                         it = (it->second->canDiscard() ? _documents.erase(it) : ++it);
                     }
 
-                    if (isUsedKit && _documents.empty())
+                    if (TerminationFlag || (isUsedKit && _documents.empty()))
                     {
                         TerminationFlag = true;
                         response += "down \r\n";
@@ -1082,13 +1083,18 @@ void lokit_main(const std::string& childRoot,
         Log::error(std::string("Exception: ") + exc.what());
     }
 
-    Log::debug("Destroying documents.");
-    _documents.clear();
+    if (!_documents.empty())
+    {
+        Log::debug("Destroying documents.");
+        _documents.clear();
+    }
 
     // Destroy LibreOfficeKit
-    Log::debug("Destroying LibreOfficeKit.");
     if (loKit)
+    {
+        Log::debug("Destroying LibreOfficeKit.");
         loKit->pClass->destroy(loKit);
+    }
 
     std::ostringstream message;
     message << "rmdoc" << " "


More information about the Libreoffice-commits mailing list