aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-18 07:31:39 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-18 07:31:39 -0800
commit311445fd32956e9383823400c82ce3fcd71b2b31 (patch)
treef9eb12e617b6eb81b47f8e1eb1a15ab15339bb5e /test
parent9dc184fd9531e5e584047c05c829897611af261d (diff)
Fix tcp_client_posix_test
Diffstat (limited to 'test')
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 9725d8a3b6..b57478059f 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -45,6 +45,7 @@
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/socket_utils_posix.h"
+#include "src/core/iomgr/timer.h"
#include "test/core/util/test_config.h"
static grpc_pollset_set g_pollset_set;
@@ -125,11 +126,13 @@ void test_succeeds(void) {
gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5));
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
}
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+
+ grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
@@ -159,14 +162,18 @@ void test_fails(void) {
/* wait for the connection callback to finish */
while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker worker;
- grpc_pollset_work(&exec_ctx, &g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC), test_deadline());
+ gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
+ gpr_timespec polling_deadline = test_deadline();
+ if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+ grpc_pollset_work(&exec_ctx, &g_pollset, &worker, now, polling_deadline);
+ }
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
}
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ grpc_exec_ctx_finish(&exec_ctx);
}
void test_times_out(void) {
@@ -243,15 +250,18 @@ void test_times_out(void) {
GPR_ASSERT(g_connections_complete ==
connections_complete_before + is_after_deadline);
}
- grpc_pollset_work(&exec_ctx, &g_pollset, &worker,
- gpr_now(GPR_CLOCK_MONOTONIC),
- GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10));
+ gpr_timespec polling_deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10);
+ if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
+ grpc_pollset_work(&exec_ctx, &g_pollset, &worker, now, polling_deadline);
+ }
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
}
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
+ grpc_exec_ctx_finish(&exec_ctx);
+
close(svr_fd);
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
close(client_fd[i]);