diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-01-01 15:42:22 -0500 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-03-27 01:26:27 +0000 |
commit | d32178652df26b9607101319eae0d9d9bf5e7b9e (patch) | |
tree | 8c14d053acd3cb1a9f8124ae55ce3e7fb1f3dfc7 | |
parent | 082678adb24003dc1128923a470cec1f9203c713 (diff) |
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@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r-- | wsd/LOOLWSD.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 9ea9d4971..866ad79f8 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 |