|
|
|
@ -57,7 +57,7 @@ typedef struct freereq { |
|
|
|
|
|
|
|
|
|
static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p, |
|
|
|
|
bool success) { |
|
|
|
|
grpc_pollset *pollset = grpc_pops_pollset(p); |
|
|
|
|
grpc_pollset *pollset = grpc_polling_entity_pollset(p); |
|
|
|
|
grpc_pollset_destroy(pollset); |
|
|
|
|
gpr_free(pollset); |
|
|
|
|
grpc_shutdown(); |
|
|
|
@ -68,7 +68,7 @@ static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, |
|
|
|
|
freereq *pr = arg; |
|
|
|
|
gpr_mu_lock(pr->mu); |
|
|
|
|
pr->done = 1; |
|
|
|
|
grpc_pollset_kick(grpc_pops_pollset(&pr->pops), NULL); |
|
|
|
|
grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL); |
|
|
|
|
gpr_mu_unlock(pr->mu); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -87,7 +87,7 @@ void grpc_free_port_using_server(char *server, int port) { |
|
|
|
|
|
|
|
|
|
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size()); |
|
|
|
|
grpc_pollset_init(pollset, &pr.mu); |
|
|
|
|
pr.pops = grpc_pops_create_from_pollset(pollset); |
|
|
|
|
pr.pops = grpc_polling_entity_create_from_pollset(pollset); |
|
|
|
|
shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops); |
|
|
|
|
|
|
|
|
|
req.host = server; |
|
|
|
@ -101,7 +101,7 @@ void grpc_free_port_using_server(char *server, int port) { |
|
|
|
|
gpr_mu_lock(pr.mu); |
|
|
|
|
while (!pr.done) { |
|
|
|
|
grpc_pollset_worker *worker = NULL; |
|
|
|
|
grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&pr.pops), &worker, |
|
|
|
|
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), &worker, |
|
|
|
|
gpr_now(GPR_CLOCK_MONOTONIC), |
|
|
|
|
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); |
|
|
|
|
} |
|
|
|
@ -109,7 +109,7 @@ void grpc_free_port_using_server(char *server, int port) { |
|
|
|
|
|
|
|
|
|
grpc_httpcli_context_destroy(&context); |
|
|
|
|
grpc_exec_ctx_finish(&exec_ctx); |
|
|
|
|
grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(&pr.pops), |
|
|
|
|
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), |
|
|
|
|
shutdown_closure); |
|
|
|
|
grpc_exec_ctx_finish(&exec_ctx); |
|
|
|
|
gpr_free(path); |
|
|
|
@ -167,7 +167,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, |
|
|
|
|
GPR_ASSERT(port > 1024); |
|
|
|
|
gpr_mu_lock(pr->mu); |
|
|
|
|
pr->port = port; |
|
|
|
|
grpc_pollset_kick(grpc_pops_pollset(&pr->pops), NULL); |
|
|
|
|
grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL); |
|
|
|
|
gpr_mu_unlock(pr->mu); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -184,7 +184,7 @@ int grpc_pick_port_using_server(char *server) { |
|
|
|
|
memset(&req, 0, sizeof(req)); |
|
|
|
|
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size()); |
|
|
|
|
grpc_pollset_init(pollset, &pr.mu); |
|
|
|
|
pr.pops = grpc_pops_create_from_pollset(pollset); |
|
|
|
|
pr.pops = grpc_polling_entity_create_from_pollset(pollset); |
|
|
|
|
shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops); |
|
|
|
|
pr.port = -1; |
|
|
|
|
pr.server = server; |
|
|
|
@ -201,14 +201,14 @@ int grpc_pick_port_using_server(char *server) { |
|
|
|
|
gpr_mu_lock(pr.mu); |
|
|
|
|
while (pr.port == -1) { |
|
|
|
|
grpc_pollset_worker *worker = NULL; |
|
|
|
|
grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&pr.pops), &worker, |
|
|
|
|
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), &worker, |
|
|
|
|
gpr_now(GPR_CLOCK_MONOTONIC), |
|
|
|
|
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); |
|
|
|
|
} |
|
|
|
|
gpr_mu_unlock(pr.mu); |
|
|
|
|
|
|
|
|
|
grpc_httpcli_context_destroy(&context); |
|
|
|
|
grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(&pr.pops), |
|
|
|
|
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), |
|
|
|
|
shutdown_closure); |
|
|
|
|
grpc_exec_ctx_finish(&exec_ctx); |
|
|
|
|
|
|
|
|
|