loolwsd/LOOLForKit.cpp | 20 +++++++++++--------- loolwsd/LOOLWSD.cpp | 9 +++++---- 2 files changed, 16 insertions(+), 13 deletions(-)
New commits: commit cf2f4ed712d87ba46055f9a0666447fdd727d8e4 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Nov 15 22:03:49 2016 -0500 loolwsd: improve interrupted pipe-reading handling in forkit Change-Id: Iabaadee064bb1178cc6b1bd3482608a758d65506 Reviewed-on: https://gerrit.libreoffice.org/30892 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp index 8509446..ab3d2c3 100644 --- a/loolwsd/LOOLForKit.cpp +++ b/loolwsd/LOOLForKit.cpp @@ -72,20 +72,22 @@ public: { std::string message; const auto ready = readLine(message, [](){ return TerminationFlag.load(); }); - if (ready == 0) - { - // Timeout. - return true; - } - else if (ready < 0) + if (ready <= 0) { // Termination is done via SIGTERM, which breaks the wait. - if (!TerminationFlag) + if (TerminationFlag) { - Log::error("Error reading from pipe [" + getName() + "]."); + if (ready < 0) + { + LOG_INF("Poll interrupted in " << getName() << " and Termination flag set."); + } + + // Break. + return false; } - return false; + // Timeout. + return true; } LOG_INF("ForKit command: [" << message << "]."); commit 4c9a2e821d5f32005be3a10ceecb107ea20ecc29 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Nov 15 22:03:11 2016 -0500 loolwsd: don't set TerminationFlag unnecessarily Change-Id: I993e1c5bfdb5b4a5d9a421bc61fa90fdfd1ba00b Reviewed-on: https://gerrit.libreoffice.org/30891 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 94be625..c0d19aa 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -2032,7 +2032,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/) { // No child processes. LOG_FTL("No Forkit instance. Terminating."); - TerminationFlag = true; break; } } @@ -2072,7 +2071,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/) if (careerSpanSeconds > 0 && time(nullptr) > startTimeSpan + careerSpanSeconds) { LOG_INF((time(nullptr) - startTimeSpan) << " seconds gone, finishing as requested."); - TerminationFlag = true; break; } #endif @@ -2080,8 +2078,10 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/) // Stop the listening to new connections // and wait until sockets close. - LOG_INF("Stopping server socket listening."); + LOG_INF("Stopping server socket listening. ShutdownFlag: " << + ShutdownFlag << ", TerminationFlag: " << TerminationFlag); Util::alertAllUsers("internal", "shutdown"); + srv.stop(); srv2.stop(); threadPool.joinAll(); @@ -2094,10 +2094,11 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/) child->close(true); } - // Wait for forkit process finish + // Wait for forkit process finish. waitpid(forKitPid, &status, WUNTRACED); close(ForKitWritePipe); + // In case forkit didn't cleanup fully.' LOG_INF("Cleaning up childroot directory [" << ChildRoot << "]."); std::vector<std::string> jails; File(ChildRoot).list(jails); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits