diff options
Diffstat (limited to 'test/core/util/reconnect_server.c')
-rw-r--r-- | test/core/util/reconnect_server.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c index 71fb69b54f..ee481ef674 100644 --- a/test/core/util/reconnect_server.c +++ b/test/core/util/reconnect_server.c @@ -65,15 +65,15 @@ static void pretty_print_backoffs(reconnect_server *server) { } } -static void on_connect(void *arg, grpc_endpoint *tcp) { +static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp) { char *peer; char *last_colon; reconnect_server *server = (reconnect_server *)arg; gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); timestamp_list *new_tail; peer = grpc_endpoint_get_peer(tcp); - grpc_endpoint_shutdown(tcp); - grpc_endpoint_destroy(tcp); + grpc_endpoint_shutdown(exec_ctx, tcp); + grpc_endpoint_destroy(exec_ctx, tcp); if (peer) { last_colon = strrchr(peer, ':'); if (server->peer == NULL) { @@ -114,6 +114,7 @@ void reconnect_server_init(reconnect_server *server) { void reconnect_server_start(reconnect_server *server, int port) { struct sockaddr_in addr; int port_added; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; addr.sin_family = AF_INET; addr.sin_port = htons((gpr_uint16)port); @@ -124,9 +125,11 @@ void reconnect_server_start(reconnect_server *server, int port) { grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr)); GPR_ASSERT(port_added == port); - grpc_tcp_server_start(server->tcp_server, server->pollsets, 1, on_connect, - server); + grpc_tcp_server_start(&exec_ctx, server->tcp_server, server->pollsets, 1, + on_connect, server); gpr_log(GPR_INFO, "reconnect tcp server listening on 0.0.0.0:%d", port); + + grpc_exec_ctx_finish(&exec_ctx); } void reconnect_server_poll(reconnect_server *server, int seconds) { @@ -134,10 +137,12 @@ void reconnect_server_poll(reconnect_server *server, int seconds) { gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(seconds, GPR_TIMESPAN)); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(GRPC_POLLSET_MU(&server->pollset)); - grpc_pollset_work(&server->pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), - deadline); + grpc_pollset_work(&exec_ctx, &server->pollset, &worker, + gpr_now(GPR_CLOCK_MONOTONIC), deadline); gpr_mu_unlock(GRPC_POLLSET_MU(&server->pollset)); + grpc_exec_ctx_finish(&exec_ctx); } void reconnect_server_clear_timestamps(reconnect_server *server) { @@ -152,12 +157,18 @@ void reconnect_server_clear_timestamps(reconnect_server *server) { server->peer = NULL; } -static void do_nothing(void *ignored) {} +static void do_nothing(grpc_exec_ctx *exec_ctx, void *ignored, int success) {} void reconnect_server_destroy(reconnect_server *server) { - grpc_tcp_server_destroy(server->tcp_server, do_nothing, NULL); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_closure do_nothing_closure[2]; + grpc_closure_init(&do_nothing_closure[0], do_nothing, NULL); + grpc_closure_init(&do_nothing_closure[1], do_nothing, NULL); + grpc_tcp_server_destroy(&exec_ctx, server->tcp_server, + &do_nothing_closure[0]); reconnect_server_clear_timestamps(server); - grpc_pollset_shutdown(&server->pollset, do_nothing, NULL); + grpc_pollset_shutdown(&exec_ctx, &server->pollset, &do_nothing_closure[1]); + grpc_exec_ctx_finish(&exec_ctx); grpc_pollset_destroy(&server->pollset); grpc_shutdown(); } |