[Libreoffice-commits] online.git: loolwsd/DocumentBroker.hpp loolwsd/LOOLKit.cpp loolwsd/protocol.txt
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 7 06:39:02 UTC 2016
loolwsd/DocumentBroker.hpp | 37 ++++++++++++++++++++++++++++---------
loolwsd/LOOLKit.cpp | 5 +++++
loolwsd/protocol.txt | 4 ++++
3 files changed, 37 insertions(+), 9 deletions(-)
New commits:
commit 8cd8ca27a642c3049476a575948f63e34ebb8df8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Nov 6 21:16:11 2016 -0500
loolwsd: new 'exit' command to request child process termination
Change-Id: Id3f9bc67096b422630e04f59ed4ccbca012ddd4a
Reviewed-on: https://gerrit.libreoffice.org/30641
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index fdb7fac..60a7099 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -69,6 +69,18 @@ public:
{
LOG_DBG("Stopping ChildProcess [" << _pid << "]");
_stop = true;
+
+ try
+ {
+ if (_pid != -1 && _ws)
+ {
+ sendTextFrame("exit");
+ }
+ }
+ catch (const std::exception&)
+ {
+ LOG_ERR("Failed to send 'exit' command to child [" << _pid << "].");
+ }
}
void close(const bool rude)
@@ -84,16 +96,19 @@ public:
}
_ws.reset();
- if (_pid != -1)
+ if (_pid != -1 && kill(_pid, 0) != 0)
{
- LOG_INF("Closing child [" << _pid << "].");
- if (rude && kill(_pid, SIGINT) != 0 && kill(_pid, 0) != 0)
+ if (rude)
{
- Log::syserror("Cannot terminate lokit [" + std::to_string(_pid) + "]. Abandoning.");
+ LOG_INF("Killing child [" << _pid << "].");
+ if (kill(_pid, SIGINT) != 0 && kill(_pid, 0) != 0)
+ {
+ Log::syserror("Cannot terminate lokit [" + std::to_string(_pid) + "]. Abandoning.");
+ }
}
-
- _pid = -1;
}
+
+ _pid = -1;
}
catch (const std::exception& ex)
{
@@ -108,9 +123,12 @@ public:
{
try
{
- LOG_TRC("DocBroker to Child: " << data);
- _ws->sendFrame(data.data(), data.size());
- return true;
+ if (_ws)
+ {
+ LOG_TRC("DocBroker to Child: " << data);
+ _ws->sendFrame(data.data(), data.size());
+ return true;
+ }
}
catch (const std::exception& exc)
{
@@ -119,6 +137,7 @@ public:
throw;
}
+ LOG_WRN("No socket between DocBroker and child to send [" << data << "]");
return false;
}
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 2fc199d..a89ba53 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1521,6 +1521,11 @@ void lokit_main(const std::string& childRoot,
LOG_DBG("CreateSession failed.");
}
}
+ else if (tokens[0] == "exit")
+ {
+ LOG_TRC("Setting TerminationFlag due to 'exit' command from parent.");
+ TerminationFlag = true;
+ }
else if (tokens[0] == "tile" || tokens[0] == "tilecombine" || tokens[0] == "canceltiles" ||
LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
{
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 560208f..f6035b9 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -395,6 +395,10 @@ disconnect
Signals to the child that the client for the respective connection
has disconnected.
+exit
+
+ Signals to the child that the process must end and exit.
+
Admin console
===============
More information about the Libreoffice-commits
mailing list