summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBartosz Sosnowski <bartosz@janeasystems.com>2016-12-12 12:02:10 +0100
committerJoão Reis <reis@janeasystems.com>2016-12-23 02:32:08 +0000
commitb2321c24dc4bec8f148e0b30cae4ff18f2133c14 (patch)
tree8888b2fabb2c7e0e9e1bf3c54a187fe092cce20f /src
parent4e1b2e73c46873ae91d5c18f718ac876caa73892 (diff)
downloadandroid-node-v8-b2321c24dc4bec8f148e0b30cae4ff18f2133c14.tar.gz
android-node-v8-b2321c24dc4bec8f148e0b30cae4ff18f2133c14.tar.bz2
android-node-v8-b2321c24dc4bec8f148e0b30cae4ff18f2133c14.zip
watchdog: add flag to mark handler as disabled
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of removing it. Trying to remove the controller from the controller handle itself leads to deadlock. PR-URL: https://github.com/nodejs/node/pull/10248 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src')
-rw-r--r--src/node_watchdog.cc13
-rw-r--r--src/node_watchdog.h1
2 files changed, 11 insertions, 3 deletions
diff --git a/src/node_watchdog.cc b/src/node_watchdog.cc
index 01b39123be..5d95c4132f 100644
--- a/src/node_watchdog.cc
+++ b/src/node_watchdog.cc
@@ -150,7 +150,8 @@ void SigintWatchdogHelper::HandleSignal(int signum) {
// Windows starts a separate thread for executing the handler, so no extra
// helper thread is required.
BOOL WINAPI SigintWatchdogHelper::WinCtrlCHandlerRoutine(DWORD dwCtrlType) {
- if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) {
+ if (!instance.watchdog_disabled_ &&
+ (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT)) {
InformWatchdogsAboutSignal();
// Return true because the signal has been handled.
@@ -207,7 +208,11 @@ int SigintWatchdogHelper::Start() {
RegisterSignalHandler(SIGINT, HandleSignal);
#else
- SetConsoleCtrlHandler(WinCtrlCHandlerRoutine, TRUE);
+ if (watchdog_disabled_) {
+ watchdog_disabled_ = false;
+ } else {
+ SetConsoleCtrlHandler(WinCtrlCHandlerRoutine, TRUE);
+ }
#endif
return 0;
@@ -251,7 +256,7 @@ bool SigintWatchdogHelper::Stop() {
RegisterSignalHandler(SIGINT, SignalExit, true);
#else
- SetConsoleCtrlHandler(WinCtrlCHandlerRoutine, FALSE);
+ watchdog_disabled_ = true;
#endif
had_pending_signal = has_pending_signal_;
@@ -292,6 +297,8 @@ SigintWatchdogHelper::SigintWatchdogHelper()
has_running_thread_ = false;
stopping_ = false;
CHECK_EQ(0, uv_sem_init(&sem_, 0));
+#else
+ watchdog_disabled_ = false;
#endif
}
diff --git a/src/node_watchdog.h b/src/node_watchdog.h
index dd97e4e735..2d55d782d0 100644
--- a/src/node_watchdog.h
+++ b/src/node_watchdog.h
@@ -91,6 +91,7 @@ class SigintWatchdogHelper {
static void* RunSigintWatchdog(void* arg);
static void HandleSignal(int signum);
#else
+ bool watchdog_disabled_;
static BOOL WINAPI WinCtrlCHandlerRoutine(DWORD dwCtrlType);
#endif
};