aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/client_channel/resolvers/sockaddr_resolver_test.c
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-13 16:07:13 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-18 17:12:19 -0700
commit0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch)
treee43d5de442fdcc3d39cd5af687f319fa39612d3f /test/core/client_channel/resolvers/sockaddr_resolver_test.c
parent6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (diff)
Removing instances of exec_ctx being passed around in functions in
src/core. exec_ctx is now a thread_local pointer of type ExecCtx instead of grpc_exec_ctx which is initialized whenever ExecCtx is instantiated. ExecCtx also keeps track of the previous exec_ctx so that nesting of exec_ctx is allowed. This means that there is only one exec_ctx being used at any time. Also, grpc_exec_ctx_finish is called in the destructor of the object, and the previous exec_ctx is restored to avoid breaking current functionality. The code still explicitly calls grpc_exec_ctx_finish because removing all such instances causes the code to break.
Diffstat (limited to 'test/core/client_channel/resolvers/sockaddr_resolver_test.c')
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
index 8b88619164..e69c68141b 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
@@ -35,14 +35,14 @@ typedef struct on_resolution_arg {
grpc_channel_args *resolver_result;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+void on_resolution_cb(void *arg, grpc_error *error) {
on_resolution_arg *res = arg;
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
+ grpc_channel_args_destroy(res->resolver_result);
}
static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -51,7 +51,7 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver != NULL);
on_resolution_arg on_res_arg;
@@ -60,16 +60,16 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
grpc_closure *on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
+ grpc_exec_ctx_finish();
grpc_uri_destroy(uri);
}
static void test_fails(grpc_resolver_factory *factory, const char *string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
@@ -78,10 +78,10 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == NULL);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_finish();
}
int main(int argc, char **argv) {
@@ -112,9 +112,9 @@ int main(int argc, char **argv) {
grpc_resolver_factory_unref(ipv6);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ exec_ctx = GRPC_EXEC_CTX_INIT;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
+ grpc_exec_ctx_finish();
}
grpc_shutdown();