diff options
Diffstat (limited to 'test/core/util/port_windows.c')
-rw-r--r-- | test/core/util/port_windows.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/test/core/util/port_windows.c b/test/core/util/port_windows.c index 3b20aeb718..b5bd0168ad 100644 --- a/test/core/util/port_windows.c +++ b/test/core/util/port_windows.c @@ -129,8 +129,7 @@ static int is_port_available(int *port, int is_tcp) { } typedef struct portreq { - grpc_pollset *pollset; - gpr_mu *mu; + grpc_pollset pollset; int port; } portreq; @@ -146,10 +145,10 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, port = port * 10 + response->body[i] - '0'; } GPR_ASSERT(port > 1024); - gpr_mu_lock(pr->mu); + gpr_mu_lock(GRPC_POLLSET_MU(&pr->pollset)); pr->port = port; - grpc_pollset_kick(pr->pollset, NULL); - gpr_mu_unlock(pr->mu); + grpc_pollset_kick(&pr->pollset, NULL); + gpr_mu_unlock(GRPC_POLLSET_MU(&pr->pollset)); } static void destroy_pollset_and_shutdown(grpc_exec_ctx *exec_ctx, void *p, @@ -169,34 +168,32 @@ static int pick_port_using_server(char *server) { memset(&pr, 0, sizeof(pr)); memset(&req, 0, sizeof(req)); - pr.pollset = gpr_malloc(grpc_pollset_size()); - grpc_pollset_init(pr.pollset, &pr.mu); + grpc_pollset_init(&pr.pollset); pr.port = -1; req.host = server; req.path = "/get"; grpc_httpcli_context_init(&context); - grpc_httpcli_get(&exec_ctx, &context, pr.pollset, &req, + grpc_httpcli_get(&exec_ctx, &context, &pr.pollset, &req, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server, &pr); - gpr_mu_lock(pr.mu); + gpr_mu_lock(GRPC_POLLSET_MU(&pr.pollset)); while (pr.port == -1) { grpc_pollset_worker *worker = NULL; - grpc_pollset_work(&exec_ctx, pr.pollset, &worker, + grpc_pollset_work(&exec_ctx, &pr.pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); - gpr_mu_unlock(pr.mu); + gpr_mu_unlock(GRPC_POLLSET_MU(&pr.pollset)); grpc_exec_ctx_flush(&exec_ctx); - gpr_mu_lock(pr.mu); + gpr_mu_lock(GRPC_POLLSET_MU(&pr.pollset)); } - gpr_mu_unlock(pr.mu); + gpr_mu_unlock(GRPC_POLLSET_MU(&pr.pollset)); grpc_httpcli_context_destroy(&context); grpc_closure_init(&destroy_pollset_closure, destroy_pollset_and_shutdown, &pr.pollset); - grpc_pollset_shutdown(&exec_ctx, pr.pollset, &destroy_pollset_closure); - gpr_free(pr.pollset); + grpc_pollset_shutdown(&exec_ctx, &pr.pollset, &destroy_pollset_closure); grpc_exec_ctx_finish(&exec_ctx); return pr.port; |