From b8c3d715fdb0c08065b98a640ee72dbcbd6c5c8c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 26 Jan 2010 18:34:42 -0800 Subject: [PATCH] use efence again --- src/node_object_wrap.h | 17 +++++++++++++---- wscript | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index 457b234581..6656664bdf 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -13,10 +13,12 @@ class ObjectWrap { } virtual ~ObjectWrap ( ) { - assert(handle_.IsNearDeath()); - handle_->SetInternalField(0, v8::Undefined()); - handle_.Dispose(); - handle_.Clear(); + if (!handle_.IsEmpty()) { + assert(handle_.IsNearDeath()); + handle_->SetInternalField(0, v8::Undefined()); + handle_.Dispose(); + handle_.Clear(); + } } protected: @@ -35,6 +37,11 @@ class ObjectWrap { assert(handle->InternalFieldCount() > 0); handle_ = v8::Persistent::New(handle); handle_->SetInternalField(0, v8::External::New(this)); + MakeWeak(); + } + + inline void MakeWeak (void) + { handle_.MakeWeak(this, WeakCallback); } @@ -75,6 +82,8 @@ class ObjectWrap { assert(value == obj->handle_); if (obj->refs_ == 0) { delete obj; + } else { + obj->MakeWeak(); } } }; diff --git a/wscript b/wscript index 2431ecb1c3..bd2425035c 100644 --- a/wscript +++ b/wscript @@ -118,8 +118,8 @@ def configure(conf): #if Options.options.debug: # conf.check(lib='profiler', uselib_store='PROFILER') - #if Options.options.efence: - # conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE') + if Options.options.efence: + conf.check(lib='efence', libpath=['/usr/lib', '/usr/local/lib'], uselib_store='EFENCE') if not conf.check(lib="execinfo", libpath=['/usr/lib', '/usr/local/lib'], uselib_store="EXECINFO"): # Note on Darwin/OS X: This will fail, but will still be used as the @@ -373,7 +373,7 @@ def build(bld): """ node.add_objects = 'ev eio evcom http_parser coupling' node.uselib_local = '' - node.uselib = 'GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL' + node.uselib = 'GNUTLS GPGERROR UDNS V8 EXECINFO DL KVM SOCKET NSL EFENCE' node.install_path = '${PREFIX}/lib' node.install_path = '${PREFIX}/bin'