From d35af56e5f3b1334c4360dbf8a013d0c522fe5f8 Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Tue, 12 Jun 2018 09:01:46 -0400 Subject: src: shutdown node in-flight This commit introduces a `node::Stop()` API. An identified use case for embedders is their ability to tear down Node while it is still running (event loop contain pending events) Here the assumptions are that (i) embedders do not wish to resort to JS routines to initiate shutdown (ii) embedders have the Environment handle handy. (iii) embedders stop Node through a second thread. Fixes: https://github.com/nodejs/node/issues/19365 Refs: https://github.com/nodejs/user-feedback/issues/51 PR-URL: https://github.com/nodejs/node/pull/21283 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Michael Dawson --- src/api/callback.cc | 2 +- src/api/environment.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/api') diff --git a/src/api/callback.cc b/src/api/callback.cc index 6c6aec4573..b90f5ca92d 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -82,7 +82,7 @@ void InternalCallbackScope::Close() { HandleScope handle_scope(env_->isolate()); if (!env_->can_call_into_js()) return; - if (failed_ && !env_->is_main_thread() && env_->is_stopping_worker()) { + if (failed_ && !env_->is_main_thread() && env_->is_stopping()) { env_->async_hooks()->clear_async_id_stack(); } diff --git a/src/api/environment.cc b/src/api/environment.cc index 6e3c61fac1..1597a6cec5 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -40,7 +40,7 @@ static bool ShouldAbortOnUncaughtException(Isolate* isolate) { DebugSealHandleScope scope(isolate); Environment* env = Environment::GetCurrent(isolate); return env != nullptr && - (env->is_main_thread() || !env->is_stopping_worker()) && + (env->is_main_thread() || !env->is_stopping()) && env->should_abort_on_uncaught_toggle()[0] && !env->inside_should_not_abort_on_uncaught_scope(); } -- cgit v1.2.3