[Libreoffice-commits] online.git: loolwsd/common loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Nov 20 00:26:58 UTC 2016
loolwsd/LOOLWSD.cpp | 6 +++---
loolwsd/common/SigUtil.cpp | 10 +++++++++-
loolwsd/common/SigUtil.hpp | 6 +++---
3 files changed, 15 insertions(+), 7 deletions(-)
New commits:
commit efe6b96738fb1adcc9fac9248e1de0a3c4ae970a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Nov 19 11:35:09 2016 -0500
loolwsd: privatize ShutdownFlag and add public getter
Change-Id: I129fa8dda907758730bb494d1da950f48c61abbc
Reviewed-on: https://gerrit.libreoffice.org/31004
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 2cdf5d4..1f8644f 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -886,7 +886,7 @@ private:
return session->handleInput(payload.data(), payload.size());
},
[&session]() { session->closeFrame(); },
- []() { return TerminationFlag || ShutdownFlag; });
+ []() { return TerminationFlag || SigUtil::isShuttingDown(); });
// Connection terminated. Destroy session.
LOG_DBG("Client session [" << id << "] terminated. Cleaning up.");
@@ -1968,7 +1968,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
time_t last30SecCheck = time(nullptr);
int status = 0;
- while (!TerminationFlag && !ShutdownFlag)
+ while (!TerminationFlag && !SigUtil::isShuttingDown())
{
UnitWSD::get().invokeTest();
if (TerminationFlag || SigUtil::handleShutdownRequest())
@@ -2077,7 +2077,7 @@ 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. ShutdownFlag: " <<
- ShutdownFlag << ", TerminationFlag: " << TerminationFlag);
+ SigUtil::isShuttingDown() << ", TerminationFlag: " << TerminationFlag);
srv.stop();
srv2.stop();
diff --git a/loolwsd/common/SigUtil.cpp b/loolwsd/common/SigUtil.cpp
index db29de5..02443df 100644
--- a/loolwsd/common/SigUtil.cpp
+++ b/loolwsd/common/SigUtil.cpp
@@ -51,9 +51,12 @@
#include "Util.hpp"
std::atomic<bool> TerminationFlag(false);
-std::atomic<bool> ShutdownFlag(false);
std::mutex SigHandlerTrap;
+/// Flag to shutdown the server.
+std::atomic<bool> ShutdownFlag;
+
+/// Flag to request WSD to notify clients and shutdown.
static std::atomic<bool> ShutdownRequestFlag(false);
namespace SigUtil
@@ -262,6 +265,11 @@ namespace SigUtil
return false;
}
+ bool isShuttingDown()
+ {
+ return ShutdownFlag;
+ }
+
bool killChild(const int pid)
{
LOG_DBG("Killing PID: " << pid);
diff --git a/loolwsd/common/SigUtil.hpp b/loolwsd/common/SigUtil.hpp
index a17d808..a478161 100644
--- a/loolwsd/common/SigUtil.hpp
+++ b/loolwsd/common/SigUtil.hpp
@@ -16,9 +16,6 @@
/// Flag to stop pump loops.
extern std::atomic<bool> TerminationFlag;
-/// Flag to shutdown the server.
-extern std::atomic<bool> ShutdownFlag;
-
/// Mutex to trap signal handler, if any,
/// and prevent _Exit while collecting backtrace.
extern std::mutex SigHandlerTrap;
@@ -49,6 +46,9 @@ namespace SigUtil
/// Returns true if shutdown is requested.
bool handleShutdownRequest();
+ /// Returns true if Shutdown is in progress.
+ bool isShuttingDown();
+
/// Kills a child process and returns true when
/// child pid is removed from the process table
/// after a certain (short) timeout.
More information about the Libreoffice-commits
mailing list