diff options
author | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2016-05-03 17:47:10 +0300 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2016-05-12 00:43:48 +0300 |
commit | 96a9439fd2c9577a735d6abf01990b45b836fba2 (patch) | |
tree | 76d999709f1d7aa41830c081fa0107aefb180f41 /src | |
parent | 738a1d639f8d59dccc600c67f63f1566c30306f8 (diff) |
Revert "handle_wrap: IsRefed -> Unrefed, no isAlive check"
This reverts commit 9bb5a5e2a127010807f5b8a8bf4cf34109271c55.
This API is not suitable because it depended on being able to
potentially access the handle's flag after the handle was already
cleaned up. Since this is not actually possible (obviously, oops)
this newer API no longer makes much sense, and the older API is more
suitable.
API comparison:
IsRefed -> Has a strong reference AND is alive. (Deterministic)
Unrefed -> Has a weak reference OR is dead. (Less deterministic)
Refs: https://github.com/nodejs/node/pull/6395
Refs: https://github.com/nodejs/node/pull/6204
Refs: https://github.com/nodejs/node/pull/6401
Refs: https://github.com/nodejs/node/pull/6382
Fixes: https://github.com/nodejs/node/pull/6381
PR-URL: https://github.com/nodejs/node/pull/6546
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Conflicts:
src/handle_wrap.cc
test/parallel/test-handle-wrap-isrefed-tty.js
test/parallel/test-handle-wrap-isrefed.js
Diffstat (limited to 'src')
-rw-r--r-- | src/handle_wrap.cc | 4 | ||||
-rw-r--r-- | src/handle_wrap.h | 2 | ||||
-rw-r--r-- | src/pipe_wrap.cc | 2 | ||||
-rw-r--r-- | src/process_wrap.cc | 2 | ||||
-rw-r--r-- | src/signal_wrap.cc | 2 | ||||
-rw-r--r-- | src/tcp_wrap.cc | 2 | ||||
-rw-r--r-- | src/timer_wrap.cc | 2 | ||||
-rw-r--r-- | src/tty_wrap.cc | 2 | ||||
-rw-r--r-- | src/udp_wrap.cc | 2 |
9 files changed, 10 insertions, 10 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index b82449989dd..d28b6959c82 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -33,9 +33,9 @@ void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) { } -void HandleWrap::Unrefed(const FunctionCallbackInfo<Value>& args) { +void HandleWrap::IsRefed(const FunctionCallbackInfo<Value>& args) { HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder()); - args.GetReturnValue().Set(!HasRef(wrap)); + args.GetReturnValue().Set(HasRef(wrap)); } diff --git a/src/handle_wrap.h b/src/handle_wrap.h index ef37cf9e341..506358c1405 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -35,7 +35,7 @@ class HandleWrap : public AsyncWrap { static void Close(const v8::FunctionCallbackInfo<v8::Value>& args); static void Ref(const v8::FunctionCallbackInfo<v8::Value>& args); static void Unref(const v8::FunctionCallbackInfo<v8::Value>& args); - static void Unrefed(const v8::FunctionCallbackInfo<v8::Value>& args); + static void IsRefed(const v8::FunctionCallbackInfo<v8::Value>& args); static inline bool IsAlive(const HandleWrap* wrap) { return wrap != nullptr && wrap->state_ != kClosed; diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 43df5cb7158..25080041c27 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -80,7 +80,7 @@ void PipeWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "close", HandleWrap::Close); env->SetProtoMethod(t, "unref", HandleWrap::Unref); env->SetProtoMethod(t, "ref", HandleWrap::Ref); - env->SetProtoMethod(t, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(t, "isRefed", HandleWrap::IsRefed); StreamWrap::AddMethods(env, t); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index b804d9f35e4..0b7ad41b61a 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -40,7 +40,7 @@ class ProcessWrap : public HandleWrap { env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); - env->SetProtoMethod(constructor, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(constructor, "isRefed", HandleWrap::IsRefed); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Process"), constructor->GetFunction()); diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index a008b083f0a..ca5201d81a4 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -32,7 +32,7 @@ class SignalWrap : public HandleWrap { env->SetProtoMethod(constructor, "close", HandleWrap::Close); env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); - env->SetProtoMethod(constructor, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(constructor, "isRefed", HandleWrap::IsRefed); env->SetProtoMethod(constructor, "start", Start); env->SetProtoMethod(constructor, "stop", Stop); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index d1cc99e756e..4e8617af2d0 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -87,7 +87,7 @@ void TCPWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "ref", HandleWrap::Ref); env->SetProtoMethod(t, "unref", HandleWrap::Unref); - env->SetProtoMethod(t, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(t, "isRefed", HandleWrap::IsRefed); StreamWrap::AddMethods(env, t, StreamBase::kFlagHasWritev); diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index b2c41ebf73a..4a1cd3716a9 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -39,7 +39,7 @@ class TimerWrap : public HandleWrap { env->SetProtoMethod(constructor, "close", HandleWrap::Close); env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); - env->SetProtoMethod(constructor, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(constructor, "isRefed", HandleWrap::IsRefed); env->SetProtoMethod(constructor, "start", Start); env->SetProtoMethod(constructor, "stop", Stop); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index e7acedd27a1..5a1d333c3d2 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -36,7 +36,7 @@ void TTYWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "close", HandleWrap::Close); env->SetProtoMethod(t, "unref", HandleWrap::Unref); - env->SetProtoMethod(t, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(t, "isRefed", HandleWrap::IsRefed); StreamWrap::AddMethods(env, t, StreamBase::kFlagNoShutdown); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index b5f3a3cf540..ac087f395ac 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -108,7 +108,7 @@ void UDPWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "ref", HandleWrap::Ref); env->SetProtoMethod(t, "unref", HandleWrap::Unref); - env->SetProtoMethod(t, "unrefed", HandleWrap::Unrefed); + env->SetProtoMethod(t, "isRefed", HandleWrap::IsRefed); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UDP"), t->GetFunction()); env->set_udp_constructor_function(t->GetFunction()); |