[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Mar 27 01:26:45 UTC 2017


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

New commits:
commit d32178652df26b9607101319eae0d9d9bf5e7b9e
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/35578
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9ea9d497..866ad79f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -431,7 +431,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);
@@ -2038,12 +2038,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)));
                     }
@@ -2054,17 +2054,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) == true)
                 {
-                    LOG_INF("Child process [" << pid << "] stopped with " <<
+                    LOG_INF("Forkit process [" << pid << "] stopped with " <<
                             SigUtil::signalName(WSTOPSIG(status)));
                 }
                 else if (WIFCONTINUED(status) == true)
                 {
-                    LOG_INF("Child process [" << pid << "] resumed with SIGCONT.");
+                    LOG_INF("Forkit process [" << pid << "] resumed with SIGCONT.");
                 }
                 else
                 {
@@ -2073,17 +2074,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