Skip to content

Commit 24c6777

Browse files
committed
src: allow optional Isolate termination in node::Stop()
1 parent 5092346 commit 24c6777

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/env.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,11 @@ void Environment::InitializeLibuv() {
911911
StartProfilerIdleNotifier();
912912
}
913913

914-
void Environment::ExitEnv() {
914+
void Environment::ExitEnv(bool terminate) {
915915
// Should not access non-thread-safe methods here.
916916
set_stopping(true);
917-
isolate_->TerminateExecution();
917+
if (terminate)
918+
isolate_->TerminateExecution();
918919
SetImmediateThreadsafe([](Environment* env) {
919920
env->set_can_call_into_js(false);
920921
uv_stop(env->event_loop());

src/env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ class Environment : public MemoryRetainer {
636636
void RegisterHandleCleanups();
637637
void CleanupHandles();
638638
void Exit(ExitCode code);
639-
void ExitEnv();
639+
void ExitEnv(bool terminate);
640640

641641
// Register clean-up cb to be called on environment destruction.
642642
inline void RegisterHandleCleanup(uv_handle_t* handle,

src/node.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,8 @@ int Start(int argc, char** argv) {
12531253
return static_cast<int>(StartInternal(argc, argv));
12541254
}
12551255

1256-
int Stop(Environment* env) {
1257-
env->ExitEnv();
1256+
int Stop(Environment* env, bool terminate) {
1257+
env->ExitEnv(terminate);
12581258
return 0;
12591259
}
12601260

src/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ NODE_EXTERN int Start(int argc, char* argv[]);
308308

309309
// Tear down Node.js while it is running (there are active handles
310310
// in the loop and / or actively executing JavaScript code).
311-
NODE_EXTERN int Stop(Environment* env);
311+
NODE_EXTERN int Stop(Environment* env, bool terminate = true);
312312

313313
// Set up per-process state needed to run Node.js. This will consume arguments
314314
// from argv, fill exec_argv, and possibly add errors resulting from parsing

0 commit comments

Comments
 (0)