diff options
author | 2017-10-13 16:07:13 -0700 | |
---|---|---|
committer | 2017-10-18 17:12:19 -0700 | |
commit | 0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch) | |
tree | e43d5de442fdcc3d39cd5af687f319fa39612d3f /test/core/surface/concurrent_connectivity_test.c | |
parent | 6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (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/surface/concurrent_connectivity_test.c')
-rw-r--r-- | test/core/surface/concurrent_connectivity_test.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 3595885ff6..28bdf5d1d3 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -99,29 +99,28 @@ void server_thread(void *vargs) { GPR_ASSERT(detag(ev.tag) == 0xd1e); } -static void on_connect(grpc_exec_ctx *exec_ctx, void *vargs, grpc_endpoint *tcp, +static void on_connect(void *vargs, grpc_endpoint *tcp, grpc_pollset *accepting_pollset, grpc_tcp_server_acceptor *acceptor) { gpr_free(acceptor); struct server_thread_args *args = (struct server_thread_args *)vargs; - grpc_endpoint_shutdown(exec_ctx, tcp, + grpc_endpoint_shutdown(tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); - grpc_endpoint_destroy(exec_ctx, tcp); + grpc_endpoint_destroy(tcp); gpr_mu_lock(args->mu); - GRPC_LOG_IF_ERROR("pollset_kick", - grpc_pollset_kick(exec_ctx, args->pollset, NULL)); + GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, NULL)); gpr_mu_unlock(args->mu); } void bad_server_thread(void *vargs) { struct server_thread_args *args = (struct server_thread_args *)vargs; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; int port; grpc_tcp_server *s; - grpc_error *error = grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s); + grpc_error *error = grpc_tcp_server_create(NULL, NULL, &s); GPR_ASSERT(error == GRPC_ERROR_NONE); memset(&resolved_addr, 0, sizeof(resolved_addr)); addr->ss_family = AF_INET; @@ -130,35 +129,34 @@ void bad_server_thread(void *vargs) { GPR_ASSERT(port > 0); gpr_asprintf(&args->addr, "localhost:%d", port); - grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args); + grpc_tcp_server_start(s, &args->pollset, 1, on_connect, args); gpr_event_set(&args->ready, (void *)1); gpr_mu_lock(args->mu); while (gpr_atm_acq_load(&args->stop) == 0) { - grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100; + grpc_millis deadline = grpc_exec_ctx_now() + 100; grpc_pollset_worker *worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) { + grpc_pollset_work(args->pollset, &worker, deadline))) { gpr_atm_rel_store(&args->stop, 1); } gpr_mu_unlock(args->mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_finish(); gpr_mu_lock(args->mu); } gpr_mu_unlock(args->mu); - grpc_tcp_server_unref(&exec_ctx, s); + grpc_tcp_server_unref(s); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_finish(); gpr_free(args->addr); } -static void done_pollset_shutdown(grpc_exec_ctx *exec_ctx, void *pollset, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, pollset); +static void done_pollset_shutdown(void *pollset, grpc_error *error) { + grpc_pollset_destroy(pollset); gpr_free(pollset); } @@ -226,11 +224,11 @@ int run_concurrent_connectivity_test() { gpr_atm_rel_store(&args.stop, 1); gpr_thd_join(server); - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_shutdown(&exec_ctx, args.pollset, + exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_pollset_shutdown(args.pollset, GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset, grpc_schedule_on_exec_ctx)); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_finish(); grpc_shutdown(); return 0; |