Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-02-10 13:39:45 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-02-21 05:47:28 +0300
commitc435f069ebb3b8a1c6fb0d983db7f1b799715627 (patch)
treeb133acb7f191d15e9ef46531220b389938ea2a8c /src/node_trace_events.cc
parent435eea6400522189c9e521bde32134b03791a576 (diff)
process: simplify the setup of async hooks trace events
- Remove `trace_category_state` from `Environment` - since this is only accessed in the bootstrap process and later in the trace category update handler, we could just pass the initial values into JS land via the trace_events binding, and pass the dynamic values directly to the handler later, instead of accessing them out-of-band via the AliasedBuffer. - Instead of creating the hooks directly in `trace_events_async_hooks.js`, export the hook factory and create the hooks in trace category state toggle. PR-URL: https://github.com/nodejs/node/pull/26062 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_trace_events.cc')
-rw-r--r--src/node_trace_events.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc
index 6a0d4f037a7..5e30df41c4f 100644
--- a/src/node_trace_events.cc
+++ b/src/node_trace_events.cc
@@ -1,6 +1,7 @@
#include "base_object-inl.h"
#include "env.h"
#include "node.h"
+#include "node_internals.h"
#include "node_v8_platform-inl.h"
#include "tracing/agent.h"
@@ -10,6 +11,7 @@
namespace node {
using v8::Array;
+using v8::Boolean;
using v8::Context;
using v8::Function;
using v8::FunctionCallbackInfo;
@@ -148,9 +150,14 @@ void NodeCategorySet::Initialize(Local<Object> target,
target->Set(context, trace,
binding->Get(context, trace).ToLocalChecked()).FromJust();
- target->Set(context,
- FIXED_ONE_BYTE_STRING(env->isolate(), "traceCategoryState"),
- env->trace_category_state().GetJSArray()).FromJust();
+ // Initial value of async hook trace events
+ bool async_hooks_enabled = (*(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
+ TRACING_CATEGORY_NODE1(async_hooks)))) != 0;
+ target
+ ->Set(context,
+ FIXED_ONE_BYTE_STRING(env->isolate(), "asyncHooksEnabledInitial"),
+ Boolean::New(env->isolate(), async_hooks_enabled))
+ .FromJust();
}
} // namespace node