File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed
Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -902,10 +902,11 @@ void Environment::InitializeLibuv() {
902902 StartProfilerIdleNotifier ();
903903}
904904
905- void Environment::ExitEnv () {
905+ void Environment::ExitEnv (StopFlags::Flags flags ) {
906906 // Should not access non-thread-safe methods here.
907907 set_stopping (true );
908- isolate_->TerminateExecution ();
908+ if ((flags & StopFlags::kDoNotTerminateIsolate ) == 0 )
909+ isolate_->TerminateExecution ();
909910 SetImmediateThreadsafe ([](Environment* env) {
910911 env->set_can_call_into_js (false );
911912 uv_stop (env->event_loop ());
Original file line number Diff line number Diff line change @@ -628,7 +628,7 @@ class Environment : public MemoryRetainer {
628628 void RegisterHandleCleanups ();
629629 void CleanupHandles ();
630630 void Exit (int code);
631- void ExitEnv ();
631+ void ExitEnv (StopFlags::Flags flags );
632632
633633 // Register clean-up cb to be called on environment destruction.
634634 inline void RegisterHandleCleanup (uv_handle_t * handle,
Original file line number Diff line number Diff line change @@ -1231,7 +1231,11 @@ int Start(int argc, char** argv) {
12311231}
12321232
12331233int Stop (Environment* env) {
1234- env->ExitEnv ();
1234+ return Stop (env, StopFlags::kNoFlags );
1235+ }
1236+
1237+ int Stop (Environment* env, StopFlags::Flags flags) {
1238+ env->ExitEnv (flags);
12351239 return 0 ;
12361240}
12371241
Original file line number Diff line number Diff line change @@ -274,6 +274,15 @@ enum Flags : uint64_t {
274274// TODO(addaleax): Make this the canonical name, as it is more descriptive.
275275namespace ProcessInitializationFlags = ProcessFlags;
276276
277+ namespace StopFlags {
278+ enum Flags : uint32_t {
279+ kNoFlags = 0 ,
280+ // Do not explicitly terminate the Isolate
281+ // when exiting the Environment.
282+ kDoNotTerminateIsolate = 1 << 0 ,
283+ };
284+ } // namespace StopFlags
285+
277286class NODE_EXTERN InitializationResult {
278287 public:
279288 virtual ~InitializationResult ();
@@ -310,6 +319,7 @@ NODE_EXTERN int Start(int argc, char* argv[]);
310319// Tear down Node.js while it is running (there are active handles
311320// in the loop and / or actively executing JavaScript code).
312321NODE_EXTERN int Stop (Environment* env);
322+ NODE_EXTERN int Stop (Environment* env, StopFlags::Flags flags);
313323
314324// This runs a subset of the initialization performed by
315325// InitializeOncePerProcess(), which supersedes this function.
You can’t perform that action at this time.
0 commit comments