From 102a3740ea8be95c784de362da81bd70b9ba0c59 Mon Sep 17 00:00:00 2001 From: Robo Date: Wed, 10 Mar 2021 11:44:16 -0800 Subject: [PATCH] chore: cherry-pick 1fe571a from node (#28067) Backports https://github.com/nodejs/node/pull/37000 --- patches/node/.patches | 1 + ...ne_asynccleanuphookhandle_in_headers.patch | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 patches/node/src_inline_asynccleanuphookhandle_in_headers.patch diff --git a/patches/node/.patches b/patches/node/.patches index b7fc6a6e7b..2a5106fe3a 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -31,3 +31,4 @@ remove_makeexternal_case_for_uncached_internal_strings.patch fix_remove_outdated_--experimental-wasm-bigint_flag.patch fix_crypto_tests_to_run_with_bssl.patch build_add_mjs_support_to_js2c.patch +src_inline_asynccleanuphookhandle_in_headers.patch diff --git a/patches/node/src_inline_asynccleanuphookhandle_in_headers.patch b/patches/node/src_inline_asynccleanuphookhandle_in_headers.patch new file mode 100644 index 0000000000..9ecdeed761 --- /dev/null +++ b/patches/node/src_inline_asynccleanuphookhandle_in_headers.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Ang-Wanek +Date: Tue, 19 Jan 2021 07:39:14 -0700 +Subject: src: inline AsyncCleanupHookHandle in headers + +Fixes: https://github.com/nodejs/node/issues/36349 + +PR-URL: https://github.com/nodejs/node/pull/37000 +Reviewed-By: Anna Henningsen +Reviewed-By: Rich Trott +Reviewed-By: James M Snell + +diff --git a/src/api/hooks.cc b/src/api/hooks.cc +index a719a861dbe9d8d9ca67c3bb5920b14b0df16d83..8f191aad7e2dcfbedddeaeb88f47ed721ef51cf1 100644 +--- a/src/api/hooks.cc ++++ b/src/api/hooks.cc +@@ -133,7 +133,7 @@ static void RunAsyncCleanupHook(void* arg) { + info->fun(info->arg, FinishAsyncCleanupHook, info); + } + +-AsyncCleanupHookHandle AddEnvironmentCleanupHook( ++ACHHandle* AddEnvironmentCleanupHookInternal( + Isolate* isolate, + AsyncCleanupHook fun, + void* arg) { +@@ -145,11 +145,11 @@ AsyncCleanupHookHandle AddEnvironmentCleanupHook( + info->arg = arg; + info->self = info; + env->AddCleanupHook(RunAsyncCleanupHook, info.get()); +- return AsyncCleanupHookHandle(new ACHHandle { info }); ++ return new ACHHandle { info }; + } + +-void RemoveEnvironmentCleanupHook( +- AsyncCleanupHookHandle handle) { ++void RemoveEnvironmentCleanupHookInternal( ++ ACHHandle* handle) { + if (handle->info->started) return; + handle->info->self.reset(); + handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get()); +diff --git a/src/node.h b/src/node.h +index f150725b54ee1315476d202797963369490d5152..7ab2ed9345c83cb4c1f51c0cc3050abc6571e3fa 100644 +--- a/src/node.h ++++ b/src/node.h +@@ -905,12 +905,26 @@ struct ACHHandle; + struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; }; + typedef std::unique_ptr AsyncCleanupHookHandle; + +-NODE_EXTERN AsyncCleanupHookHandle AddEnvironmentCleanupHook( ++/* This function is not intended to be used externally, it exists to aid in ++ * keeping ABI compatibility between Node and Electron. */ ++NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookInternal( + v8::Isolate* isolate, + void (*fun)(void* arg, void (*cb)(void*), void* cbarg), + void* arg); ++inline AsyncCleanupHookHandle AddEnvironmentCleanupHook( ++ v8::Isolate* isolate, ++ void (*fun)(void* arg, void (*cb)(void*), void* cbarg), ++ void* arg) { ++ return AsyncCleanupHookHandle(AddEnvironmentCleanupHookInternal(isolate, fun, ++ arg)); ++} + +-NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder); ++/* This function is not intended to be used externally, it exists to aid in ++ * keeping ABI compatibility between Node and Electron. */ ++NODE_EXTERN void RemoveEnvironmentCleanupHookInternal(ACHHandle* holder); ++inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) { ++ RemoveEnvironmentCleanupHookInternal(holder.get()); ++} + + /* Returns the id of the current execution context. If the return value is + * zero then no execution has been set. This will happen if the user handles