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.cc70
1 files changed, 26 insertions, 44 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 7846576c11..3a870b2d06 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,24 +96,12 @@ 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 == nullptr) {
- /* 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);
- } 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);
gpr_free(r);
@@ -133,9 +121,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 +207,13 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
}
}
gpr_mu_unlock(&r->mu);
- destroy_hostbyname_request(nullptr, hr);
+ destroy_hostbyname_request(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;
+ grpc_core::ExecCtx 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 +233,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 != nullptr) {
@@ -264,8 +251,7 @@ 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);
}
static const char g_service_config_attribute_prefix[] = "grpc_config=";
@@ -323,14 +309,13 @@ fail:
}
done:
gpr_mu_unlock(&r->mu);
- grpc_ares_request_unref(nullptr, 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 = nullptr;
grpc_ares_request* r = nullptr;
@@ -437,28 +422,28 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
gpr_free(config_name);
}
/* 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 nullptr;
}
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);
}
}
@@ -501,8 +486,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;
@@ -520,14 +504,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,
@@ -539,14 +521,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, nullptr /* dns_server */, name, default_port,
+ grpc_dns_lookup_ares(nullptr /* dns_server */, name, default_port,
interested_parties, &r->on_dns_lookup_done, &r->lb_addrs,
false /* check_grpclb */,
nullptr /* 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;