aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc')
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc69
1 files changed, 32 insertions, 37 deletions
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
index 04379975e1..fecf2bfebc 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
@@ -96,23 +96,23 @@ static void grpc_ares_request_ref(grpc_ares_request *r) {
gpr_ref(&r->pending_queries);
}
-static void grpc_ares_request_unref(grpc_exec_ctx *exec_ctx,
- grpc_ares_request *r) {
+static void grpc_ares_request_unref(grpc_ares_request *r) {
/* If there are no pending queries, invoke on_done callback and destroy the
request */
if (gpr_unref(&r->pending_queries)) {
/* TODO(zyc): Sort results with RFC6724 before invoking on_done. */
- if (exec_ctx == NULL) {
+ if (/*might be dangerous */ exec_ctx == NULL) {
/* A new exec_ctx is created here, as the c-ares interface does not
provide one in ares_host_callback. It's safe to schedule on_done with
the newly created exec_ctx, since the caller has been warned not to
acquire locks in on_done. ares_dns_resolver is using combiner to
protect resources needed by on_done. */
- grpc_exec_ctx new_exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&new_exec_ctx, r->on_done, r->error);
- grpc_exec_ctx_finish(&new_exec_ctx);
+ ExecCtx _local_exec_ctx;
+ GRPC_CLOSURE_SCHED(/* might be dangerous &new_exec_ctx, */ r->on_done,
+ r->error);
+ grpc_exec_ctx_finish(/*&new_exec_ctx*/);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, r->error);
+ GRPC_CLOSURE_SCHED(r->on_done, r->error);
}
gpr_mu_destroy(&r->mu);
grpc_ares_ev_driver_destroy(r->ev_driver);
@@ -133,9 +133,8 @@ static grpc_ares_hostbyname_request *create_hostbyname_request(
return hr;
}
-static void destroy_hostbyname_request(grpc_exec_ctx *exec_ctx,
- grpc_ares_hostbyname_request *hr) {
- grpc_ares_request_unref(exec_ctx, hr->parent_request);
+static void destroy_hostbyname_request(grpc_ares_hostbyname_request *hr) {
+ grpc_ares_request_unref(hr->parent_request);
gpr_free(hr->host);
gpr_free(hr);
}
@@ -220,13 +219,13 @@ static void on_hostbyname_done_cb(void *arg, int status, int timeouts,
}
}
gpr_mu_unlock(&r->mu);
- destroy_hostbyname_request(NULL, hr);
+ destroy_hostbyname_request(/* might be dangerous */ hr);
}
static void on_srv_query_done_cb(void *arg, int status, int timeouts,
unsigned char *abuf, int alen) {
grpc_ares_request *r = (grpc_ares_request *)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "on_query_srv_done_cb");
if (status == ARES_SUCCESS) {
gpr_log(GPR_DEBUG, "on_query_srv_done_cb ARES_SUCCESS");
@@ -246,7 +245,7 @@ static void on_srv_query_done_cb(void *arg, int status, int timeouts,
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb,
hr);
- grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_start(r->ev_driver);
}
}
if (reply != NULL) {
@@ -264,8 +263,8 @@ static void on_srv_query_done_cb(void *arg, int status, int timeouts,
r->error = grpc_error_add_child(error, r->error);
}
}
- grpc_ares_request_unref(&exec_ctx, r);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_ares_request_unref(r);
+ grpc_exec_ctx_finish();
}
static const char g_service_config_attribute_prefix[] = "grpc_config=";
@@ -323,14 +322,13 @@ fail:
}
done:
gpr_mu_unlock(&r->mu);
- grpc_ares_request_unref(NULL, r);
+ grpc_ares_request_unref(r);
}
static grpc_ares_request *grpc_dns_lookup_ares_impl(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
- char **service_config_json) {
+ const char *dns_server, const char *name, const char *default_port,
+ grpc_pollset_set *interested_parties, grpc_closure *on_done,
+ grpc_lb_addresses **addrs, bool check_grpclb, char **service_config_json) {
grpc_error *error = GRPC_ERROR_NONE;
grpc_ares_hostbyname_request *hr = NULL;
grpc_ares_request *r = NULL;
@@ -434,28 +432,28 @@ static grpc_ares_request *grpc_dns_lookup_ares_impl(
ares_search(*channel, hr->host, ns_c_in, ns_t_txt, on_txt_done_cb, r);
}
/* TODO(zyc): Handle CNAME records here. */
- grpc_ares_ev_driver_start(exec_ctx, r->ev_driver);
- grpc_ares_request_unref(exec_ctx, r);
+ grpc_ares_ev_driver_start(r->ev_driver);
+ grpc_ares_request_unref(r);
gpr_free(host);
gpr_free(port);
return r;
error_cleanup:
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
gpr_free(host);
gpr_free(port);
return NULL;
}
grpc_ares_request *(*grpc_dns_lookup_ares)(
- grpc_exec_ctx *exec_ctx, const char *dns_server, const char *name,
- const char *default_port, grpc_pollset_set *interested_parties,
- grpc_closure *on_done, grpc_lb_addresses **addrs, bool check_grpclb,
+ const char *dns_server, const char *name, const char *default_port,
+ grpc_pollset_set *interested_parties, grpc_closure *on_done,
+ grpc_lb_addresses **addrs, bool check_grpclb,
char **service_config_json) = grpc_dns_lookup_ares_impl;
-void grpc_cancel_ares_request(grpc_exec_ctx *exec_ctx, grpc_ares_request *r) {
+void grpc_cancel_ares_request(grpc_ares_request *r) {
if (grpc_dns_lookup_ares == grpc_dns_lookup_ares_impl) {
- grpc_ares_ev_driver_shutdown(exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_shutdown(r->ev_driver);
}
}
@@ -498,8 +496,7 @@ typedef struct grpc_resolve_address_ares_request {
grpc_closure on_dns_lookup_done;
} grpc_resolve_address_ares_request;
-static void on_dns_lookup_done_cb(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void on_dns_lookup_done_cb(void *arg, grpc_error *error) {
grpc_resolve_address_ares_request *r =
(grpc_resolve_address_ares_request *)arg;
grpc_resolved_addresses **resolved_addresses = r->addrs_out;
@@ -517,14 +514,12 @@ static void on_dns_lookup_done_cb(grpc_exec_ctx *exec_ctx, void *arg,
&r->lb_addrs->addresses[i].address, sizeof(grpc_resolved_address));
}
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_resolve_address_done,
- GRPC_ERROR_REF(error));
- grpc_lb_addresses_destroy(exec_ctx, r->lb_addrs);
+ GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error));
+ grpc_lb_addresses_destroy(r->lb_addrs);
gpr_free(r);
}
-static void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx,
- const char *name,
+static void grpc_resolve_address_ares_impl(const char *name,
const char *default_port,
grpc_pollset_set *interested_parties,
grpc_closure *on_done,
@@ -536,14 +531,14 @@ static void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx,
r->on_resolve_address_done = on_done;
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done, on_dns_lookup_done_cb, r,
grpc_schedule_on_exec_ctx);
- grpc_dns_lookup_ares(exec_ctx, NULL /* dns_server */, name, default_port,
+ grpc_dns_lookup_ares(NULL /* dns_server */, name, default_port,
interested_parties, &r->on_dns_lookup_done, &r->lb_addrs,
false /* check_grpclb */,
NULL /* service_config_json */);
}
void (*grpc_resolve_address_ares)(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
+ const char *name, const char *default_port,
grpc_pollset_set *interested_parties, grpc_closure *on_done,
grpc_resolved_addresses **addrs) = grpc_resolve_address_ares_impl;