aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/iomgr/tcp_client_posix_test.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-25 15:34:55 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-25 15:34:55 -0800
commit8be227840333e3766cbdbc477d7ebc8bfe6c3d10 (patch)
treecc2029c6ca1a053e44c72f0a3a263fb3e9bf74d9 /test/core/iomgr/tcp_client_posix_test.c
parentee821bb10bca90c5a39d042349be1f8c8d01a289 (diff)
parente2a8a3f45ceb63bcb4c039aa2a53cb5deb7d4767 (diff)
Merge branch 'hide-the-pollset-set' into cleaner-posix2
Diffstat (limited to 'test/core/iomgr/tcp_client_posix_test.c')
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 51581a8cb0..ac666080fe 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -51,7 +51,7 @@
#include "test/core/util/test_config.h"
static grpc_pollset_set *g_pollset_set;
-static gpr_mu g_mu;
+static gpr_mu *g_mu;
static grpc_pollset *g_pollset;
static int g_connections_complete = 0;
static grpc_endpoint *g_connecting = NULL;
@@ -61,10 +61,10 @@ static gpr_timespec test_deadline(void) {
}
static void finish_connection() {
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
g_connections_complete++;
grpc_pollset_kick(g_pollset, NULL);
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
}
static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
@@ -102,9 +102,9 @@ void test_succeeds(void) {
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr *)&addr, addr_len));
GPR_ASSERT(0 == listen(svr_fd, 1));
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
connections_complete_before = g_connections_complete;
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0);
@@ -121,19 +121,19 @@ void test_succeeds(void) {
GPR_ASSERT(r >= 0);
close(r);
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5));
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
}
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -150,9 +150,9 @@ void test_fails(void) {
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
connections_complete_before = g_connections_complete;
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
/* connect to a broken address */
grpc_closure_init(&done, must_fail, NULL);
@@ -160,7 +160,7 @@ void test_fails(void) {
(struct sockaddr *)&addr, addr_len,
gpr_inf_future(GPR_CLOCK_REALTIME));
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
/* wait for the connection callback to finish */
while (g_connections_complete == connections_complete_before) {
@@ -170,12 +170,12 @@ void test_fails(void) {
if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
grpc_pollset_work(&exec_ctx, g_pollset, &worker, now, polling_deadline);
}
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
}
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -220,16 +220,16 @@ void test_times_out(void) {
connect_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
connections_complete_before = g_connections_complete;
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_closure_init(&done, must_fail, NULL);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set,
(struct sockaddr *)&addr, addr_len, connect_deadline);
/* Make sure the event doesn't trigger early */
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
for (;;) {
grpc_pollset_worker *worker = NULL;
gpr_timespec now = gpr_now(connect_deadline.clock_type);
@@ -257,11 +257,11 @@ void test_times_out(void) {
if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
grpc_pollset_work(&exec_ctx, g_pollset, &worker, now, polling_deadline);
}
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_flush(&exec_ctx);
- gpr_mu_lock(&g_mu);
+ gpr_mu_lock(g_mu);
}
- gpr_mu_unlock(&g_mu);
+ gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -282,7 +282,6 @@ int main(int argc, char **argv) {
grpc_init();
g_pollset_set = grpc_pollset_set_create();
g_pollset = gpr_malloc(grpc_pollset_size());
- gpr_mu_init(&g_mu);
grpc_pollset_init(g_pollset, &g_mu);
grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset);
grpc_exec_ctx_finish(&exec_ctx);
@@ -296,6 +295,5 @@ int main(int argc, char **argv) {
grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(g_pollset);
- gpr_mu_destroy(&g_mu);
return 0;
}