From 13abc6adfb9f6a53618ca7d533d31b6a5d26dcec Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Wed, 5 Dec 2018 17:24:49 -0800 Subject: 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 Reviewed-By: Joyee Cheung --- src/env.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/env.cc') 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& args, -- cgit v1.2.3