diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-01-05 15:33:21 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-02-12 14:03:24 -0700 |
commit | e9192249c8c6b05c7cc04e8b51a7e37235f31415 (patch) | |
tree | 8859fa3eb0090035dae60d813b9f315b456413bb /src/async-wrap.cc | |
parent | 575b84ec41b94d4a565b981c146d88ce0637fff2 (diff) | |
download | node-new-e9192249c8c6b05c7cc04e8b51a7e37235f31415.tar.gz |
src: add AsyncCallbackScope
Add a scope that will allow MakeCallback to know whether or not it's
currently running. This will prevent nextTickQueue and the
MicrotaskQueue from being processed recursively. It is also required to
wrap the bootloading stage since it doesn't run within a MakeCallback.
Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245
PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/async-wrap.cc')
-rw-r--r-- | src/async-wrap.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 29ea139f5f..01dcaf277c 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -184,6 +184,8 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb, Local<Object> domain; bool has_domain = false; + Environment::AsyncCallbackScope callback_scope(env()); + if (env()->using_domains()) { Local<Value> domain_v = context->Get(env()->domain_string()); has_domain = domain_v->IsObject(); @@ -236,7 +238,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb, Environment::TickInfo* tick_info = env()->tick_info(); - if (tick_info->in_tick()) { + if (callback_scope.in_makecallback()) { return ret; } @@ -249,12 +251,8 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb, return ret; } - tick_info->set_in_tick(true); - env()->tick_callback_function()->Call(process, 0, nullptr); - tick_info->set_in_tick(false); - if (try_catch.HasCaught()) { tick_info->set_last_threw(true); return Undefined(env()->isolate()); |