summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-08-01 14:21:39 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2012-09-22 03:49:17 +0200
commit17ef062db1f4b2a952d7c540ebb08acb8077f3e8 (patch)
tree3eb4a9f3ebc8079abebf58c2920c873e04da226f
parent86d4cf71d6abd861e3d12a5b1258536c6686176b (diff)
downloadnode-17ef062db1f4b2a952d7c540ebb08acb8077f3e8.tar.gz
handle_wrap: don't abort if wrap == NULL
After a disconnect, the internal pointer of the parent/child channel is set to NULL. That's not an error so don't abort().
-rw-r--r--src/handle_wrap.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
index ead7da1f7..4c43957b8 100644
--- a/src/handle_wrap.cc
+++ b/src/handle_wrap.cc
@@ -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;
@@ -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();
}
@@ -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();
}