diff options
author | Robbie Shade <rjshade@google.com> | 2015-07-15 14:16:48 -0400 |
---|---|---|
committer | Robbie Shade <rjshade@google.com> | 2015-07-15 14:16:48 -0400 |
commit | 1cef6dccded53c8394319220b4fca29802ef7eaa (patch) | |
tree | 1125e7e91b9eb6a7bbec3080a9f3c8fdb7b734a8 | |
parent | 4cde25cd016c732ff8a508ed3cb9715d818c8a07 (diff) |
Adding 10 client test, fiddling with pollsets
-rw-r--r-- | src/core/iomgr/udp_server.c | 6 | ||||
-rw-r--r-- | test/core/iomgr/udp_server_test.c | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c index eecaf27319..c8805d25ad 100644 --- a/src/core/iomgr/udp_server.c +++ b/src/core/iomgr/udp_server.c @@ -84,6 +84,11 @@ struct grpc_udp_server { /* shutdown callback */ void (*shutdown_complete)(void *); void *shutdown_complete_arg; + + /* all pollsets interested in new connections */ + grpc_pollset **pollsets; + /* number of pollsets in the pollsets array */ + size_t pollset_count; }; grpc_udp_server *grpc_udp_server_create(void) { @@ -368,6 +373,7 @@ void grpc_udp_server_start(grpc_udp_server *s, grpc_pollset **pollsets, GPR_ASSERT(s->active_ports == 0); s->cb = new_transport_cb; s->cb_arg = cb_arg; + s->pollsets = pollsets; for (i = 0; i < s->nports; i++) { for (j = 0; j < pollset_count; j++) { grpc_pollset_add_fd(pollsets[j], s->ports[i].emfd); diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index a7e7873738..ee7ef038f2 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -52,7 +52,10 @@ static void on_connect(void *arg, grpc_endpoint *udp) { } static void on_read(int fd, grpc_udp_server_cb new_transport_cb, void *cb_arg) { + gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); g_number_of_reads++; + grpc_pollset_kick(&g_pollset); + gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); } static void test_no_op(void) { @@ -110,9 +113,12 @@ static void test_receive(int n) { memset(&addr, 0, sizeof(addr)); addr.ss_family = AF_INET; GPR_ASSERT(grpc_udp_server_add_port(s, (struct sockaddr *)&addr, addr_len, on_read)); + pollsets[0] = &g_pollset; grpc_udp_server_start(s, pollsets, 1, on_connect, NULL); + gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); + for (i = 0; i < n; i++) { deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(4000); @@ -130,6 +136,8 @@ static void test_receive(int n) { close(clifd); } + gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); + grpc_udp_server_destroy(s, NULL, NULL); } @@ -145,6 +153,7 @@ int main(int argc, char **argv) { test_no_op_with_port(); test_no_op_with_port_and_start(); test_receive(1); + test_receive(10); grpc_pollset_shutdown(&g_pollset, destroy_pollset, &g_pollset); grpc_iomgr_shutdown(); |