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

Commit

Permalink
node: make _getActiveHandles() return user objects
Browse files Browse the repository at this point in the history
Before this commit, process._getActiveHandles() returned a list of internal
handles. Now, it returns the user objects that handles are attached to.

For example, a tcp_wrap handle will now return its parent net.Socket object.

It works for all handle types except timers because timer handles are shared
across multiple user objects.
  • Loading branch information
bnoordhuis committed May 15, 2012
1 parent 88d7a10 commit e813e34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node.cc
Expand Up @@ -1362,10 +1362,14 @@ Handle<Value> GetActiveHandles(const Arguments& args) {
ngx_queue_t* q = NULL;
int i = 0;

Local<String> owner_sym = String::New("owner");

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

return scope.Close(ary);
Expand Down

0 comments on commit e813e34

Please sign in to comment.