[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/Util.cpp loolwsd/Util.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Nov 14 05:30:28 UTC 2016


 loolwsd/LOOLKit.cpp |   10 +++++-----
 loolwsd/LOOLWSD.cpp |    3 ++-
 loolwsd/Util.cpp    |   13 ++++++++++++-
 loolwsd/Util.hpp    |    5 +++++
 4 files changed, 24 insertions(+), 7 deletions(-)

New commits:
commit 47d040f34532e1b913a64d340dd891601a83072b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Nov 13 16:13:36 2016 -0500

    loolwsd: handle SIGINT in WSD only
    
    CONTROL-C is now handled by WSD only to
    have full control over server shutting down.
    
    Also set signal handlers first thing to trap
    any early failures.
    
    Change-Id: Ifc5c93b9dd2aef288eed0ed36c600a639dbc6a44
    Reviewed-on: https://gerrit.libreoffice.org/30826
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 507ad94..17bd15c 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1279,6 +1279,11 @@ void lokit_main(const std::string& childRoot,
                 bool queryVersion,
                 bool displayVersion)
 {
+    Util::setFatalSignals();
+    Util::setTerminationSignals();
+
+    Util::setThreadName("loolkit");
+
     // Reinitialize logging when forked.
     const bool logToFile = std::getenv("LOOL_LOGFILE");
     const char* logFilename = std::getenv("LOOL_LOGFILENAME");
@@ -1304,13 +1309,8 @@ void lokit_main(const std::string& childRoot,
     static const std::string pid = std::to_string(Process::id());
     static const std::string jailId = pid;
 
-    Util::setThreadName("loolkit");
-
     LOG_DBG("Process started.");
 
-    Util::setTerminationSignals();
-    Util::setFatalSignals();
-
     std::string userdir_url;
     std::string instdir_path;
 
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 177b155..4655a91 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1846,8 +1846,9 @@ Process::PID LOOLWSD::createForKit()
 
 int LOOLWSD::main(const std::vector<std::string>& /*args*/)
 {
-    Util::setTerminationSignals();
     Util::setFatalSignals();
+    Util::setTerminationSignals();
+    Util::setInterruptionSignal();
 
     // down-pay all the forkit linking cost once & early.
     Environment::set("LD_BIND_NOW", "1");
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index b5c26a7..deb2819 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -218,11 +218,22 @@ namespace Util
         action.sa_handler = handleTerminationSignal;
 
         sigaction(SIGTERM, &action, nullptr);
-        sigaction(SIGINT, &action, nullptr);
         sigaction(SIGQUIT, &action, nullptr);
         sigaction(SIGHUP, &action, nullptr);
     }
 
+    /// Handle SIGINT, should be set by WSD only.
+    void setInterruptionSignal()
+    {
+        struct sigaction action;
+
+        sigemptyset(&action.sa_mask);
+        action.sa_flags = 0;
+        action.sa_handler = handleTerminationSignal;
+
+        sigaction(SIGINT, &action, nullptr);
+    }
+
     static char FatalGdbString[256] = { '\0' };
 
     static
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 93c95f7..2303a65 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -84,8 +84,13 @@ namespace Util
 
     /// Trap signals to cleanup and exit the process gracefully.
     void setTerminationSignals();
+
+    /// Trap all fatal signals to assist debugging.
     void setFatalSignals();
 
+    /// Trap SIGINT, should be set by WSD only.
+    void setInterruptionSignal();
+
     void requestTermination(const Poco::Process::PID& pid);
 
     /// Kills a child process and returns true when


More information about the Libreoffice-commits mailing list