aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/iomgr/udp_server_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/iomgr/udp_server_test.c')
-rw-r--r--test/core/iomgr/udp_server_test.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index ce3c23b4bf..5248b613d7 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,24 +31,26 @@
*
*/
-#include "src/core/iomgr/iomgr.h"
-#include "src/core/iomgr/pollset_posix.h"
-#include "src/core/iomgr/udp_server.h"
+#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>
+#include "src/core/lib/iomgr/ev_posix.h"
+#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/test_config.h"
-#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
+#include <sys/socket.h>
#include <unistd.h>
#ifdef GRPC_NEED_UDP
#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;
@@ -59,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);
}
@@ -141,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);
@@ -158,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);
@@ -184,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();
@@ -193,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;
}