Skip to content

Commit 15f29aa

Browse files
trop[bot]deepak1556zcbenz
authored
chore: cherry-pick 1fe571a from node (#28109)
* chore: cherry-pick 1fe571a from node Backports nodejs/node#37000 * Fix merge error Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
1 parent 312682d commit 15f29aa

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ fix_add_safeforterminationscopes_for_sigint_interruptions.patch
3131
remove_makeexternal_case_for_uncached_internal_strings.patch
3232
fix_remove_outdated_--experimental-wasm-bigint_flag.patch
3333
fix_parallel_test-crypto-ecdh-convert-key_to_use_compatible_group.patch
34+
src_inline_asynccleanuphookhandle_in_headers.patch
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Tyler Ang-Wanek <tylerw@axosoft.com>
3+
Date: Tue, 19 Jan 2021 07:39:14 -0700
4+
Subject: src: inline AsyncCleanupHookHandle in headers
5+
6+
Fixes: https://github.com/nodejs/node/issues/36349
7+
8+
PR-URL: https://github.com/nodejs/node/pull/37000
9+
Reviewed-By: Anna Henningsen <anna@addaleax.net>
10+
Reviewed-By: Rich Trott <rtrott@gmail.com>
11+
Reviewed-By: James M Snell <jasnell@gmail.com>
12+
13+
diff --git a/src/api/hooks.cc b/src/api/hooks.cc
14+
index a719a861dbe9d8d9ca67c3bb5920b14b0df16d83..8f191aad7e2dcfbedddeaeb88f47ed721ef51cf1 100644
15+
--- a/src/api/hooks.cc
16+
+++ b/src/api/hooks.cc
17+
@@ -133,7 +133,7 @@ static void RunAsyncCleanupHook(void* arg) {
18+
info->fun(info->arg, FinishAsyncCleanupHook, info);
19+
}
20+
21+
-AsyncCleanupHookHandle AddEnvironmentCleanupHook(
22+
+ACHHandle* AddEnvironmentCleanupHookInternal(
23+
Isolate* isolate,
24+
AsyncCleanupHook fun,
25+
void* arg) {
26+
@@ -145,11 +145,11 @@ AsyncCleanupHookHandle AddEnvironmentCleanupHook(
27+
info->arg = arg;
28+
info->self = info;
29+
env->AddCleanupHook(RunAsyncCleanupHook, info.get());
30+
- return AsyncCleanupHookHandle(new ACHHandle { info });
31+
+ return new ACHHandle { info };
32+
}
33+
34+
-void RemoveEnvironmentCleanupHook(
35+
- AsyncCleanupHookHandle handle) {
36+
+void RemoveEnvironmentCleanupHookInternal(
37+
+ ACHHandle* handle) {
38+
if (handle->info->started) return;
39+
handle->info->self.reset();
40+
handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get());
41+
diff --git a/src/node.h b/src/node.h
42+
index f150725b54ee1315476d202797963369490d5152..7ab2ed9345c83cb4c1f51c0cc3050abc6571e3fa 100644
43+
--- a/src/node.h
44+
+++ b/src/node.h
45+
@@ -905,12 +905,26 @@ struct ACHHandle;
46+
struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; };
47+
typedef std::unique_ptr<ACHHandle, DeleteACHHandle> AsyncCleanupHookHandle;
48+
49+
-NODE_EXTERN AsyncCleanupHookHandle AddEnvironmentCleanupHook(
50+
+/* This function is not intended to be used externally, it exists to aid in
51+
+ * keeping ABI compatibility between Node and Electron. */
52+
+NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookInternal(
53+
v8::Isolate* isolate,
54+
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
55+
void* arg);
56+
+inline AsyncCleanupHookHandle AddEnvironmentCleanupHook(
57+
+ v8::Isolate* isolate,
58+
+ void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
59+
+ void* arg) {
60+
+ return AsyncCleanupHookHandle(AddEnvironmentCleanupHookInternal(isolate, fun,
61+
+ arg));
62+
+}
63+
64+
-NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder);
65+
+/* This function is not intended to be used externally, it exists to aid in
66+
+ * keeping ABI compatibility between Node and Electron. */
67+
+NODE_EXTERN void RemoveEnvironmentCleanupHookInternal(ACHHandle* holder);
68+
+inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
69+
+ RemoveEnvironmentCleanupHookInternal(holder.get());
70+
+}
71+
72+
/* Returns the id of the current execution context. If the return value is
73+
* zero then no execution has been set. This will happen if the user handles

0 commit comments

Comments
 (0)