Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
handle_wrap: replace unref_ field with flags_ field
Browse files Browse the repository at this point in the history
Prep work for a follow-up commit that adds support for close callbacks.
  • Loading branch information
bnoordhuis committed Mar 6, 2013
1 parent 3dbbfd7 commit 3d20905
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/handle_wrap.cc
Expand Up @@ -63,7 +63,7 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {

if (wrap) {
uv_ref(wrap->handle__);
wrap->unref_ = false;
wrap->flags_ &= ~kUnref;
}

return v8::Undefined();
Expand All @@ -77,7 +77,7 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {

if (wrap) {
uv_unref(wrap->handle__);
wrap->unref_ = true;
wrap->flags_ |= kUnref;
}

return v8::Undefined();
Expand All @@ -102,7 +102,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {


HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
unref_ = false;
flags_ = 0;
handle__ = h;
if (h) {
h->data = this;
Expand Down
4 changes: 3 additions & 1 deletion src/handle_wrap.h
Expand Up @@ -70,7 +70,9 @@ class HandleWrap {
// Using double underscore due to handle_ member in tcp_wrap. Probably
// tcp_wrap should rename it's member to 'handle'.
uv_handle_t* handle__;
bool unref_;
unsigned int flags_;

static const unsigned int kUnref = 1;
};


Expand Down
2 changes: 1 addition & 1 deletion src/node.cc
Expand Up @@ -1382,7 +1382,7 @@ Handle<Value> GetActiveHandles(const Arguments& args) {

ngx_queue_foreach(q, &handle_wrap_queue) {
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
if (w->object_.IsEmpty() || w->unref_) continue;
if (w->object_.IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
Local<Value> obj = w->object_->Get(owner_sym);
if (obj->IsUndefined()) obj = *w->object_;
ary->Set(i++, obj);
Expand Down

0 comments on commit 3d20905

Please sign in to comment.