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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun May 8 04:17:26 UTC 2016


 loolwsd/LOOLWSD.cpp |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 9e7b0865878c02a23faca9bda37c0451347402b1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat May 7 09:42:10 2016 -0400

    loolwsd: refactored new child addition
    
    Change-Id: I5f554dd0c2d37be3f90059bc8a943cbbe7ac094b
    Reviewed-on: https://gerrit.libreoffice.org/24737
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 9685350..fdaaf78 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -211,6 +211,19 @@ static void prespawnChildren()
     forkChildren(balance);
 }
 
+static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
+{
+    std::unique_lock<std::mutex> lock(newChildrenMutex);
+    newChildren.emplace_back(child);
+    const auto count = newChildren.size();
+    Log::info() << "Have " << count << " "
+                << (count == 1 ? "child" : "children")
+                << "." << Log::end;
+
+    newChildrenCV.notify_one();
+    return count;
+}
+
 static std::shared_ptr<ChildProcess> getNewChild()
 {
     std::unique_lock<std::mutex> lock(newChildrenMutex);
@@ -867,11 +880,9 @@ public:
 
             Log::info("New child [" + std::to_string(pid) + "].");
             auto ws = std::make_shared<WebSocket>(request, response);
-            std::unique_lock<std::mutex> lock(newChildrenMutex);
-            newChildren.emplace_back(std::make_shared<ChildProcess>(pid, ws));
-            Log::info("Have " + std::to_string(newChildren.size()) + " " + (newChildren.size() == 1 ? "child" : "children") + ".");
-            newChildrenCV.notify_one();
             UnitWSD::get().newChild(ws);
+
+            addNewChild(std::make_shared<ChildProcess>(pid, ws));
             return;
         }
 


More information about the Libreoffice-commits mailing list