loolwsd: improve interrupted pipe-reading handling in forkit

Change-Id: Iabaadee064bb1178cc6b1bd3482608a758d65506
Reviewed-on: https://gerrit.libreoffice.org/30892
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2016-11-15 22:03:49 -05:00 committed by Ashod Nakashian
parent 4c9a2e821d
commit cf2f4ed712

View file

@ -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 << "].");