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 @@ -911,10 +911,11 @@ void Environment::InitializeLibuv() {
911911 StartProfilerIdleNotifier ();
912912}
913913
914- void Environment::ExitEnv () {
914+ void Environment::ExitEnv (StopFlags::Flags flags ) {
915915 // Should not access non-thread-safe methods here.
916916 set_stopping (true );
917- isolate_->TerminateExecution ();
917+ if ((flags & StopFlags::kDoNotTerminateIsolate ) == 0 )
918+ isolate_->TerminateExecution ();
918919 SetImmediateThreadsafe ([](Environment* env) {
919920 env->set_can_call_into_js (false );
920921 uv_stop (env->event_loop ());
Original file line number Diff line number Diff 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 (StopFlags::Flags flags );
640640
641641 // Register clean-up cb to be called on environment destruction.
642642 inline void RegisterHandleCleanup (uv_handle_t * handle,
Original file line number Diff line number Diff line change @@ -1254,7 +1254,11 @@ int Start(int argc, char** argv) {
12541254}
12551255
12561256int Stop (Environment* env) {
1257- env->ExitEnv ();
1257+ return Stop (env, StopFlags::kNoFlags );
1258+ }
1259+
1260+ int Stop (Environment* env, StopFlags::Flags flags) {
1261+ env->ExitEnv (flags);
12581262 return 0 ;
12591263}
12601264
Original file line number Diff line number Diff line change @@ -273,6 +273,15 @@ enum Flags : uint32_t {
273273} // namespace ProcessInitializationFlags
274274namespace ProcessFlags = ProcessInitializationFlags; // Legacy alias.
275275
276+ namespace StopFlags {
277+ enum Flags : uint32_t {
278+ kNoFlags = 0 ,
279+ // Do not explicitly terminate the Isolate
280+ // when exiting the Environment.
281+ kDoNotTerminateIsolate = 1 << 0 ,
282+ };
283+ } // namespace StopFlags
284+
276285class NODE_EXTERN InitializationResult {
277286 public:
278287 virtual ~InitializationResult ();
@@ -309,6 +318,7 @@ NODE_EXTERN int Start(int argc, char* argv[]);
309318// Tear down Node.js while it is running (there are active handles
310319// in the loop and / or actively executing JavaScript code).
311320NODE_EXTERN int Stop (Environment* env);
321+ NODE_EXTERN int Stop (Environment* env, StopFlags::Flags flags);
312322
313323// Set up per-process state needed to run Node.js. This will consume arguments
314324// from argv, fill exec_argv, and possibly add errors resulting from parsing
You can’t perform that action at this time.
0 commit comments