aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-05-04 20:20:04 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2016-05-04 20:20:04 -0700
commit604490973b219aa69ee67c252173fa60cadb24b1 (patch)
treeed9687ef20163c61a33ba47cff16948c559f96c8 /test/core
parent261db111e638da413ce3f7e933571cfbe02874c2 (diff)
allocate grpc_pops on the stack
Diffstat (limited to 'test/core')
-rw-r--r--test/core/http/httpcli_test.c19
-rw-r--r--test/core/http/httpscli_test.c19
-rw-r--r--test/core/security/oauth2_utils.c13
-rw-r--r--test/core/security/print_google_default_creds_token.c11
-rw-r--r--test/core/util/port_server_client.c27
5 files changed, 42 insertions, 47 deletions
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index 6b9ec7fd94..e517e37102 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -48,7 +48,7 @@
static int g_done = 0;
static grpc_httpcli_context g_context;
static gpr_mu *g_mu;
-static grpc_pops *g_pops;
+static grpc_pops g_pops;
static gpr_timespec n_seconds_time(int seconds) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
@@ -66,7 +66,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
gpr_mu_lock(g_mu);
g_done = 1;
- grpc_pollset_kick(grpc_pops_pollset(g_pops), NULL);
+ grpc_pollset_kick(grpc_pops_pollset(&g_pops), NULL);
gpr_mu_unlock(g_mu);
}
@@ -86,12 +86,12 @@ static void test_get(int port) {
req.http.path = "/get";
req.handshaker = &grpc_httpcli_plaintext;
- grpc_httpcli_get(&exec_ctx, &g_context, g_pops, &req, n_seconds_time(15),
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, &req, n_seconds_time(15),
on_finish, (void *)42);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(g_pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&g_pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -117,12 +117,12 @@ static void test_post(int port) {
req.http.path = "/post";
req.handshaker = &grpc_httpcli_plaintext;
- grpc_httpcli_post(&exec_ctx, &g_context, g_pops, &req, "hello", 5,
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(g_pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&g_pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -188,13 +188,12 @@ int main(int argc, char **argv) {
test_post(port);
grpc_httpcli_context_destroy(&g_context);
- grpc_closure_init(&destroyed, destroy_pops, g_pops);
- grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(g_pops), &destroyed);
+ grpc_closure_init(&destroyed, destroy_pops, &g_pops);
+ grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(&g_pops), &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
- gpr_free(grpc_pops_pollset(g_pops));
- grpc_pops_destroy(g_pops);
+ gpr_free(grpc_pops_pollset(&g_pops));
gpr_subprocess_destroy(server);
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index ee2122e1c1..8943c492fb 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -48,7 +48,7 @@
static int g_done = 0;
static grpc_httpcli_context g_context;
static gpr_mu *g_mu;
-static grpc_pops *g_pops;
+static grpc_pops g_pops;
static gpr_timespec n_seconds_time(int seconds) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
@@ -66,7 +66,7 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
gpr_mu_lock(g_mu);
g_done = 1;
- grpc_pollset_kick(grpc_pops_pollset(g_pops), NULL);
+ grpc_pollset_kick(grpc_pops_pollset(&g_pops), NULL);
gpr_mu_unlock(g_mu);
}
@@ -87,12 +87,12 @@ static void test_get(int port) {
req.http.path = "/get";
req.handshaker = &grpc_httpcli_ssl;
- grpc_httpcli_get(&exec_ctx, &g_context, g_pops, &req, n_seconds_time(15),
+ grpc_httpcli_get(&exec_ctx, &g_context, &g_pops, &req, n_seconds_time(15),
on_finish, (void *)42);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(g_pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&g_pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -119,12 +119,12 @@ static void test_post(int port) {
req.http.path = "/post";
req.handshaker = &grpc_httpcli_ssl;
- grpc_httpcli_post(&exec_ctx, &g_context, g_pops, &req, "hello", 5,
+ grpc_httpcli_post(&exec_ctx, &g_context, &g_pops, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(g_pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&g_pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -191,13 +191,12 @@ int main(int argc, char **argv) {
test_post(port);
grpc_httpcli_context_destroy(&g_context);
- grpc_closure_init(&destroyed, destroy_pops, g_pops);
- grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(g_pops), &destroyed);
+ grpc_closure_init(&destroyed, destroy_pops, &g_pops);
+ grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(&g_pops), &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
- gpr_free(grpc_pops_pollset(g_pops));
- grpc_pops_destroy(g_pops);
+ gpr_free(grpc_pops_pollset(&g_pops));
gpr_subprocess_destroy(server);
diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c
index 2580757837..b3fe738e97 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.c
@@ -46,7 +46,7 @@
typedef struct {
gpr_mu *mu;
- grpc_pops *pops;
+ grpc_pops pops;
int is_done;
char *token;
} oauth2_request;
@@ -70,7 +70,7 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data,
gpr_mu_lock(request->mu);
request->is_done = 1;
request->token = token;
- grpc_pollset_kick(grpc_pops_pollset(request->pops), NULL);
+ grpc_pollset_kick(grpc_pops_pollset(&request->pops), NULL);
gpr_mu_unlock(request->mu);
}
@@ -90,23 +90,22 @@ char *grpc_test_fetch_oauth2_token_with_credentials(
grpc_closure_init(&do_nothing_closure, do_nothing, NULL);
grpc_call_credentials_get_request_metadata(
- &exec_ctx, creds, request.pops, null_ctx, on_oauth2_response, &request);
+ &exec_ctx, creds, &request.pops, null_ctx, on_oauth2_response, &request);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(request.mu);
while (!request.is_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(request.pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&request.pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(request.mu);
- grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(request.pops),
+ grpc_pollset_shutdown(&exec_ctx, grpc_pops_pollset(&request.pops),
&do_nothing_closure);
grpc_exec_ctx_finish(&exec_ctx);
- gpr_free(grpc_pops_pollset(request.pops));
- grpc_pops_destroy(request.pops);
+ gpr_free(grpc_pops_pollset(&request.pops));
return request.token;
}
diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c
index 4f5038c045..79e2549803 100644
--- a/test/core/security/print_google_default_creds_token.c
+++ b/test/core/security/print_google_default_creds_token.c
@@ -47,7 +47,7 @@
typedef struct {
gpr_mu *mu;
- grpc_pops *pops;
+ grpc_pops pops;
int is_done;
} synchronizer;
@@ -66,7 +66,7 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *user_data,
}
gpr_mu_lock(sync->mu);
sync->is_done = 1;
- grpc_pollset_kick(grpc_pops_pollset(sync->pops), NULL);
+ grpc_pollset_kick(grpc_pops_pollset(&sync->pops), NULL);
gpr_mu_unlock(sync->mu);
}
@@ -100,12 +100,12 @@ int main(int argc, char **argv) {
grpc_call_credentials_get_request_metadata(
&exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds,
- sync.pops, context, on_metadata_response, &sync);
+ &sync.pops, context, on_metadata_response, &sync);
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, grpc_pops_pollset(sync.pops), &worker,
+ grpc_pollset_work(&exec_ctx, grpc_pops_pollset(&sync.pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(sync.mu);
@@ -117,8 +117,7 @@ int main(int argc, char **argv) {
grpc_exec_ctx_finish(&exec_ctx);
grpc_channel_credentials_release(creds);
- gpr_free(grpc_pops_pollset(sync.pops));
- grpc_pops_destroy(sync.pops);
+ gpr_free(grpc_pops_pollset(&sync.pops));
end:
gpr_cmdline_destroy(cl);
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c
index e6cf35be94..1bdef6e82b 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.c
@@ -51,7 +51,7 @@
typedef struct freereq {
gpr_mu *mu;
- grpc_pops *pops;
+ grpc_pops pops;
int done;
} freereq;
@@ -60,7 +60,6 @@ static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p,
grpc_pollset *pollset = grpc_pops_pollset(p);
grpc_pollset_destroy(pollset);
gpr_free(pollset);
- grpc_pops_destroy(p);
grpc_shutdown();
}
@@ -69,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_pops_pollset(&pr->pops), NULL);
gpr_mu_unlock(pr->mu);
}
@@ -89,20 +88,20 @@ 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);
- shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, pr.pops);
+ shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops);
req.host = server;
gpr_asprintf(&path, "/drop/%d", port);
req.http.path = path;
grpc_httpcli_context_init(&context);
- grpc_httpcli_get(&exec_ctx, &context, pr.pops, &req,
+ grpc_httpcli_get(&exec_ctx, &context, &pr.pops, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), freed_port_from_server,
&pr);
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_pops_pollset(&pr.pops), &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1));
}
@@ -110,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_pops_pollset(&pr.pops),
shutdown_closure);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(path);
@@ -118,7 +117,7 @@ void grpc_free_port_using_server(char *server, int port) {
typedef struct portreq {
gpr_mu *mu;
- grpc_pops *pops;
+ grpc_pops pops;
int port;
int retries;
char *server;
@@ -154,7 +153,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
pr->retries++;
req.host = pr->server;
req.http.path = "/get";
- grpc_httpcli_get(exec_ctx, pr->ctx, pr->pops, &req,
+ grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server,
pr);
return;
@@ -168,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_pops_pollset(&pr->pops), NULL);
gpr_mu_unlock(pr->mu);
}
@@ -186,7 +185,7 @@ int grpc_pick_port_using_server(char *server) {
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_pops_create_from_pollset(pollset);
- shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, pr.pops);
+ shutdown_closure = grpc_closure_create(destroy_pops_and_shutdown, &pr.pops);
pr.port = -1;
pr.server = server;
pr.ctx = &context;
@@ -195,21 +194,21 @@ int grpc_pick_port_using_server(char *server) {
req.http.path = "/get";
grpc_httpcli_context_init(&context);
- grpc_httpcli_get(&exec_ctx, &context, pr.pops, &req,
+ grpc_httpcli_get(&exec_ctx, &context, &pr.pops, &req,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server,
&pr);
grpc_exec_ctx_finish(&exec_ctx);
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_pops_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_pops_pollset(&pr.pops),
shutdown_closure);
grpc_exec_ctx_finish(&exec_ctx);