diff options
author | Shelley Vohr <shelley.vohr@gmail.com> | 2019-09-20 08:16:04 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-09-25 08:49:33 +0300 |
commit | 3c17f160e39d96d6e29b3e379bdf20169bacd75f (patch) | |
tree | 657dbcb10e25af817f6518a4a96927f05e8fec5c /src/node_binding.cc | |
parent | 5058c7f13838801cdc1155227f9aa7267507b49a (diff) |
src: add buildflag to force context-aware addons
PR-URL: https://github.com/nodejs/node/pull/29631
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_binding.cc')
-rw-r--r-- | src/node_binding.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node_binding.cc b/src/node_binding.cc index a2790d42aa9..2deefefb65f 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -1,4 +1,5 @@ #include "node_binding.h" +#include "node_errors.h" #include <atomic> #include "env-inl.h" #include "node_native_module_env.h" @@ -462,6 +463,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) { } if (mp != nullptr) { + if (mp->nm_context_register_func == nullptr) { + if (env->options()->force_context_aware) { + dlib->Close(); + THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env); + return false; + } + } mp->nm_dso_handle = dlib->handle_; dlib->SaveInGlobalHandleMap(mp); } else { |