summaryrefslogtreecommitdiff
path: root/src/env.cc
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2018-12-05 17:24:49 -0800
committerGabriel Schulhof <gabriel.schulhof@intel.com>2018-12-19 18:35:38 -0800
commit13abc6adfb9f6a53618ca7d533d31b6a5d26dcec (patch)
treec926fad94aa23bf3bec5af81b975efa0771338da /src/env.cc
parent622e348d8f70a4ec006ee1ce9207a6a5bc3fc325 (diff)
downloadandroid-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.tar.gz
android-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.tar.bz2
android-node-v8-13abc6adfb9f6a53618ca7d533d31b6a5d26dcec.zip
src: unload addons when environment quits
This is an alternative to https://github.com/nodejs/node/pull/23319 which attaches the loaded addons to the environment and closes them when the environment is destroyed. PR-URL: https://github.com/nodejs/node/pull/24861 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r--src/env.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/env.cc b/src/env.cc
index 4b05a8b4a9..afdebc304f 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -276,6 +276,11 @@ Environment::~Environment() {
TRACE_EVENT_NESTABLE_ASYNC_END0(
TRACING_CATEGORY_NODE1(environment), "Environment", this);
+
+ // Dereference all addons that were loaded into this environment.
+ for (binding::DLib& addon : loaded_addons_) {
+ addon.Close();
+ }
}
void Environment::Start(const std::vector<std::string>& args,