diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-04-26 14:32:44 +0300 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-04-27 17:27:28 +0300 |
commit | a58d4839af6dfcb493ead8771cbff21b5ef9f18d (patch) | |
tree | 6d926fbecebc2b091087824728f680a568ebb17c /src/handle_wrap.cc | |
parent | cad1a62d325b011887349687962700dfe7510525 (diff) |
src: simplify handlewrap state tracking logic
This also updates the tests to expect that a closed handle has no
reference count.
PR-URL: https://github.com/nodejs/node/pull/6395
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/handle_wrap.cc')
-rw-r--r-- | src/handle_wrap.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 85c8d9e9215..b82449989dd 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -35,10 +35,7 @@ void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) { void HandleWrap::Unrefed(const FunctionCallbackInfo<Value>& args) { HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder()); - // XXX(bnoordhuis) It's debatable whether a nullptr wrap should count - // as having a reference count but it's compatible with the logic that - // it replaces. - args.GetReturnValue().Set(wrap == nullptr || !HasRef(wrap)); + args.GetReturnValue().Set(!HasRef(wrap)); } @@ -51,6 +48,9 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) { if (!IsAlive(wrap)) return; + if (wrap->state_ != kInitialized) + return; + CHECK_EQ(false, wrap->persistent().IsEmpty()); uv_close(wrap->handle__, OnClose); wrap->state_ = kClosing; |