From a58d4839af6dfcb493ead8771cbff21b5ef9f18d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 26 Apr 2016 13:32:44 +0200 Subject: 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 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/handle_wrap.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/handle_wrap.h') diff --git a/src/handle_wrap.h b/src/handle_wrap.h index fe3c5a8d9d..ef37cf9e34 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -38,15 +38,11 @@ class HandleWrap : public AsyncWrap { static void Unrefed(const v8::FunctionCallbackInfo& args); static inline bool IsAlive(const HandleWrap* wrap) { - // XXX(bnoordhuis) It's debatable whether only kInitialized should - // count as alive but it's compatible with the check that it replaces. - return wrap != nullptr && wrap->state_ == kInitialized; + return wrap != nullptr && wrap->state_ != kClosed; } static inline bool HasRef(const HandleWrap* wrap) { - return wrap != nullptr && - wrap->state_ != kClosed && - uv_has_ref(wrap->GetHandle()); + return IsAlive(wrap) && uv_has_ref(wrap->GetHandle()); } inline uv_handle_t* GetHandle() const { return handle__; } -- cgit v1.2.3