summaryrefslogtreecommitdiff
path: root/src/async_wrap.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-12 15:01:50 +0200
committerAnna Henningsen <anna@addaleax.net>2018-09-17 17:20:27 +0200
commit4286dcf17f062034117043a2640b620210b61f57 (patch)
treede227e8bb7bee72778a2e7bd98f08991839bf866 /src/async_wrap.cc
parentc33e27dc3caf5a5b7954706fe6ecde1e4f82534d (diff)
downloadandroid-node-v8-4286dcf17f062034117043a2640b620210b61f57.tar.gz
android-node-v8-4286dcf17f062034117043a2640b620210b61f57.tar.bz2
android-node-v8-4286dcf17f062034117043a2640b620210b61f57.zip
src: refactor `Environment::GetCurrent()` usage
Make `Environment::GetCurrent()` return `nullptr` if the current `Context` is not a Node.js context, and for the relevant usage of this function, either: - Switch to the better `GetCurrent(args)` variant - Turn functions in to no-ops where it makes sense - Make it a `CHECK`, i.e. an API requirement, where it make sense - Leave a `TODO` comment for verifying what, if anything, is to be done PR-URL: https://github.com/nodejs/node/pull/22819 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/async_wrap.cc')
-rw-r--r--src/async_wrap.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/async_wrap.cc b/src/async_wrap.cc
index acc61ea4b4..f697679399 100644
--- a/src/async_wrap.cc
+++ b/src/async_wrap.cc
@@ -687,12 +687,16 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
- return Environment::GetCurrent(isolate)->execution_async_id();
+ Environment* env = Environment::GetCurrent(isolate);
+ if (env == nullptr) return -1;
+ return env->execution_async_id();
}
async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) {
- return Environment::GetCurrent(isolate)->trigger_async_id();
+ Environment* env = Environment::GetCurrent(isolate);
+ if (env == nullptr) return -1;
+ return env->trigger_async_id();
}
@@ -711,6 +715,7 @@ async_context EmitAsyncInit(Isolate* isolate,
v8::Local<v8::String> name,
async_id trigger_async_id) {
Environment* env = Environment::GetCurrent(isolate);
+ CHECK_NOT_NULL(env);
// Initialize async context struct
if (trigger_async_id == -1)