embedding: make Stop() stop Workers · nodejs/node@7a8f59f · GitHub
Skip to content

Commit 7a8f59f

Browse files
committed
embedding: make Stop() stop Workers
This makes sense given that terminating execution of the parent thread this way likely also is supposed to stop all running Worker threads spawned by it. Backport-PR-URL: #35241 PR-URL: #32531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ff0a036 commit 7a8f59f

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/api/environment.cc

Lines changed: 1 addition & 2 deletions

src/env.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
523523
}
524524
}
525525

526-
void Environment::ExitEnv() {
526+
void Environment::Stop() {
527527
set_can_call_into_js(false);
528528
set_stopping(true);
529+
stop_sub_worker_contexts();
529530
isolate_->TerminateExecution();
530531
SetImmediateThreadsafe([](Environment* env) { uv_stop(env->event_loop()); });
531532
}

src/env.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ class Environment : public MemoryRetainer {
913913
void RegisterHandleCleanups();
914914
void CleanupHandles();
915915
void Exit(int code);
916-
void ExitEnv();
916+
void Stop();
917917

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

src/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ int Start(int argc, char** argv) {
10351035
}
10361036

10371037
int Stop(Environment* env) {
1038-
env->ExitEnv();
1038+
env->Stop();
10391039
return 0;
10401040
}
10411041

src/node.h

Lines changed: 4 additions & 3 deletions

0 commit comments

Comments
 (0)