aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-04-21 18:59:06 -0700
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-04-21 18:59:06 -0700
commit241dea56c8f3688c17c01c96edb497ab89fce582 (patch)
tree3ef5e77e8b593fabfe5114a3df4466561a531e21 /test/core
parent626f303eefd1f376357b71f8c811362f5b3f1e68 (diff)
parent7beea147e506b57a9656976001a1360e755a2e9b (diff)
Merge pull request #6147 from ctiller/strong-includes
Rollup of changes from latest import
Diffstat (limited to 'test/core')
-rw-r--r--test/core/iomgr/udp_server_test.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 463d40a46b..5248b613d7 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -33,6 +33,7 @@
#include "src/core/lib/iomgr/udp_server.h"
#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@@ -49,7 +50,7 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
-static grpc_pollset g_pollset;
+static grpc_pollset *g_pollset;
static gpr_mu *g_mu;
static int g_number_of_reads = 0;
static int g_number_of_bytes_read = 0;
@@ -60,12 +61,13 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
ssize_t byte_count;
gpr_mu_lock(g_mu);
- byte_count = recv(emfd->fd, read_buffer, sizeof(read_buffer), 0);
+ byte_count =
+ recv(grpc_fd_wrapped_fd(emfd), read_buffer, sizeof(read_buffer), 0);
g_number_of_reads++;
g_number_of_bytes_read += (int)byte_count;
- grpc_pollset_kick(&g_pollset, NULL);
+ grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(g_mu);
}
@@ -142,7 +144,7 @@ static void test_receive(int number_of_clients) {
GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)&addr, &addr_len) == 0);
GPR_ASSERT(addr_len <= sizeof(addr));
- pollsets[0] = &g_pollset;
+ pollsets[0] = g_pollset;
grpc_udp_server_start(&exec_ctx, s, pollsets, 1, NULL);
gpr_mu_lock(g_mu);
@@ -159,7 +161,7 @@ static void test_receive(int number_of_clients) {
while (g_number_of_reads == number_of_reads_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
grpc_pollset_worker *worker = NULL;
- grpc_pollset_work(&exec_ctx, &g_pollset, &worker,
+ grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline);
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
@@ -185,7 +187,8 @@ int main(int argc, char **argv) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- grpc_pollset_init(&g_pollset, &g_mu);
+ g_pollset = gpr_malloc(grpc_pollset_size());
+ grpc_pollset_init(g_pollset, &g_mu);
test_no_op();
test_no_op_with_start();
@@ -194,9 +197,10 @@ int main(int argc, char **argv) {
test_receive(1);
test_receive(10);
- grpc_closure_init(&destroyed, destroy_pollset, &g_pollset);
- grpc_pollset_shutdown(&exec_ctx, &g_pollset, &destroyed);
+ grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
+ grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx);
+ gpr_free(g_pollset);
grpc_iomgr_shutdown();
return 0;
}