diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2017-11-22 15:41:18 +0100 |
---|---|---|
committer | Andreas Madsen <amwebdk@gmail.com> | 2017-12-19 18:04:48 +0100 |
commit | 0784b0440c05464f79b857f7d8698fcc953d3fb3 (patch) | |
tree | f201fec7e9547e2a3e22d983ae27608d427b757d /src | |
parent | f3f1a9349afaee9a05dce8df0836dd4355836391 (diff) | |
download | android-node-v8-0784b0440c05464f79b857f7d8698fcc953d3fb3.tar.gz android-node-v8-0784b0440c05464f79b857f7d8698fcc953d3fb3.tar.bz2 android-node-v8-0784b0440c05464f79b857f7d8698fcc953d3fb3.zip |
async_hooks: separate missing from default context
When context is missing the executionAsyncId will be zero. For the
default triggerAsyncId the zero value was used to default to the
executionAsyncId. While this was not technically wrong because the
functions are different themself, it poorly separated the two concepts.
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')
-rw-r--r-- | src/env-inl.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/env-inl.h b/src/env-inl.h index a692e8e08e..2d4c0c18e9 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -66,6 +66,12 @@ inline Environment::AsyncHooks::AsyncHooks(v8::Isolate* isolate) // and flag changes won't be included. fields_[kCheck] = 1; + // kDefaultTriggerAsyncId should be -1, this indicates that there is no + // specified default value and it should fallback to the executionAsyncId. + // 0 is not used as the magic value, because that indicates a missing context + // which is different from a default context. + async_id_fields_[AsyncHooks::kDefaultTriggerAsyncId] = -1; + // kAsyncIdCounter should start at 1 because that'll be the id the execution // context during bootstrap (code that runs before entering uv_run()). async_id_fields_[AsyncHooks::kAsyncIdCounter] = 1; @@ -450,9 +456,9 @@ inline double Environment::trigger_async_id() { inline double Environment::get_default_trigger_async_id() { double default_trigger_async_id = async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId]; - async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] = 0; + async_hooks()->async_id_fields()[AsyncHooks::kDefaultTriggerAsyncId] = -1; // If defaultTriggerAsyncId isn't set, use the executionAsyncId - if (default_trigger_async_id <= 0) + if (default_trigger_async_id < 0) default_trigger_async_id = execution_async_id(); return default_trigger_async_id; } |