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

Henry Castro hcastro at collabora.com
Wed Feb 3 21:36:25 UTC 2016


 loolwsd/LOOLBroker.cpp |   46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

New commits:
commit b7ee46f729e102c9a09070c75f9385c942aa96b7
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Feb 3 17:35:35 2016 -0400

    loolwsd: child exit codes are required before fork new lokit process

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index df278a5..6c3b3f8 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -949,29 +949,6 @@ int main(int argc, char** argv)
     unsigned timeoutCounter = 0;
     while (!TerminationFlag)
     {
-        if (forkCounter > 0)
-        {
-            std::lock_guard<std::recursive_mutex> lock(forkMutex);
-
-            const signed empty = pipeHandler.syncChilds();
-            const signed total = _childProcesses.size();
-
-            // Figure out how many children we need. Always create at least as many
-            // as configured pre-spawn or one more than requested (whichever is larger).
-            signed spawn = std::max(static_cast<int>(forkCounter) + 1, numPreSpawnedChildren);
-            Log::debug() << "Creating " << spawn << " childs. Current Total: "
-                         << total << ", Empty: " << empty << Log::end;
-            do
-            {
-                if (createLibreOfficeKit(sharePages, loSubPath, jailId) < 0)
-                    Log::error("Error: fork failed.");
-            }
-            while (--spawn > 0);
-
-            // We've done our best. If need more, retrying will bump the counter.
-            forkCounter = 0;
-        }
-
         int status;
         const pid_t pid = waitpid(-1, &status, WUNTRACED | WNOHANG);
         if (pid > 0)
@@ -1019,6 +996,29 @@ int main(int argc, char** argv)
         else if (pid < 0)
             Log::error("Error: waitpid failed.");
 
+        if (forkCounter > 0)
+        {
+            std::lock_guard<std::recursive_mutex> lock(forkMutex);
+
+            const signed empty = pipeHandler.syncChilds();
+            const signed total = _childProcesses.size();
+
+            // Figure out how many children we need. Always create at least as many
+            // as configured pre-spawn or one more than requested (whichever is larger).
+            signed spawn = std::max(static_cast<int>(forkCounter) + 1, numPreSpawnedChildren);
+            Log::debug() << "Creating " << spawn << " childs. Current Total: "
+                         << total << ", Empty: " << empty << Log::end;
+            do
+            {
+                if (createLibreOfficeKit(sharePages, loSubPath, jailId) < 0)
+                    Log::error("Error: fork failed.");
+            }
+            while (--spawn > 0);
+
+            // We've done our best. If need more, retrying will bump the counter.
+            forkCounter = 0;
+        }
+
         if (timeoutCounter++ == INTERVAL_PROBES)
         {
             timeoutCounter = 0;


More information about the Libreoffice-commits mailing list