summaryrefslogtreecommitdiff
path: root/src/async-wrap-inl.h
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2015-05-04 15:56:40 -0600
committerTrevor Norris <trev.norris@gmail.com>2015-05-04 20:07:01 -0600
commit84bf609fd2dce0343157d2bf8afa323744fd3107 (patch)
treead6261f08de1d7a46310431713b9d528e9d17020 /src/async-wrap-inl.h
parent2ed10f13492221da0e5d1795bb0c780308c08d48 (diff)
downloadandroid-node-v8-84bf609fd2dce0343157d2bf8afa323744fd3107.tar.gz
android-node-v8-84bf609fd2dce0343157d2bf8afa323744fd3107.tar.bz2
android-node-v8-84bf609fd2dce0343157d2bf8afa323744fd3107.zip
async-wrap: don't call init callback unnecessarily
Some calls to ReqWrap would get through the initial check and allow the init callback to run, even though the callback had not been used on the parent. Fix by explicitly checking if the parent has a queue. Also change the name of the check, and internal field of AsyncHooks. Other names were confusing. PR-URL: https://github.com/iojs/io.js/pull/1614 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/async-wrap-inl.h')
-rw-r--r--src/async-wrap-inl.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h
index b08f791c2e..ba84af19c0 100644
--- a/src/async-wrap-inl.h
+++ b/src/async-wrap-inl.h
@@ -21,7 +21,13 @@ inline AsyncWrap::AsyncWrap(Environment* env,
// Check user controlled flag to see if the init callback should run.
if (!env->using_asyncwrap())
return;
- if (!env->call_async_init_hook() && parent == nullptr)
+
+ // If callback hooks have not been enabled, and there is no parent, return.
+ if (!env->async_wrap_callbacks_enabled() && parent == nullptr)
+ return;
+
+ // If callback hooks have not been enabled and parent has no queue, return.
+ if (!env->async_wrap_callbacks_enabled() && !parent->has_async_queue())
return;
// TODO(trevnorris): Until it's verified all passed object's are not weak,