Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-18 05:58:58 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-22 13:43:40 +0300
commit19e3e02a2db996a3df36e00df6c6b57cec516c9e (patch)
treebbf50d100e24232422a3039ed567647db68d9de1 /src/node_contextify.cc
parent7c816b7588f0e2910bcef5db48f71296cd3b67c2 (diff)
src: move SIGINT watchdog utils to the contextify binding
These are used when evaluating scripts so it makes more sense to put them in the contextify binding whose other methods are going to be used together. PR-URL: https://github.com/nodejs/node/pull/27290 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r--src/node_contextify.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 25b8b28ecd5..f8d43e062ee 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -1141,6 +1141,20 @@ void ContextifyContext::CompileFunction(
args.GetReturnValue().Set(fn);
}
+static void StartSigintWatchdog(const FunctionCallbackInfo<Value>& args) {
+ int ret = SigintWatchdogHelper::GetInstance()->Start();
+ args.GetReturnValue().Set(ret == 0);
+}
+
+static void StopSigintWatchdog(const FunctionCallbackInfo<Value>& args) {
+ bool had_pending_signals = SigintWatchdogHelper::GetInstance()->Stop();
+ args.GetReturnValue().Set(had_pending_signals);
+}
+
+static void WatchdogHasPendingSigint(const FunctionCallbackInfo<Value>& args) {
+ bool ret = SigintWatchdogHelper::GetInstance()->HasPendingSignal();
+ args.GetReturnValue().Set(ret);
+}
void Initialize(Local<Object> target,
Local<Value> unused,
@@ -1149,6 +1163,12 @@ void Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
ContextifyContext::Init(env, target);
ContextifyScript::Init(env, target);
+
+ env->SetMethod(target, "startSigintWatchdog", StartSigintWatchdog);
+ env->SetMethod(target, "stopSigintWatchdog", StopSigintWatchdog);
+ // Used in tests.
+ env->SetMethodNoSideEffect(
+ target, "watchdogHasPendingSigint", WatchdogHasPendingSigint);
}
} // namespace contextify