mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
src: remove async_hooks destroy timer handle
Backport-PR-URL: https://github.com/nodejs/node/pull/18179 PR-URL: https://github.com/nodejs/node/pull/17117 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
bd47272bc9
commit
e67448813f
6 files changed
+14
-34
No files matched your search
+2
-7
@@ -138,11 +138,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Local<Value> wrapper) {
|
||||
// end RetainedAsyncInfo
|
||||
|
||||
|
||||
static void DestroyAsyncIdsCallback(uv_timer_t* handle) {
|
||||
Environment* env = Environment::from_destroy_async_ids_timer_handle(handle);
|
||||
|
||||
HandleScope handle_scope(env->isolate());
|
||||
Context::Scope context_scope(env->context());
|
||||
static void DestroyAsyncIdsCallback(Environment* env, void* data) {
|
||||
Local<Function> fn = env->async_hooks_destroy_function();
|
||||
|
||||
TryCatch try_catch(env->isolate());
|
||||
@@ -690,8 +686,7 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) {
|
||||
return;
|
||||
|
||||
if (env->destroy_async_id_list()->empty()) {
|
||||
uv_timer_start(env->destroy_async_ids_timer_handle(),
|
||||
DestroyAsyncIdsCallback, 0, 0);
|
||||
env->SetImmediate(DestroyAsyncIdsCallback, nullptr);
|
||||
}
|
||||
|
||||
env->destroy_async_id_list()->push_back(async_id);
|
||||
|
||||
@@ -388,15 +388,6 @@ inline uv_idle_t* Environment::immediate_idle_handle() {
|
||||
return &immediate_idle_handle_;
|
||||
}
|
||||
|
||||
inline Environment* Environment::from_destroy_async_ids_timer_handle(
|
||||
uv_timer_t* handle) {
|
||||
return ContainerOf(&Environment::destroy_async_ids_timer_handle_, handle);
|
||||
}
|
||||
|
||||
inline uv_timer_t* Environment::destroy_async_ids_timer_handle() {
|
||||
return &destroy_async_ids_timer_handle_;
|
||||
}
|
||||
|
||||
inline void Environment::RegisterHandleCleanup(uv_handle_t* handle,
|
||||
HandleCleanupCb cb,
|
||||
void *arg) {
|
||||
|
||||
@@ -42,8 +42,6 @@ void Environment::Start(int argc,
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&idle_prepare_handle_));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&idle_check_handle_));
|
||||
|
||||
uv_timer_init(event_loop(), destroy_async_ids_timer_handle());
|
||||
|
||||
auto close_and_finish = [](Environment* env, uv_handle_t* handle, void* arg) {
|
||||
handle->data = env;
|
||||
|
||||
@@ -68,10 +66,6 @@ void Environment::Start(int argc,
|
||||
reinterpret_cast<uv_handle_t*>(&idle_check_handle_),
|
||||
close_and_finish,
|
||||
nullptr);
|
||||
RegisterHandleCleanup(
|
||||
reinterpret_cast<uv_handle_t*>(&destroy_async_ids_timer_handle_),
|
||||
close_and_finish,
|
||||
nullptr);
|
||||
|
||||
if (start_profiler_idle_notifier) {
|
||||
StartProfilerIdleNotifier();
|
||||
|
||||
@@ -561,11 +561,8 @@ class Environment {
|
||||
inline uint32_t watched_providers() const;
|
||||
|
||||
static inline Environment* from_immediate_check_handle(uv_check_t* handle);
|
||||
static inline Environment* from_destroy_async_ids_timer_handle(
|
||||
uv_timer_t* handle);
|
||||
inline uv_check_t* immediate_check_handle();
|
||||
inline uv_idle_t* immediate_idle_handle();
|
||||
inline uv_timer_t* destroy_async_ids_timer_handle();
|
||||
|
||||
// Register clean-up cb to be called on environment destruction.
|
||||
inline void RegisterHandleCleanup(uv_handle_t* handle,
|
||||
@@ -706,7 +703,6 @@ class Environment {
|
||||
IsolateData* const isolate_data_;
|
||||
uv_check_t immediate_check_handle_;
|
||||
uv_idle_t immediate_idle_handle_;
|
||||
uv_timer_t destroy_async_ids_timer_handle_;
|
||||
uv_prepare_t idle_prepare_handle_;
|
||||
uv_check_t idle_check_handle_;
|
||||
|
||||
|
||||
@@ -66,12 +66,14 @@ function onsigusr2() {
|
||||
}
|
||||
|
||||
function onsigusr2Again() {
|
||||
checkInvocations(
|
||||
signal1, { init: 1, before: 2, after: 2, destroy: 1 },
|
||||
'signal1: when second SIGUSR2 handler is called');
|
||||
checkInvocations(
|
||||
signal2, { init: 1, before: 1 },
|
||||
'signal2: when second SIGUSR2 handler is called');
|
||||
setImmediate(() => {
|
||||
checkInvocations(
|
||||
signal1, { init: 1, before: 2, after: 2, destroy: 1 },
|
||||
'signal1: when second SIGUSR2 handler is called');
|
||||
checkInvocations(
|
||||
signal2, { init: 1, before: 1 },
|
||||
'signal2: when second SIGUSR2 handler is called');
|
||||
});
|
||||
}
|
||||
|
||||
process.on('exit', onexit);
|
||||
|
||||
@@ -128,8 +128,10 @@ function onconnection(c) {
|
||||
function onserverClosed() {
|
||||
checkInvocations(tcp1, { init: 1, before: 1, after: 1, destroy: 1 },
|
||||
'tcp1 when server is closed');
|
||||
checkInvocations(tcp2, { init: 1, before: 2, after: 2, destroy: 1 },
|
||||
'tcp2 when server is closed');
|
||||
setImmediate(() => {
|
||||
checkInvocations(tcp2, { init: 1, before: 2, after: 2, destroy: 1 },
|
||||
'tcp2 after server is closed');
|
||||
});
|
||||
checkInvocations(tcp3, { init: 1, before: 1, after: 1 },
|
||||
'tcp3 synchronously when server is closed');
|
||||
tick(2, () => {
|
||||
|
||||
Reference in new issue
Block a user