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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 2 06:08:10 UTC 2017


 wsd/LOOLWSD.cpp |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

New commits:
commit fb1e8eb63ae6a0b8626e6e798fa45176e4f6e713
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 1 15:42:22 2017 -0500

    wsd: flag for shutdown when we fail to create forkit
    
    And say 'forkit' in the logs where we recognize it
    instead of the generic 'child'.
    
    Change-Id: I7628b064bb6330db145a948640e48b727def3270
    Reviewed-on: https://gerrit.libreoffice.org/32619
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f30edf0..f46df92 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -464,7 +464,7 @@ static std::shared_ptr<ChildProcess> getNewChild()
             }
         }
 
-        LOG_DBG("getNewChild: No live child, forking more.");
+        LOG_WRN("getNewChild: No available child. Sending spawn request to forkit and failing.");
     }
     while (chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime).count() <
            CHILD_TIMEOUT_MS * 4);
@@ -2102,12 +2102,12 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
                 {
                     if (WIFEXITED(status))
                     {
-                        LOG_INF("Child process [" << pid << "] exited with code: " <<
+                        LOG_INF("Forkit process [" << pid << "] exited with code: " <<
                                 WEXITSTATUS(status) << ".");
                     }
                     else
                     {
-                        LOG_ERR("Child process [" << pid << "] " <<
+                        LOG_ERR("Forkit process [" << pid << "] " <<
                                 (WCOREDUMP(status) ? "core-dumped" : "died") <<
                                 " with " << SigUtil::signalName(WTERMSIG(status)));
                     }
@@ -2118,17 +2118,18 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
                     if (forKitPid < 0)
                     {
                         LOG_FTL("Failed to spawn forkit instance. Shutting down.");
+                        SigUtil::requestShutdown();
                         break;
                     }
                 }
                 else if (WIFSTOPPED(status))
                 {
-                    LOG_INF("Child process [" << pid << "] stopped with " <<
+                    LOG_INF("Forkit process [" << pid << "] stopped with " <<
                             SigUtil::signalName(WSTOPSIG(status)));
                 }
                 else if (WIFCONTINUED(status))
                 {
-                    LOG_INF("Child process [" << pid << "] resumed with SIGCONT.");
+                    LOG_INF("Forkit process [" << pid << "] resumed with SIGCONT.");
                 }
                 else
                 {
@@ -2137,17 +2138,24 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
             }
             else
             {
-                LOG_ERR("An unknown child process died, pid: " << pid);
+                LOG_ERR("An unknown child process [" << pid << "] died.");
             }
         }
         else if (pid < 0)
         {
-            LOG_SYS("waitpid failed.");
+            LOG_SYS("Forkit waitpid failed.");
             if (errno == ECHILD)
             {
                 // No child processes.
-                LOG_FTL("No Forkit instance. Terminating.");
-                break;
+                // Spawn a new forkit and try to dust it off and resume.
+                close(ForKitWritePipe);
+                forKitPid = createForKit();
+                if (forKitPid < 0)
+                {
+                    LOG_FTL("Failed to spawn forkit instance. Shutting down.");
+                    SigUtil::requestShutdown();
+                    break;
+                }
             }
         }
         else // pid == 0, no children have died


More information about the Libreoffice-commits mailing list