@@ -195,28 +195,28 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock,
195195
196196
197197static Local<Array> HostentToAddresses (struct hostent * host) {
198- HandleScope scope;
198+ HandleScope scope (node_isolate) ;
199199 Local<Array> addresses = Array::New ();
200200
201201 char ip[INET6_ADDRSTRLEN];
202202 for (int i = 0 ; host->h_addr_list [i]; ++i) {
203203 uv_inet_ntop (host->h_addrtype , host->h_addr_list [i], ip, sizeof (ip));
204204
205205 Local<String> address = String::New (ip);
206- addresses->Set (Integer::New (i), address);
206+ addresses->Set (Integer::New (i, node_isolate ), address);
207207 }
208208
209209 return scope.Close (addresses);
210210}
211211
212212
213213static Local<Array> HostentToNames (struct hostent * host) {
214- HandleScope scope;
214+ HandleScope scope (node_isolate) ;
215215 Local<Array> names = Array::New ();
216216
217217 for (int i = 0 ; host->h_aliases [i]; ++i) {
218218 Local<String> address = String::New (host->h_aliases [i]);
219- names->Set (Integer::New (i), address);
219+ names->Set (Integer::New (i, node_isolate ), address);
220220 }
221221
222222 return scope.Close (names);
@@ -260,7 +260,7 @@ static const char* AresErrnoString(int errorno) {
260260
261261
262262static void SetAresErrno (int errorno) {
263- HandleScope scope;
263+ HandleScope scope (node_isolate) ;
264264 Local<Value> key = String::NewSymbol (" _errno" );
265265 Local<Value> value = String::NewSymbol (AresErrnoString (errorno));
266266 node::process->Set (key, value);
@@ -270,7 +270,7 @@ static void SetAresErrno(int errorno) {
270270class QueryWrap {
271271 public:
272272 QueryWrap () {
273- HandleScope scope;
273+ HandleScope scope (node_isolate) ;
274274
275275 object_ = Persistent<Object>::New (node_isolate, Object::New ());
276276 }
@@ -336,23 +336,23 @@ class QueryWrap {
336336 }
337337
338338 void CallOnComplete (Local<Value> answer) {
339- HandleScope scope;
340- Local<Value> argv[2 ] = { Integer::New (0 ), answer };
339+ HandleScope scope (node_isolate) ;
340+ Local<Value> argv[2 ] = { Integer::New (0 , node_isolate ), answer };
341341 MakeCallback (object_, oncomplete_sym, ARRAY_SIZE (argv), argv);
342342 }
343343
344344 void CallOnComplete (Local<Value> answer, Local<Value> family) {
345- HandleScope scope;
346- Local<Value> argv[3 ] = { Integer::New (0 ), answer, family };
345+ HandleScope scope (node_isolate) ;
346+ Local<Value> argv[3 ] = { Integer::New (0 , node_isolate ), answer, family };
347347 MakeCallback (object_, oncomplete_sym, ARRAY_SIZE (argv), argv);
348348 }
349349
350350 void ParseError (int status) {
351351 assert (status != ARES_SUCCESS);
352352 SetAresErrno (status);
353353
354- HandleScope scope;
355- Local<Value> argv[1 ] = { Integer::New (-1 ) };
354+ HandleScope scope (node_isolate) ;
355+ Local<Value> argv[1 ] = { Integer::New (-1 , node_isolate ) };
356356 MakeCallback (object_, oncomplete_sym, ARRAY_SIZE (argv), argv);
357357 }
358358
@@ -379,7 +379,7 @@ class QueryAWrap: public QueryWrap {
379379
380380 protected:
381381 void Parse (unsigned char * buf, int len) {
382- HandleScope scope;
382+ HandleScope scope (node_isolate) ;
383383
384384 struct hostent * host;
385385
@@ -411,7 +411,7 @@ class QueryAaaaWrap: public QueryWrap {
411411
412412 protected:
413413 void Parse (unsigned char * buf, int len) {
414- HandleScope scope;
414+ HandleScope scope (node_isolate) ;
415415
416416 struct hostent * host;
417417
@@ -443,7 +443,7 @@ class QueryCnameWrap: public QueryWrap {
443443
444444 protected:
445445 void Parse (unsigned char * buf, int len) {
446- HandleScope scope;
446+ HandleScope scope (node_isolate) ;
447447
448448 struct hostent * host;
449449
@@ -473,7 +473,7 @@ class QueryMxWrap: public QueryWrap {
473473
474474 protected:
475475 void Parse (unsigned char * buf, int len) {
476- HandleScope scope;
476+ HandleScope scope (node_isolate) ;
477477
478478 struct ares_mx_reply * mx_start;
479479 int status = ares_parse_mx_reply (buf, len, &mx_start);
@@ -492,8 +492,8 @@ class QueryMxWrap: public QueryWrap {
492492 Local<Object> mx_record = Object::New ();
493493 mx_record->Set (exchange_symbol, String::New (mx_current->host ));
494494 mx_record->Set (priority_symbol,
495- Integer::New (mx_current->priority ));
496- mx_records->Set (Integer::New (i++), mx_record);
495+ Integer::New (mx_current->priority , node_isolate ));
496+ mx_records->Set (Integer::New (i++, node_isolate ), mx_record);
497497 }
498498
499499 ares_free_data (mx_start);
@@ -550,7 +550,7 @@ class QueryTxtWrap: public QueryWrap {
550550 struct ares_txt_reply *current = txt_out;
551551 for (int i = 0 ; current; ++i, current = current->next ) {
552552 Local<String> txt = String::New (reinterpret_cast <char *>(current->txt ));
553- txt_records->Set (Integer::New (i), txt);
553+ txt_records->Set (Integer::New (i, node_isolate ), txt);
554554 }
555555
556556 ares_free_data (txt_out);
@@ -574,7 +574,7 @@ class QuerySrvWrap: public QueryWrap {
574574
575575 protected:
576576 void Parse (unsigned char * buf, int len) {
577- HandleScope scope;
577+ HandleScope scope (node_isolate) ;
578578
579579 struct ares_srv_reply * srv_start;
580580 int status = ares_parse_srv_reply (buf, len, &srv_start);
@@ -595,12 +595,12 @@ class QuerySrvWrap: public QueryWrap {
595595 Local<Object> srv_record = Object::New ();
596596 srv_record->Set (name_symbol, String::New (srv_current->host ));
597597 srv_record->Set (port_symbol,
598- Integer::New (srv_current->port ));
598+ Integer::New (srv_current->port , node_isolate ));
599599 srv_record->Set (priority_symbol,
600- Integer::New (srv_current->priority ));
600+ Integer::New (srv_current->priority , node_isolate ));
601601 srv_record->Set (weight_symbol,
602- Integer::New (srv_current->weight ));
603- srv_records->Set (Integer::New (i++), srv_record);
602+ Integer::New (srv_current->weight , node_isolate ));
603+ srv_records->Set (Integer::New (i++, node_isolate ), srv_record);
604604 }
605605
606606 ares_free_data (srv_start);
@@ -623,7 +623,7 @@ class QueryNaptrWrap: public QueryWrap {
623623
624624 protected:
625625 void Parse (unsigned char * buf, int len) {
626- HandleScope scope;
626+ HandleScope scope (node_isolate) ;
627627
628628 ares_naptr_reply* naptr_start;
629629 int status = ares_parse_naptr_reply (buf, len, &naptr_start);
@@ -656,11 +656,12 @@ class QueryNaptrWrap: public QueryWrap {
656656 String::New (reinterpret_cast <char *>(naptr_current->regexp )));
657657 naptr_record->Set (replacement_symbol,
658658 String::New (naptr_current->replacement ));
659- naptr_record->Set (order_symbol, Integer::New (naptr_current->order ));
659+ naptr_record->Set (order_symbol, Integer::New (naptr_current->order ,
660+ node_isolate));
660661 naptr_record->Set (preference_symbol,
661- Integer::New (naptr_current->preference ));
662+ Integer::New (naptr_current->preference , node_isolate ));
662663
663- naptr_records->Set (Integer::New (i++), naptr_record);
664+ naptr_records->Set (Integer::New (i++, node_isolate ), naptr_record);
664665 }
665666
666667 ares_free_data (naptr_start);
@@ -697,7 +698,7 @@ class GetHostByAddrWrap: public QueryWrap {
697698
698699 protected:
699700 void Parse (struct hostent * host) {
700- HandleScope scope;
701+ HandleScope scope (node_isolate) ;
701702
702703 this ->CallOnComplete (HostentToNames (host));
703704 }
@@ -713,10 +714,10 @@ class GetHostByNameWrap: public QueryWrap {
713714
714715 protected:
715716 void Parse (struct hostent * host) {
716- HandleScope scope;
717+ HandleScope scope (node_isolate) ;
717718
718719 Local<Array> addresses = HostentToAddresses (host);
719- Local<Integer> family = Integer::New (host->h_addrtype );
720+ Local<Integer> family = Integer::New (host->h_addrtype , node_isolate );
720721
721722 this ->CallOnComplete (addresses, family);
722723 }
@@ -725,7 +726,7 @@ class GetHostByNameWrap: public QueryWrap {
725726
726727template <class Wrap >
727728static Handle<Value> Query (const Arguments& args) {
728- HandleScope scope;
729+ HandleScope scope (node_isolate) ;
729730
730731 assert (!args.IsConstructCall ());
731732 assert (args.Length () >= 2 );
@@ -737,15 +738,15 @@ static Handle<Value> Query(const Arguments& args) {
737738 // We must cache the wrap's js object here, because cares might make the
738739 // callback from the wrap->Send stack. This will destroy the wrap's internal
739740 // object reference, causing wrap->GetObject() to return undefined.
740- Local<Object> object = Local<Object>::New (wrap->GetObject ());
741+ Local<Object> object = Local<Object>::New (node_isolate, wrap->GetObject ());
741742
742743 String::Utf8Value name (args[0 ]);
743744
744745 int r = wrap->Send (*name);
745746 if (r) {
746747 SetAresErrno (r);
747748 delete wrap;
748- return scope.Close (v8::Null ());
749+ return scope.Close (v8::Null (node_isolate ));
749750 } else {
750751 return scope.Close (object);
751752 }
@@ -754,7 +755,7 @@ static Handle<Value> Query(const Arguments& args) {
754755
755756template <class Wrap >
756757static Handle<Value> QueryWithFamily (const Arguments& args) {
757- HandleScope scope;
758+ HandleScope scope (node_isolate) ;
758759
759760 assert (!args.IsConstructCall ());
760761 assert (args.Length () >= 3 );
@@ -766,7 +767,7 @@ static Handle<Value> QueryWithFamily(const Arguments& args) {
766767 // We must cache the wrap's js object here, because cares might make the
767768 // callback from the wrap->Send stack. This will destroy the wrap's internal
768769 // object reference, causing wrap->GetObject() to return undefined.
769- Local<Object> object = Local<Object>::New (wrap->GetObject ());
770+ Local<Object> object = Local<Object>::New (node_isolate, wrap->GetObject ());
770771
771772 String::Utf8Value name (args[0 ]);
772773 int family = args[1 ]->Int32Value ();
@@ -775,15 +776,15 @@ static Handle<Value> QueryWithFamily(const Arguments& args) {
775776 if (r) {
776777 SetAresErrno (r);
777778 delete wrap;
778- return scope.Close (v8::Null ());
779+ return scope.Close (v8::Null (node_isolate ));
779780 } else {
780781 return scope.Close (object);
781782 }
782783}
783784
784785
785786void AfterGetAddrInfo (uv_getaddrinfo_t * req, int status, struct addrinfo * res) {
786- HandleScope scope;
787+ HandleScope scope (node_isolate) ;
787788
788789 GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data ;
789790
@@ -792,7 +793,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
792793 if (status) {
793794 // Error
794795 SetErrno (uv_last_error (uv_default_loop ()));
795- argv[0 ] = Local<Value>::New (Null ());
796+ argv[0 ] = Local<Value>::New (node_isolate, Null (node_isolate ));
796797 } else {
797798 // Success
798799 struct addrinfo *address;
@@ -878,25 +879,25 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
878879
879880
880881static Handle<Value> IsIP (const Arguments& args) {
881- HandleScope scope;
882+ HandleScope scope (node_isolate) ;
882883
883884 String::AsciiValue ip (args[0 ]);
884885 char address_buffer[sizeof (struct in6_addr )];
885886
886887 if (uv_inet_pton (AF_INET, *ip, &address_buffer).code == UV_OK) {
887- return scope.Close (v8::Integer::New (4 ));
888+ return scope.Close (v8::Integer::New (4 , node_isolate ));
888889 }
889890
890891 if (uv_inet_pton (AF_INET6, *ip, &address_buffer).code == UV_OK) {
891- return scope.Close (v8::Integer::New (6 ));
892+ return scope.Close (v8::Integer::New (6 , node_isolate ));
892893 }
893894
894- return scope.Close (v8::Integer::New (0 ));
895+ return scope.Close (v8::Integer::New (0 , node_isolate ));
895896}
896897
897898
898899static Handle<Value> GetAddrInfo (const Arguments& args) {
899- HandleScope scope;
900+ HandleScope scope (node_isolate) ;
900901
901902 String::Utf8Value hostname (args[0 ]);
902903
@@ -931,15 +932,15 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
931932 if (r) {
932933 SetErrno (uv_last_error (uv_default_loop ()));
933934 delete req_wrap;
934- return scope.Close (v8::Null ());
935+ return scope.Close (v8::Null (node_isolate ));
935936 } else {
936937 return scope.Close (req_wrap->object_ );
937938 }
938939}
939940
940941
941942static void Initialize (Handle<Object> target) {
942- HandleScope scope;
943+ HandleScope scope (node_isolate) ;
943944 int r;
944945
945946 r = ares_library_init (ARES_LIB_INIT_ALL);
@@ -976,11 +977,11 @@ static void Initialize(Handle<Object> target) {
976977 NODE_SET_METHOD (target, " isIP" , IsIP);
977978
978979 target->Set (String::NewSymbol (" AF_INET" ),
979- Integer::New (AF_INET));
980+ Integer::New (AF_INET, node_isolate ));
980981 target->Set (String::NewSymbol (" AF_INET6" ),
981- Integer::New (AF_INET6));
982+ Integer::New (AF_INET6, node_isolate ));
982983 target->Set (String::NewSymbol (" AF_UNSPEC" ),
983- Integer::New (AF_UNSPEC));
984+ Integer::New (AF_UNSPEC, node_isolate ));
984985
985986 oncomplete_sym = NODE_PSYMBOL (" oncomplete" );
986987}
0 commit comments