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

Commit

Permalink
src: use Context::Scope objects in cares_wrap.cc
Browse files Browse the repository at this point in the history
Enter the context explicitly, don't rely on the fact that there is a
Context::Scope a few stack frames below because it may be gone someday
  • Loading branch information
bnoordhuis committed Nov 12, 2013
1 parent 27f115d commit 5235d71
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ class QueryAWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());

struct hostent* host;

Expand Down Expand Up @@ -403,7 +404,8 @@ class QueryAaaaWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());

struct hostent* host;

Expand Down Expand Up @@ -439,8 +441,8 @@ class QueryCnameWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);

HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
struct hostent* host;

int status = ares_parse_a_reply(buf, len, &host, NULL, NULL);
Expand Down Expand Up @@ -478,7 +480,8 @@ class QueryMxWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());

struct ares_mx_reply* mx_start;
int status = ares_parse_mx_reply(buf, len, &mx_start);
Expand Down Expand Up @@ -528,6 +531,8 @@ class QueryNsWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
struct hostent* host;

int status = ares_parse_ns_reply(buf, len, &host);
Expand Down Expand Up @@ -562,6 +567,8 @@ class QueryTxtWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
struct ares_txt_reply* txt_out;

int status = ares_parse_txt_reply(buf, len, &txt_out);
Expand Down Expand Up @@ -603,7 +610,8 @@ class QuerySrvWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());

struct ares_srv_reply* srv_start;
int status = ares_parse_srv_reply(buf, len, &srv_start);
Expand Down Expand Up @@ -660,7 +668,8 @@ class QueryNaptrWrap: public QueryWrap {

protected:
void Parse(unsigned char* buf, int len) {
HandleScope scope(node_isolate);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());

ares_naptr_reply* naptr_start;
int status = ares_parse_naptr_reply(buf, len, &naptr_start);
Expand Down Expand Up @@ -740,8 +749,8 @@ class GetHostByAddrWrap: public QueryWrap {

protected:
void Parse(struct hostent* host) {
HandleScope scope(node_isolate);

HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
this->CallOnComplete(HostentToNames(host));
}
};
Expand Down

0 comments on commit 5235d71

Please sign in to comment.