diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-09-09 22:29:08 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-10 14:15:17 +0200 |
commit | 61fd027096c0416a6e9bbe3ee7b7edb4c180725a (patch) | |
tree | e64998f427bfaa959448f7e28223b9d10f01e5eb /src/env.cc | |
parent | 1db0039c505c6081f1d0d84cc24133ed6659e539 (diff) | |
download | node-new-61fd027096c0416a6e9bbe3ee7b7edb4c180725a.tar.gz |
src: use cleanup hooks to tear down BaseObjects
Clean up after `BaseObject` instances when the `Environment`
is being shut down. This takes care of closing non-libuv resources
like `zlib` instances, which do not require asynchronous shutdown.
Many thanks for Stephen Belanger, Timothy Gu and Alexey Orlenko for
reviewing the original version of this commit in the Ayo.js project.
Refs: https://github.com/ayojs/ayo/pull/88
PR-URL: https://github.com/nodejs/node/pull/19377
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r-- | src/env.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/env.cc b/src/env.cc index e5b9c0fd6a..ab5de3e2ee 100644 --- a/src/env.cc +++ b/src/env.cc @@ -133,6 +133,10 @@ Environment::Environment(IsolateData* isolate_data, } Environment::~Environment() { + // Make sure there are no re-used libuv wrapper objects. + // CleanupHandles() should have removed all of them. + CHECK(file_handle_read_wrap_freelist_.empty()); + v8::HandleScope handle_scope(isolate()); #if HAVE_INSPECTOR @@ -245,6 +249,8 @@ void Environment::CleanupHandles() { !handle_wrap_queue_.IsEmpty()) { uv_run(event_loop(), UV_RUN_ONCE); } + + file_handle_read_wrap_freelist_.clear(); } void Environment::StartProfilerIdleNotifier() { |