|
|
@ -67,7 +67,8 @@ class ServerThread { |
|
|
|
grpc_server_shutdown_and_notify(server_, shutdown_cq, nullptr); |
|
|
|
grpc_server_shutdown_and_notify(server_, shutdown_cq, nullptr); |
|
|
|
GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr, |
|
|
|
GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr, |
|
|
|
grpc_timeout_seconds_to_deadline(1), |
|
|
|
grpc_timeout_seconds_to_deadline(1), |
|
|
|
nullptr).type == GRPC_OP_COMPLETE); |
|
|
|
nullptr) |
|
|
|
|
|
|
|
.type == GRPC_OP_COMPLETE); |
|
|
|
grpc_completion_queue_destroy(shutdown_cq); |
|
|
|
grpc_completion_queue_destroy(shutdown_cq); |
|
|
|
grpc_server_destroy(server_); |
|
|
|
grpc_server_destroy(server_); |
|
|
|
grpc_completion_queue_destroy(cq_); |
|
|
|
grpc_completion_queue_destroy(cq_); |
|
|
@ -98,8 +99,8 @@ class Client { |
|
|
|
void Connect() { |
|
|
|
void Connect() { |
|
|
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
|
|
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
|
|
|
grpc_resolved_addresses* server_addresses = nullptr; |
|
|
|
grpc_resolved_addresses* server_addresses = nullptr; |
|
|
|
grpc_error* error = grpc_blocking_resolve_address(server_address_, |
|
|
|
grpc_error* error = |
|
|
|
"80", &server_addresses); |
|
|
|
grpc_blocking_resolve_address(server_address_, "80", &server_addresses); |
|
|
|
ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_string(error); |
|
|
|
ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_string(error); |
|
|
|
ASSERT_GE(server_addresses->naddrs, 1UL); |
|
|
|
ASSERT_GE(server_addresses->naddrs, 1UL); |
|
|
|
pollset_ = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); |
|
|
|
pollset_ = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); |
|
|
@ -107,12 +108,12 @@ class Client { |
|
|
|
grpc_pollset_set* pollset_set = grpc_pollset_set_create(); |
|
|
|
grpc_pollset_set* pollset_set = grpc_pollset_set_create(); |
|
|
|
grpc_pollset_set_add_pollset(&exec_ctx, pollset_set, pollset_); |
|
|
|
grpc_pollset_set_add_pollset(&exec_ctx, pollset_set, pollset_); |
|
|
|
EventState state; |
|
|
|
EventState state; |
|
|
|
grpc_tcp_client_connect(&exec_ctx, state.closure(), &endpoint_, |
|
|
|
grpc_tcp_client_connect(&exec_ctx, state.closure(), &endpoint_, pollset_set, |
|
|
|
pollset_set, nullptr /* channel_args */, |
|
|
|
nullptr /* channel_args */, server_addresses->addrs, |
|
|
|
server_addresses->addrs, 1000); |
|
|
|
1000); |
|
|
|
ASSERT_TRUE(PollUntilDone(&exec_ctx, &state, |
|
|
|
ASSERT_TRUE(PollUntilDone( |
|
|
|
grpc_timespec_to_millis_round_up( |
|
|
|
&exec_ctx, &state, |
|
|
|
gpr_inf_future(GPR_CLOCK_MONOTONIC)))); |
|
|
|
grpc_timespec_to_millis_round_up(gpr_inf_future(GPR_CLOCK_MONOTONIC)))); |
|
|
|
ASSERT_EQ(GRPC_ERROR_NONE, state.error()); |
|
|
|
ASSERT_EQ(GRPC_ERROR_NONE, state.error()); |
|
|
|
grpc_pollset_set_destroy(&exec_ctx, pollset_set); |
|
|
|
grpc_pollset_set_destroy(&exec_ctx, pollset_set); |
|
|
|
grpc_endpoint_add_to_pollset(&exec_ctx, endpoint_, pollset_); |
|
|
|
grpc_endpoint_add_to_pollset(&exec_ctx, endpoint_, pollset_); |
|
|
@ -195,8 +196,7 @@ class Client { |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
grpc_pollset_worker* worker = nullptr; |
|
|
|
grpc_pollset_worker* worker = nullptr; |
|
|
|
gpr_mu_lock(mu_); |
|
|
|
gpr_mu_lock(mu_); |
|
|
|
GRPC_LOG_IF_ERROR( |
|
|
|
GRPC_LOG_IF_ERROR("grpc_pollset_work", |
|
|
|
"grpc_pollset_work", |
|
|
|
|
|
|
|
grpc_pollset_work(exec_ctx, pollset_, &worker, |
|
|
|
grpc_pollset_work(exec_ctx, pollset_, &worker, |
|
|
|
grpc_exec_ctx_now(exec_ctx) + 1000)); |
|
|
|
grpc_exec_ctx_now(exec_ctx) + 1000)); |
|
|
|
gpr_mu_unlock(mu_); |
|
|
|
gpr_mu_unlock(mu_); |
|
|
|