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 @@ -910,10 +910,11 @@ void Environment::InitializeLibuv() {
910910 StartProfilerIdleNotifier ();
911911}
912912
913- void Environment::ExitEnv () {
913+ void Environment::ExitEnv (StopFlags::Flags flags ) {
914914 // Should not access non-thread-safe methods here.
915915 set_stopping (true );
916- isolate_->TerminateExecution ();
916+ if ((flags & StopFlags::kDoNotTerminateIsolate ) == 0 )
917+ isolate_->TerminateExecution ();
917918 SetImmediateThreadsafe ([](Environment* env) {
918919 env->set_can_call_into_js (false );
919920 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 @@ -1248,7 +1248,11 @@ int Start(int argc, char** argv) {
12481248}
12491249
12501250int Stop (Environment* env) {
1251- env->ExitEnv ();
1251+ return Stop (env, StopFlags::kNoFlags );
1252+ }
1253+
1254+ int Stop (Environment* env, StopFlags::Flags flags) {
1255+ env->ExitEnv (flags);
12521256 return 0 ;
12531257}
12541258
Original file line number Diff line number Diff line change @@ -276,6 +276,15 @@ enum Flags : uint64_t {
276276// TODO(addaleax): Make this the canonical name, as it is more descriptive.
277277namespace ProcessInitializationFlags = ProcessFlags;
278278
279+ namespace StopFlags {
280+ enum Flags : uint32_t {
281+ kNoFlags = 0 ,
282+ // Do not explicitly terminate the Isolate
283+ // when exiting the Environment.
284+ kDoNotTerminateIsolate = 1 << 0 ,
285+ };
286+ } // namespace StopFlags
287+
279288class NODE_EXTERN InitializationResult {
280289 public:
281290 virtual ~InitializationResult ();
@@ -312,6 +321,7 @@ NODE_EXTERN int Start(int argc, char* argv[]);
312321// Tear down Node.js while it is running (there are active handles
313322// in the loop and / or actively executing JavaScript code).
314323NODE_EXTERN int Stop (Environment* env);
324+ NODE_EXTERN int Stop (Environment* env, StopFlags::Flags flags);
315325
316326// Set up per-process state needed to run Node.js. This will consume arguments
317327// from argv, fill exec_argv, and possibly add errors resulting from parsing
You can’t perform that action at this time.
0 commit comments