From 3b8da4cbe8a7f36fcd8892c6676a55246ba8c3be Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 22 Nov 2017 18:41:00 +0100 Subject: 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 Reviewed-By: James M Snell --- src/stream_base-inl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/stream_base-inl.h') diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index cc89a11bac..cdcff67cc5 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -143,7 +143,8 @@ void StreamBase::JSMethod(const FunctionCallbackInfo& args) { if (!wrap->IsAlive()) return args.GetReturnValue().Set(UV_EINVAL); - AsyncHooks::InitScope init_scope(handle->env(), handle->get_async_id()); + AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope( + handle->env(), handle->get_async_id()); args.GetReturnValue().Set((wrap->*Method)(args)); } -- cgit v1.2.3