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

Commit

Permalink
handle_wrap: don't abort if wrap == NULL
Browse files Browse the repository at this point in the history
After a disconnect, the internal pointer of the parent/child channel is set to
NULL. That's not an error so don't abort().
  • Loading branch information
bnoordhuis committed Sep 22, 2012
1 parent 86d4cf7 commit 17ef062
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/handle_wrap.cc
Expand Up @@ -23,6 +23,12 @@
#include "ngx-queue.h"
#include "handle_wrap.h"

#define UNWRAP_NO_ABORT(type) \
assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \
type* wrap = \
static_cast<type*>(args.Holder()->GetPointerFromInternalField(0));

namespace node {

using v8::Array;
Expand Down Expand Up @@ -53,10 +59,12 @@ void HandleWrap::Initialize(Handle<Object> target) {
Handle<Value> HandleWrap::Ref(const Arguments& args) {
HandleScope scope;

UNWRAP(HandleWrap)
UNWRAP_NO_ABORT(HandleWrap)

uv_ref(wrap->handle__);
wrap->unref_ = false;
if (wrap) {
uv_ref(wrap->handle__);
wrap->unref_ = false;
}

return v8::Undefined();
}
Expand All @@ -65,10 +73,12 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {
Handle<Value> HandleWrap::Unref(const Arguments& args) {
HandleScope scope;

UNWRAP(HandleWrap)
UNWRAP_NO_ABORT(HandleWrap)

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

return v8::Undefined();
}
Expand Down

0 comments on commit 17ef062

Please sign in to comment.