diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-13 19:02:57 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-18 21:56:49 +0300 |
commit | eef6504cf7b95ada170ec9878089ce57fde551d8 (patch) | |
tree | 43a35f63b1330bf1878872295383d47e899e507f /src/async_wrap.cc | |
parent | 321e296371383fd63131d21c1121e22163ddeb86 (diff) |
src: schedule destroy hooks in BeforeExit early during bootstrap
Instead of doing it in the `internalBinding('async_wrap')`
initialization whose first call is uncertain depending on how
the native modules are loaded in JS land during bootstrap.
PR-URL: https://github.com/nodejs/node/pull/25020
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/async_wrap.cc')
-rw-r--r-- | src/async_wrap.cc | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/src/async_wrap.cc b/src/async_wrap.cc index e197319100a..47a99551275 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -88,8 +88,7 @@ struct AsyncWrapObject : public AsyncWrap { SET_SELF_SIZE(AsyncWrapObject) }; - -static void DestroyAsyncIdsCallback(Environment* env, void* data) { +void AsyncWrap::DestroyAsyncIdsCallback(Environment* env, void* data) { Local<Function> fn = env->async_hooks_destroy_function(); TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal); @@ -112,13 +111,6 @@ static void DestroyAsyncIdsCallback(Environment* env, void* data) { } while (!env->destroy_async_id_list()->empty()); } -static void DestroyAsyncIdsCallback(void* arg) { - Environment* env = static_cast<Environment*>(arg); - if (!env->destroy_async_id_list()->empty()) - DestroyAsyncIdsCallback(env, nullptr); -} - - void Emit(Environment* env, double async_id, AsyncHooks::Fields type, Local<Function> fn) { AsyncHooks* async_hooks = env->async_hooks(); @@ -446,8 +438,6 @@ void AsyncWrap::Initialize(Local<Object> target, Isolate* isolate = env->isolate(); HandleScope scope(isolate); - env->BeforeExit(DestroyAsyncIdsCallback, env); - env->SetMethod(target, "setupHooks", SetupHooks); env->SetMethod(target, "pushAsyncIds", PushAsyncIds); env->SetMethod(target, "popAsyncIds", PopAsyncIds); |