diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-09-04 23:02:55 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-10 15:15:16 +0300 |
commit | 17e289eca8f8398243df5c4006d80f7381fd08bc (patch) | |
tree | 781f1398f78aa4b602ae3fca8654c28576e70b52 /src/fs_event_wrap.cc | |
parent | 5c6cf30143f3191b043ba0b4e814768efa1069f7 (diff) |
src: make CleanupHandles() tear down handles/reqs
Previously, handles would not be closed when the current `Environment`
stopped, which is acceptable in a single-`Environment`-per-process
situation, but would otherwise create memory and file descriptor
leaks.
Also, introduce a generic way to close handles via the
`Environment::CloseHandle()` function, which automatically keeps
track of whether a close callback has been called yet or not.
Many thanks for Stephen Belanger for reviewing the original version of
this commit in the Ayo.js project.
Refs: https://github.com/ayojs/ayo/pull/85
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/fs_event_wrap.cc')
-rw-r--r-- | src/fs_event_wrap.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index ed74f36719d..579e446fc5c 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -78,11 +78,12 @@ FSEventWrap::FSEventWrap(Environment* env, Local<Object> object) : HandleWrap(env, object, reinterpret_cast<uv_handle_t*>(&handle_), - AsyncWrap::PROVIDER_FSEVENTWRAP) {} + AsyncWrap::PROVIDER_FSEVENTWRAP) { + MarkAsUninitialized(); +} FSEventWrap::~FSEventWrap() { - CHECK_EQ(initialized_, false); } void FSEventWrap::GetInitialized(const FunctionCallbackInfo<Value>& args) { @@ -153,6 +154,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) { } err = uv_fs_event_start(&wrap->handle_, OnEvent, *path, flags); + wrap->MarkAsInitialized(); wrap->initialized_ = true; if (err != 0) { |