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:
authorAndreas Madsen <amwebdk@gmail.com>2017-11-22 20:41:00 +0300
committerAndreas Madsen <amwebdk@gmail.com>2017-12-19 20:04:52 +0300
commit3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be (patch)
tree1afc84002d1716f4acd28126df214127e0262c3c /src/udp_wrap.cc
parent0784b0440c05464f79b857f7d8698fcc953d3fb3 (diff)
async_hooks: use scope for defaultTriggerAsyncId
Previously the getter would mutate the kDefaultTriggerAsncId value. This refactor changes the setter to bind the current kDefaultTriggerAsncId to a scope, such that the getter doesn't have to mutate its own value. PR-URL: https://github.com/nodejs/node/pull/17273 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r--src/udp_wrap.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index 55e12e4278b..27be93abd0e 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -357,8 +357,12 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
node::Utf8Value address(env->isolate(), args[4]);
const bool have_callback = args[5]->IsTrue();
- env->set_default_trigger_async_id(wrap->get_async_id());
- SendWrap* req_wrap = new SendWrap(env, req_wrap_obj, have_callback);
+ SendWrap* req_wrap;
+ {
+ AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(
+ env, wrap->get_async_id());
+ req_wrap = new SendWrap(env, req_wrap_obj, have_callback);
+ }
size_t msg_size = 0;
MaybeStackBuffer<uv_buf_t, 16> bufs(count);
@@ -507,7 +511,9 @@ Local<Object> UDPWrap::Instantiate(Environment* env,
AsyncWrap* parent,
UDPWrap::SocketType type) {
EscapableHandleScope scope(env->isolate());
- AsyncHooks::InitScope init_scope(env, parent->get_async_id());
+ AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(
+ env, parent->get_async_id());
+
// If this assert fires then Initialize hasn't been called yet.
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
Local<Object> instance = env->udp_constructor_function()