File tree Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Expand file tree Collapse file tree 5 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -725,8 +725,7 @@ ThreadId AllocateEnvironmentThreadId() {
725725}
726726
727727void DefaultProcessExitHandler (Environment* env, int exit_code) {
728- env->set_can_call_into_js (false );
729- env->stop_sub_worker_contexts ();
728+ Stop (env);
730729 DisposePlatform ();
731730 exit (exit_code);
732731}
Original file line number Diff line number Diff line change @@ -501,9 +501,10 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
501501 }
502502}
503503
504- void Environment::ExitEnv () {
504+ void Environment::Stop () {
505505 set_can_call_into_js (false );
506506 set_stopping (true );
507+ stop_sub_worker_contexts ();
507508 isolate_->TerminateExecution ();
508509 SetImmediateThreadsafe ([](Environment* env) { uv_stop (env->event_loop ()); });
509510}
Original file line number Diff line number Diff line change @@ -897,7 +897,7 @@ class Environment : public MemoryRetainer {
897897 void RegisterHandleCleanups ();
898898 void CleanupHandles ();
899899 void Exit (int code);
900- void ExitEnv ();
900+ void Stop ();
901901
902902 // Register clean-up cb to be called on environment destruction.
903903 inline void RegisterHandleCleanup (uv_handle_t * handle,
Original file line number Diff line number Diff line change @@ -1059,7 +1059,7 @@ int Start(int argc, char** argv) {
10591059}
10601060
10611061int Stop (Environment* env) {
1062- env->ExitEnv ();
1062+ env->Stop ();
10631063 return 0 ;
10641064}
10651065
Original file line number Diff line number Diff line change @@ -224,7 +224,8 @@ class Environment;
224224NODE_EXTERN int Start (int argc, char * argv[]);
225225
226226// Tear down Node.js while it is running (there are active handles
227- // in the loop and / or actively executing JavaScript code).
227+ // in the loop and / or actively executing JavaScript code). This also stops
228+ // all Workers that may have been started earlier.
228229NODE_EXTERN int Stop (Environment* env);
229230
230231// TODO(addaleax): Officially deprecate this and replace it with something
@@ -478,8 +479,8 @@ NODE_EXTERN void FreeEnvironment(Environment* env);
478479// It receives the Environment* instance and the exit code as arguments.
479480// This could e.g. call Stop(env); in order to terminate execution and stop
480481// the event loop.
481- // The default handler disposes of the global V8 platform instance, if one is
482- // being used, and calls exit().
482+ // The default handler calls Stop(), disposes of the global V8 platform
483+ // instance, if one is being used, and calls exit().
483484NODE_EXTERN void SetProcessExitHandler (
484485 Environment* env,
485486 std::function<void (Environment*, int )>&& handler);
You can’t perform that action at this time.
0 commit comments