From dbb4f942d05321e7c29f67ee1057aca7238d1f3a Mon Sep 17 00:00:00 2001 From: David Klempner Date: Wed, 21 Jan 2015 17:45:18 -0800 Subject: [PATCH 1/5] Add support for eventfd based kicking on linux. This adds support for eventfd based kicking, with the skeleton of support for runtime selection between eventfds and pipes. --- Makefile | 5 + build.json | 2 + include/grpc/support/port_platform.h | 1 + src/core/iomgr/pollset_kick.h | 4 + src/core/iomgr/pollset_kick_eventfd.c | 85 ++++++++++++ src/core/iomgr/pollset_kick_eventfd.h | 42 ++++++ src/core/iomgr/pollset_kick_posix.c | 172 ++++++++++++++---------- src/core/iomgr/pollset_kick_posix.h | 15 ++- test/core/iomgr/poll_kick_test.c | 16 ++- vsprojects/vs2013/grpc.vcxproj | 3 + vsprojects/vs2013/grpc_unsecure.vcxproj | 3 + 11 files changed, 270 insertions(+), 78 deletions(-) create mode 100644 src/core/iomgr/pollset_kick_eventfd.c create mode 100644 src/core/iomgr/pollset_kick_eventfd.h diff --git a/Makefile b/Makefile index 1fefcfd09fe..85f38cb0cfb 100644 --- a/Makefile +++ b/Makefile @@ -1354,6 +1354,7 @@ LIBGRPC_SRC = \ src/core/iomgr/iomgr.c \ src/core/iomgr/iomgr_posix.c \ src/core/iomgr/pollset_kick_posix.c \ + src/core/iomgr/pollset_kick_eventfd.c \ src/core/iomgr/pollset_multipoller_with_poll_posix.c \ src/core/iomgr/pollset_posix.c \ src/core/iomgr/resolve_address_posix.c \ @@ -1472,6 +1473,7 @@ src/core/iomgr/fd_posix.c: $(OPENSSL_DEP) src/core/iomgr/iomgr.c: $(OPENSSL_DEP) src/core/iomgr/iomgr_posix.c: $(OPENSSL_DEP) src/core/iomgr/pollset_kick_posix.c: $(OPENSSL_DEP) +src/core/iomgr/pollset_kick_eventfd.c: $(OPENSSL_DEP) src/core/iomgr/pollset_multipoller_with_poll_posix.c: $(OPENSSL_DEP) src/core/iomgr/pollset_posix.c: $(OPENSSL_DEP) src/core/iomgr/resolve_address_posix.c: $(OPENSSL_DEP) @@ -1607,6 +1609,7 @@ objs/$(CONFIG)/src/core/iomgr/fd_posix.o: objs/$(CONFIG)/src/core/iomgr/iomgr.o: objs/$(CONFIG)/src/core/iomgr/iomgr_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_kick_posix.o: +objs/$(CONFIG)/src/core/iomgr/pollset_kick_eventfd.o: objs/$(CONFIG)/src/core/iomgr/pollset_multipoller_with_poll_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_posix.o: objs/$(CONFIG)/src/core/iomgr/resolve_address_posix.o: @@ -1762,6 +1765,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/iomgr/iomgr.c \ src/core/iomgr/iomgr_posix.c \ src/core/iomgr/pollset_kick_posix.c \ + src/core/iomgr/pollset_kick_eventfd.c \ src/core/iomgr/pollset_multipoller_with_poll_posix.c \ src/core/iomgr/pollset_posix.c \ src/core/iomgr/resolve_address_posix.c \ @@ -1880,6 +1884,7 @@ objs/$(CONFIG)/src/core/iomgr/fd_posix.o: objs/$(CONFIG)/src/core/iomgr/iomgr.o: objs/$(CONFIG)/src/core/iomgr/iomgr_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_kick_posix.o: +objs/$(CONFIG)/src/core/iomgr/pollset_kick_eventfd.o: objs/$(CONFIG)/src/core/iomgr/pollset_multipoller_with_poll_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_posix.o: objs/$(CONFIG)/src/core/iomgr/resolve_address_posix.o: diff --git a/build.json b/build.json index 9a5134ecd6a..f6d7f518930 100644 --- a/build.json +++ b/build.json @@ -48,6 +48,7 @@ "src/core/iomgr/pollset.h", "src/core/iomgr/pollset_kick.h", "src/core/iomgr/pollset_kick_posix.h", + "src/core/iomgr/pollset_kick_eventfd.h", "src/core/iomgr/pollset_posix.h", "src/core/iomgr/resolve_address.h", "src/core/iomgr/sockaddr.h", @@ -124,6 +125,7 @@ "src/core/iomgr/iomgr.c", "src/core/iomgr/iomgr_posix.c", "src/core/iomgr/pollset_kick_posix.c", + "src/core/iomgr/pollset_kick_eventfd.c", "src/core/iomgr/pollset_multipoller_with_poll_posix.c", "src/core/iomgr/pollset_posix.c", "src/core/iomgr/resolve_address_posix.c", diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 05a5bbe1bc9..488f1aeadbb 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -68,6 +68,7 @@ #define GPR_GCC_ATOMIC 1 #define GPR_LINUX 1 #define GPR_POSIX_MULTIPOLL_WITH_POLL 1 +#define GPR_LINUX_EVENTFD 1 #define GPR_POSIX_SOCKET 1 #define GPR_POSIX_SOCKETADDR 1 #define GPR_POSIX_STRING 1 diff --git a/src/core/iomgr/pollset_kick.h b/src/core/iomgr/pollset_kick.h index f088818b9a1..4459a31b4ff 100644 --- a/src/core/iomgr/pollset_kick.h +++ b/src/core/iomgr/pollset_kick.h @@ -48,6 +48,10 @@ void grpc_pollset_kick_global_init(void); void grpc_pollset_kick_global_destroy(void); +/* Guarantees a pure posix implementation rather than a specialized one, if + * applicable. Intended for testing. */ +void grpc_pollset_kick_global_init_posix(void); + void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state); void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state); diff --git a/src/core/iomgr/pollset_kick_eventfd.c b/src/core/iomgr/pollset_kick_eventfd.c new file mode 100644 index 00000000000..301ebad8758 --- /dev/null +++ b/src/core/iomgr/pollset_kick_eventfd.c @@ -0,0 +1,85 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/iomgr/pollset_kick_eventfd.h" + +#ifdef GPR_LINUX_EVENTFD +#include +#include +#include + +#include +#include + +static void eventfd_create(grpc_kick_fd_info *fd_info) { + int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); + /* TODO(klempner): Handle failure more gracefully */ + GPR_ASSERT(efd >= 0); + fd_info->read_fd = efd; + fd_info->write_fd = -1; +} + +static void eventfd_consume(grpc_kick_fd_info *fd_info) { + eventfd_t value; + int err; + do { + err = eventfd_read(fd_info->read_fd, &value); + } while (err < 0 && errno == EINTR); +} + +static void eventfd_kick(grpc_kick_fd_info *fd_info) { + int err; + do { + err = eventfd_write(fd_info->read_fd, 1); + } while (err < 0 && errno == EINTR); +} + +static void eventfd_destroy(grpc_kick_fd_info *fd_info) { + close(fd_info->read_fd); +} + +static const grpc_pollset_kick_vtable eventfd_kick_vtable = { + eventfd_create, eventfd_consume, eventfd_kick, eventfd_destroy +}; + +const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void) { + /* TODO(klempner): Check that eventfd works */ + return &eventfd_kick_vtable; +} + +#else /* GPR_LINUX_EVENTFD not defined */ +const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void) { + return NULL; +} + +#endif /* GPR_LINUX_EVENTFD */ diff --git a/src/core/iomgr/pollset_kick_eventfd.h b/src/core/iomgr/pollset_kick_eventfd.h new file mode 100644 index 00000000000..f06f7f65ec3 --- /dev/null +++ b/src/core/iomgr/pollset_kick_eventfd.h @@ -0,0 +1,42 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ +#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ + +#include "src/core/iomgr/pollset_kick_posix.h" + +/* Tries to enable eventfd support, returns a kick vtable if successful. */ +const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void); + +#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ */ diff --git a/src/core/iomgr/pollset_kick_posix.c b/src/core/iomgr/pollset_kick_posix.c index 9f85b6137af..4e3ee25dc7e 100644 --- a/src/core/iomgr/pollset_kick_posix.c +++ b/src/core/iomgr/pollset_kick_posix.c @@ -37,6 +37,7 @@ #include #include +#include "src/core/iomgr/pollset_kick_eventfd.h" #include "src/core/iomgr/socket_utils_posix.h" #include #include @@ -46,82 +47,58 @@ #define GRPC_MAX_CACHED_PIPES 50 #define GRPC_PIPE_LOW_WATERMARK 25 -typedef struct grpc_kick_pipe_info { - int pipe_read_fd; - int pipe_write_fd; - struct grpc_kick_pipe_info *next; -} grpc_kick_pipe_info; - -static grpc_kick_pipe_info *pipe_freelist = NULL; -static int pipe_freelist_count = 0; -static gpr_mu pipe_freelist_mu; - -static grpc_kick_pipe_info *allocate_pipe(void) { - grpc_kick_pipe_info *info; - gpr_mu_lock(&pipe_freelist_mu); - if (pipe_freelist != NULL) { - info = pipe_freelist; - pipe_freelist = pipe_freelist->next; - --pipe_freelist_count; +static grpc_kick_fd_info *fd_freelist = NULL; +static int fd_freelist_count = 0; +static gpr_mu fd_freelist_mu; +static const grpc_pollset_kick_vtable *kick_vtable = NULL; + +static grpc_kick_fd_info *allocate_pipe(void) { + grpc_kick_fd_info *info; + gpr_mu_lock(&fd_freelist_mu); + if (fd_freelist != NULL) { + info = fd_freelist; + fd_freelist = fd_freelist->next; + --fd_freelist_count; } else { - int pipefd[2]; - /* TODO(klempner): Make this nonfatal */ - GPR_ASSERT(0 == pipe(pipefd)); - GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); - GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); info = gpr_malloc(sizeof(*info)); - info->pipe_read_fd = pipefd[0]; - info->pipe_write_fd = pipefd[1]; + kick_vtable->create(info); info->next = NULL; } - gpr_mu_unlock(&pipe_freelist_mu); + gpr_mu_unlock(&fd_freelist_mu); return info; } static void destroy_pipe(void) { - /* assumes pipe_freelist_mu is held */ - grpc_kick_pipe_info *current = pipe_freelist; - pipe_freelist = pipe_freelist->next; - pipe_freelist_count--; - close(current->pipe_read_fd); - close(current->pipe_write_fd); + /* assumes fd_freelist_mu is held */ + grpc_kick_fd_info *current = fd_freelist; + fd_freelist = fd_freelist->next; + fd_freelist_count--; + kick_vtable->destroy(current); gpr_free(current); } -static void free_pipe(grpc_kick_pipe_info *pipe_info) { - gpr_mu_lock(&pipe_freelist_mu); - pipe_info->next = pipe_freelist; - pipe_freelist = pipe_info; - pipe_freelist_count++; - if (pipe_freelist_count > GRPC_MAX_CACHED_PIPES) { - while (pipe_freelist_count > GRPC_PIPE_LOW_WATERMARK) { +static void free_pipe(grpc_kick_fd_info *fd_info) { + gpr_mu_lock(&fd_freelist_mu); + fd_info->next = fd_freelist; + fd_freelist = fd_info; + fd_freelist_count++; + if (fd_freelist_count > GRPC_MAX_CACHED_PIPES) { + while (fd_freelist_count > GRPC_PIPE_LOW_WATERMARK) { destroy_pipe(); } } - gpr_mu_unlock(&pipe_freelist_mu); -} - -void grpc_pollset_kick_global_init() { - pipe_freelist = NULL; - gpr_mu_init(&pipe_freelist_mu); -} - -void grpc_pollset_kick_global_destroy() { - while (pipe_freelist != NULL) { - destroy_pipe(); - } - gpr_mu_destroy(&pipe_freelist_mu); + gpr_mu_unlock(&fd_freelist_mu); } void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state) { gpr_mu_init(&kick_state->mu); kick_state->kicked = 0; - kick_state->pipe_info = NULL; + kick_state->fd_info = NULL; } void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state) { gpr_mu_destroy(&kick_state->mu); - GPR_ASSERT(kick_state->pipe_info == NULL); + GPR_ASSERT(kick_state->fd_info == NULL); } int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { @@ -131,17 +108,48 @@ int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { gpr_mu_unlock(&kick_state->mu); return -1; } - kick_state->pipe_info = allocate_pipe(); + kick_state->fd_info = allocate_pipe(); gpr_mu_unlock(&kick_state->mu); - return kick_state->pipe_info->pipe_read_fd; + return kick_state->fd_info->read_fd; } void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state) { + kick_vtable->consume(kick_state->fd_info); +} + +void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state) { + gpr_mu_lock(&kick_state->mu); + free_pipe(kick_state->fd_info); + kick_state->fd_info = NULL; + gpr_mu_unlock(&kick_state->mu); +} + +void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state) { + gpr_mu_lock(&kick_state->mu); + if (kick_state->fd_info != NULL) { + kick_vtable->kick(kick_state->fd_info); + } else { + kick_state->kicked = 1; + } + gpr_mu_unlock(&kick_state->mu); +} + +static void pipe_create(grpc_kick_fd_info *fd_info) { + int pipefd[2]; + /* TODO(klempner): Make this nonfatal */ + GPR_ASSERT(0 == pipe(pipefd)); + GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); + GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); + fd_info->read_fd = pipefd[0]; + fd_info->write_fd = pipefd[1]; +} + +static void pipe_consume(grpc_kick_fd_info *fd_info) { char buf[128]; int r; for (;;) { - r = read(kick_state->pipe_info->pipe_read_fd, buf, sizeof(buf)); + r = read(fd_info->read_fd, buf, sizeof(buf)); if (r > 0) continue; if (r == 0) return; switch (errno) { @@ -156,22 +164,44 @@ void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state) { } } -void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state) { - gpr_mu_lock(&kick_state->mu); - free_pipe(kick_state->pipe_info); - kick_state->pipe_info = NULL; - gpr_mu_unlock(&kick_state->mu); +static void pipe_kick(grpc_kick_fd_info *fd_info) { + char c = 0; + while (write(fd_info->write_fd, &c, 1) != 1 && errno == EINTR) + ; } -void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state) { - gpr_mu_lock(&kick_state->mu); - if (kick_state->pipe_info != NULL) { - char c = 0; - while (write(kick_state->pipe_info->pipe_write_fd, &c, 1) != 1 && - errno == EINTR) - ; - } else { - kick_state->kicked = 1; +static void pipe_destroy(grpc_kick_fd_info *fd_info) { + close(fd_info->read_fd); + close(fd_info->write_fd); +} + +static const grpc_pollset_kick_vtable pipe_kick_vtable = { + pipe_create, pipe_consume, pipe_kick, pipe_destroy +}; + +static void global_init_common(void) { + fd_freelist = NULL; + gpr_mu_init(&fd_freelist_mu); +} + +void grpc_pollset_kick_global_init_posix(void) { + global_init_common(); + kick_vtable = &pipe_kick_vtable; +} + +void grpc_pollset_kick_global_init(void) { + global_init_common(); + kick_vtable = grpc_pollset_kick_eventfd_init(); + if (kick_vtable == NULL) { + kick_vtable = &pipe_kick_vtable; } - gpr_mu_unlock(&kick_state->mu); } + +void grpc_pollset_kick_global_destroy(void) { + while (fd_freelist != NULL) { + destroy_pipe(); + } + gpr_mu_destroy(&fd_freelist_mu); +} + + diff --git a/src/core/iomgr/pollset_kick_posix.h b/src/core/iomgr/pollset_kick_posix.h index bae3b5923a2..5eb49987607 100644 --- a/src/core/iomgr/pollset_kick_posix.h +++ b/src/core/iomgr/pollset_kick_posix.h @@ -36,12 +36,23 @@ #include -struct grpc_kick_pipe_info; +typedef struct grpc_kick_fd_info { + int read_fd; + int write_fd; + struct grpc_kick_fd_info *next; +} grpc_kick_fd_info; + +typedef struct grpc_pollset_kick_vtable { + void (*create)(struct grpc_kick_fd_info *fd_info); + void (*consume)(struct grpc_kick_fd_info *fd_info); + void (*kick)(struct grpc_kick_fd_info *fd_info); + void (*destroy)(struct grpc_kick_fd_info *fd_info); +} grpc_pollset_kick_vtable; typedef struct grpc_pollset_kick_state { gpr_mu mu; int kicked; - struct grpc_kick_pipe_info *pipe_info; + struct grpc_kick_fd_info *fd_info; } grpc_pollset_kick_state; #endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ */ diff --git a/test/core/iomgr/poll_kick_test.c b/test/core/iomgr/poll_kick_test.c index c30a7b9ee0a..b1d134d746f 100644 --- a/test/core/iomgr/poll_kick_test.c +++ b/test/core/iomgr/poll_kick_test.c @@ -107,17 +107,23 @@ static void test_over_free(void) { } } -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - - grpc_pollset_kick_global_init(); - +static void run_tests(void) { test_allocation(); test_basic_kick(); test_non_poll_kick(); test_non_kick(); test_over_free(); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + + grpc_pollset_kick_global_init(); + run_tests(); + grpc_pollset_kick_global_destroy(); + grpc_pollset_kick_global_init_posix(); + run_tests(); grpc_pollset_kick_global_destroy(); return 0; } diff --git a/vsprojects/vs2013/grpc.vcxproj b/vsprojects/vs2013/grpc.vcxproj index 05a9966c0e0..cdfe2b391ea 100644 --- a/vsprojects/vs2013/grpc.vcxproj +++ b/vsprojects/vs2013/grpc.vcxproj @@ -121,6 +121,7 @@ + @@ -250,6 +251,8 @@ + + diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj b/vsprojects/vs2013/grpc_unsecure.vcxproj index 05a9966c0e0..cdfe2b391ea 100644 --- a/vsprojects/vs2013/grpc_unsecure.vcxproj +++ b/vsprojects/vs2013/grpc_unsecure.vcxproj @@ -121,6 +121,7 @@ + @@ -250,6 +251,8 @@ + + From 78dc6cdaeb533cb03cd8a3b3bea6e6d7847083aa Mon Sep 17 00:00:00 2001 From: David Klempner Date: Mon, 26 Jan 2015 15:02:51 -0800 Subject: [PATCH 2/5] Refactor the pipe/eventfd abstraction This introduces the wakeup fd interface, corresponding approximately to the existing Google version, complete with a ported giant detailed usage comment. The implementation has two layers, "specialized" and "fallback". The specialized layer is intended to be a suitable platform specific implementation like eventfd, whereas "fallback" is probably pipe, with runtime detection of whether the specialized version works on this system (currently stubbed out). --- Makefile | 35 ++++-- build.json | 10 +- include/grpc/support/port_platform.h | 1 + .../{pollset_kick_posix.c => pollset_kick.c} | 104 ++++-------------- src/core/iomgr/pollset_kick.h | 26 +++-- src/core/iomgr/wakeup_fd.c | 70 ++++++++++++ src/core/iomgr/wakeup_fd.h | 102 +++++++++++++++++ ...set_kick_eventfd.c => wakeup_fd_eventfd.c} | 31 +++--- ...set_kick_posix.h => wakeup_fd_nospecial.c} | 35 +++--- src/core/iomgr/wakeup_fd_pipe.c | 93 ++++++++++++++++ ...ollset_kick_eventfd.h => wakeup_fd_pipe.h} | 11 +- test/core/iomgr/poll_kick_test.c | 2 +- vsprojects/vs2013/grpc.vcxproj | 15 ++- vsprojects/vs2013/grpc_unsecure.vcxproj | 15 ++- 14 files changed, 391 insertions(+), 159 deletions(-) rename src/core/iomgr/{pollset_kick_posix.c => pollset_kick.c} (60%) create mode 100644 src/core/iomgr/wakeup_fd.c create mode 100644 src/core/iomgr/wakeup_fd.h rename src/core/iomgr/{pollset_kick_eventfd.c => wakeup_fd_eventfd.c} (76%) rename src/core/iomgr/{pollset_kick_posix.h => wakeup_fd_nospecial.c} (68%) create mode 100644 src/core/iomgr/wakeup_fd_pipe.c rename src/core/iomgr/{pollset_kick_eventfd.h => wakeup_fd_pipe.h} (81%) diff --git a/Makefile b/Makefile index 85f38cb0cfb..51c7786f0ff 100644 --- a/Makefile +++ b/Makefile @@ -1353,8 +1353,7 @@ LIBGRPC_SRC = \ src/core/iomgr/fd_posix.c \ src/core/iomgr/iomgr.c \ src/core/iomgr/iomgr_posix.c \ - src/core/iomgr/pollset_kick_posix.c \ - src/core/iomgr/pollset_kick_eventfd.c \ + src/core/iomgr/pollset_kick.c \ src/core/iomgr/pollset_multipoller_with_poll_posix.c \ src/core/iomgr/pollset_posix.c \ src/core/iomgr/resolve_address_posix.c \ @@ -1366,6 +1365,10 @@ LIBGRPC_SRC = \ src/core/iomgr/tcp_posix.c \ src/core/iomgr/tcp_server_posix.c \ src/core/iomgr/time_averaged_stats.c \ + src/core/iomgr/wakeup_fd.c \ + src/core/iomgr/wakeup_fd_eventfd.c \ + src/core/iomgr/wakeup_fd_nospecial.c \ + src/core/iomgr/wakeup_fd_pipe.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ @@ -1472,8 +1475,7 @@ src/core/iomgr/endpoint_pair_posix.c: $(OPENSSL_DEP) src/core/iomgr/fd_posix.c: $(OPENSSL_DEP) src/core/iomgr/iomgr.c: $(OPENSSL_DEP) src/core/iomgr/iomgr_posix.c: $(OPENSSL_DEP) -src/core/iomgr/pollset_kick_posix.c: $(OPENSSL_DEP) -src/core/iomgr/pollset_kick_eventfd.c: $(OPENSSL_DEP) +src/core/iomgr/pollset_kick.c: $(OPENSSL_DEP) src/core/iomgr/pollset_multipoller_with_poll_posix.c: $(OPENSSL_DEP) src/core/iomgr/pollset_posix.c: $(OPENSSL_DEP) src/core/iomgr/resolve_address_posix.c: $(OPENSSL_DEP) @@ -1485,6 +1487,10 @@ src/core/iomgr/tcp_client_posix.c: $(OPENSSL_DEP) src/core/iomgr/tcp_posix.c: $(OPENSSL_DEP) src/core/iomgr/tcp_server_posix.c: $(OPENSSL_DEP) src/core/iomgr/time_averaged_stats.c: $(OPENSSL_DEP) +src/core/iomgr/wakeup_fd.c: $(OPENSSL_DEP) +src/core/iomgr/wakeup_fd_eventfd.c: $(OPENSSL_DEP) +src/core/iomgr/wakeup_fd_nospecial.c: $(OPENSSL_DEP) +src/core/iomgr/wakeup_fd_pipe.c: $(OPENSSL_DEP) src/core/statistics/census_init.c: $(OPENSSL_DEP) src/core/statistics/census_log.c: $(OPENSSL_DEP) src/core/statistics/census_rpc_stats.c: $(OPENSSL_DEP) @@ -1608,8 +1614,7 @@ objs/$(CONFIG)/src/core/iomgr/endpoint_pair_posix.o: objs/$(CONFIG)/src/core/iomgr/fd_posix.o: objs/$(CONFIG)/src/core/iomgr/iomgr.o: objs/$(CONFIG)/src/core/iomgr/iomgr_posix.o: -objs/$(CONFIG)/src/core/iomgr/pollset_kick_posix.o: -objs/$(CONFIG)/src/core/iomgr/pollset_kick_eventfd.o: +objs/$(CONFIG)/src/core/iomgr/pollset_kick.o: objs/$(CONFIG)/src/core/iomgr/pollset_multipoller_with_poll_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_posix.o: objs/$(CONFIG)/src/core/iomgr/resolve_address_posix.o: @@ -1621,6 +1626,10 @@ objs/$(CONFIG)/src/core/iomgr/tcp_client_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_server_posix.o: objs/$(CONFIG)/src/core/iomgr/time_averaged_stats.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_eventfd.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_nospecial.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_pipe.o: objs/$(CONFIG)/src/core/statistics/census_init.o: objs/$(CONFIG)/src/core/statistics/census_log.o: objs/$(CONFIG)/src/core/statistics/census_rpc_stats.o: @@ -1764,8 +1773,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/iomgr/fd_posix.c \ src/core/iomgr/iomgr.c \ src/core/iomgr/iomgr_posix.c \ - src/core/iomgr/pollset_kick_posix.c \ - src/core/iomgr/pollset_kick_eventfd.c \ + src/core/iomgr/pollset_kick.c \ src/core/iomgr/pollset_multipoller_with_poll_posix.c \ src/core/iomgr/pollset_posix.c \ src/core/iomgr/resolve_address_posix.c \ @@ -1777,6 +1785,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/iomgr/tcp_posix.c \ src/core/iomgr/tcp_server_posix.c \ src/core/iomgr/time_averaged_stats.c \ + src/core/iomgr/wakeup_fd.c \ + src/core/iomgr/wakeup_fd_eventfd.c \ + src/core/iomgr/wakeup_fd_nospecial.c \ + src/core/iomgr/wakeup_fd_pipe.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ @@ -1883,8 +1895,7 @@ objs/$(CONFIG)/src/core/iomgr/endpoint_pair_posix.o: objs/$(CONFIG)/src/core/iomgr/fd_posix.o: objs/$(CONFIG)/src/core/iomgr/iomgr.o: objs/$(CONFIG)/src/core/iomgr/iomgr_posix.o: -objs/$(CONFIG)/src/core/iomgr/pollset_kick_posix.o: -objs/$(CONFIG)/src/core/iomgr/pollset_kick_eventfd.o: +objs/$(CONFIG)/src/core/iomgr/pollset_kick.o: objs/$(CONFIG)/src/core/iomgr/pollset_multipoller_with_poll_posix.o: objs/$(CONFIG)/src/core/iomgr/pollset_posix.o: objs/$(CONFIG)/src/core/iomgr/resolve_address_posix.o: @@ -1896,6 +1907,10 @@ objs/$(CONFIG)/src/core/iomgr/tcp_client_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_server_posix.o: objs/$(CONFIG)/src/core/iomgr/time_averaged_stats.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_eventfd.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_nospecial.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_pipe.o: objs/$(CONFIG)/src/core/statistics/census_init.o: objs/$(CONFIG)/src/core/statistics/census_log.o: objs/$(CONFIG)/src/core/statistics/census_rpc_stats.o: diff --git a/build.json b/build.json index f6d7f518930..17187ecfc2d 100644 --- a/build.json +++ b/build.json @@ -47,8 +47,6 @@ "src/core/iomgr/iomgr_posix.h", "src/core/iomgr/pollset.h", "src/core/iomgr/pollset_kick.h", - "src/core/iomgr/pollset_kick_posix.h", - "src/core/iomgr/pollset_kick_eventfd.h", "src/core/iomgr/pollset_posix.h", "src/core/iomgr/resolve_address.h", "src/core/iomgr/sockaddr.h", @@ -60,6 +58,7 @@ "src/core/iomgr/tcp_posix.h", "src/core/iomgr/tcp_server.h", "src/core/iomgr/time_averaged_stats.h", + "src/core/iomgr/wakeup_fd.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_log.h", "src/core/statistics/census_rpc_stats.h", @@ -124,8 +123,7 @@ "src/core/iomgr/fd_posix.c", "src/core/iomgr/iomgr.c", "src/core/iomgr/iomgr_posix.c", - "src/core/iomgr/pollset_kick_posix.c", - "src/core/iomgr/pollset_kick_eventfd.c", + "src/core/iomgr/pollset_kick.c", "src/core/iomgr/pollset_multipoller_with_poll_posix.c", "src/core/iomgr/pollset_posix.c", "src/core/iomgr/resolve_address_posix.c", @@ -137,6 +135,10 @@ "src/core/iomgr/tcp_posix.c", "src/core/iomgr/tcp_server_posix.c", "src/core/iomgr/time_averaged_stats.c", + "src/core/iomgr/wakeup_fd.c", + "src/core/iomgr/wakeup_fd_eventfd.c", + "src/core/iomgr/wakeup_fd_nospecial.c", + "src/core/iomgr/wakeup_fd_pipe.c", "src/core/statistics/census_init.c", "src/core/statistics/census_log.c", "src/core/statistics/census_rpc_stats.c", diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 488f1aeadbb..d6723289ad0 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -68,6 +68,7 @@ #define GPR_GCC_ATOMIC 1 #define GPR_LINUX 1 #define GPR_POSIX_MULTIPOLL_WITH_POLL 1 +#define GPR_POSIX_HAS_SPECIAL_WAKEUP_FD 1 #define GPR_LINUX_EVENTFD 1 #define GPR_POSIX_SOCKET 1 #define GPR_POSIX_SOCKETADDR 1 diff --git a/src/core/iomgr/pollset_kick_posix.c b/src/core/iomgr/pollset_kick.c similarity index 60% rename from src/core/iomgr/pollset_kick_posix.c rename to src/core/iomgr/pollset_kick.c index 4e3ee25dc7e..f863207cf1a 100644 --- a/src/core/iomgr/pollset_kick_posix.c +++ b/src/core/iomgr/pollset_kick.c @@ -31,28 +31,28 @@ * */ -#include "src/core/iomgr/pollset_kick_posix.h" +#include "src/core/iomgr/pollset_kick.h" #include #include #include -#include "src/core/iomgr/pollset_kick_eventfd.h" #include "src/core/iomgr/socket_utils_posix.h" +#include "src/core/iomgr/wakeup_fd.h" #include #include -/* This implementation is based on a freelist of pipes. */ +/* This implementation is based on a freelist of wakeup fds, with extra logic to + * handle kicks while there is no attached fd. */ -#define GRPC_MAX_CACHED_PIPES 50 -#define GRPC_PIPE_LOW_WATERMARK 25 +#define GRPC_MAX_CACHED_WFDS 50 +#define GRPC_WFD_LOW_WATERMARK 25 static grpc_kick_fd_info *fd_freelist = NULL; static int fd_freelist_count = 0; static gpr_mu fd_freelist_mu; -static const grpc_pollset_kick_vtable *kick_vtable = NULL; -static grpc_kick_fd_info *allocate_pipe(void) { +static grpc_kick_fd_info *allocate_wfd(void) { grpc_kick_fd_info *info; gpr_mu_lock(&fd_freelist_mu); if (fd_freelist != NULL) { @@ -61,30 +61,30 @@ static grpc_kick_fd_info *allocate_pipe(void) { --fd_freelist_count; } else { info = gpr_malloc(sizeof(*info)); - kick_vtable->create(info); + grpc_wakeup_fd_create(&info->wakeup_fd); info->next = NULL; } gpr_mu_unlock(&fd_freelist_mu); return info; } -static void destroy_pipe(void) { +static void destroy_wfd(void) { /* assumes fd_freelist_mu is held */ grpc_kick_fd_info *current = fd_freelist; fd_freelist = fd_freelist->next; fd_freelist_count--; - kick_vtable->destroy(current); + grpc_wakeup_fd_destroy(¤t->wakeup_fd); gpr_free(current); } -static void free_pipe(grpc_kick_fd_info *fd_info) { +static void free_wfd(grpc_kick_fd_info *fd_info) { gpr_mu_lock(&fd_freelist_mu); fd_info->next = fd_freelist; fd_freelist = fd_info; fd_freelist_count++; - if (fd_freelist_count > GRPC_MAX_CACHED_PIPES) { - while (fd_freelist_count > GRPC_PIPE_LOW_WATERMARK) { - destroy_pipe(); + if (fd_freelist_count > GRPC_MAX_CACHED_WFDS) { + while (fd_freelist_count > GRPC_WFD_LOW_WATERMARK) { + destroy_wfd(); } } gpr_mu_unlock(&fd_freelist_mu); @@ -108,18 +108,18 @@ int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { gpr_mu_unlock(&kick_state->mu); return -1; } - kick_state->fd_info = allocate_pipe(); + kick_state->fd_info = allocate_wfd(); gpr_mu_unlock(&kick_state->mu); - return kick_state->fd_info->read_fd; + return GRPC_WAKEUP_FD_FD(&kick_state->fd_info->wakeup_fd); } void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state) { - kick_vtable->consume(kick_state->fd_info); + grpc_wakeup_fd_consume_wakeup(&kick_state->fd_info->wakeup_fd); } void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state) { gpr_mu_lock(&kick_state->mu); - free_pipe(kick_state->fd_info); + free_wfd(kick_state->fd_info); kick_state->fd_info = NULL; gpr_mu_unlock(&kick_state->mu); } @@ -127,81 +127,23 @@ void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state) { void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state) { gpr_mu_lock(&kick_state->mu); if (kick_state->fd_info != NULL) { - kick_vtable->kick(kick_state->fd_info); + grpc_wakeup_fd_wakeup(&kick_state->fd_info->wakeup_fd); } else { kick_state->kicked = 1; } gpr_mu_unlock(&kick_state->mu); } -static void pipe_create(grpc_kick_fd_info *fd_info) { - int pipefd[2]; - /* TODO(klempner): Make this nonfatal */ - GPR_ASSERT(0 == pipe(pipefd)); - GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); - GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); - fd_info->read_fd = pipefd[0]; - fd_info->write_fd = pipefd[1]; -} - -static void pipe_consume(grpc_kick_fd_info *fd_info) { - char buf[128]; - int r; - - for (;;) { - r = read(fd_info->read_fd, buf, sizeof(buf)); - if (r > 0) continue; - if (r == 0) return; - switch (errno) { - case EAGAIN: - return; - case EINTR: - continue; - default: - gpr_log(GPR_ERROR, "error reading pipe: %s", strerror(errno)); - return; - } - } -} - -static void pipe_kick(grpc_kick_fd_info *fd_info) { - char c = 0; - while (write(fd_info->write_fd, &c, 1) != 1 && errno == EINTR) - ; -} - -static void pipe_destroy(grpc_kick_fd_info *fd_info) { - close(fd_info->read_fd); - close(fd_info->write_fd); -} - -static const grpc_pollset_kick_vtable pipe_kick_vtable = { - pipe_create, pipe_consume, pipe_kick, pipe_destroy -}; - -static void global_init_common(void) { - fd_freelist = NULL; - gpr_mu_init(&fd_freelist_mu); -} - -void grpc_pollset_kick_global_init_posix(void) { - global_init_common(); - kick_vtable = &pipe_kick_vtable; +void grpc_pollset_kick_global_init_fallback_fd(void) { + grpc_wakeup_fd_global_init_force_fallback(); } void grpc_pollset_kick_global_init(void) { - global_init_common(); - kick_vtable = grpc_pollset_kick_eventfd_init(); - if (kick_vtable == NULL) { - kick_vtable = &pipe_kick_vtable; - } + grpc_wakeup_fd_global_init(); } void grpc_pollset_kick_global_destroy(void) { - while (fd_freelist != NULL) { - destroy_pipe(); - } - gpr_mu_destroy(&fd_freelist_mu); + grpc_wakeup_fd_global_destroy(); } diff --git a/src/core/iomgr/pollset_kick.h b/src/core/iomgr/pollset_kick.h index 4459a31b4ff..5e909312611 100644 --- a/src/core/iomgr/pollset_kick.h +++ b/src/core/iomgr/pollset_kick.h @@ -34,27 +34,33 @@ #ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ #define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ -#include +#include "src/core/iomgr/wakeup_fd.h" +#include /* This is an abstraction around the typical pipe mechanism for waking up a thread sitting in a poll() style call. */ -#ifdef GPR_POSIX_SOCKET -#include "src/core/iomgr/pollset_kick_posix.h" -#else -#error "No pollset kick support on platform" -#endif +typedef struct grpc_kick_fd_info { + grpc_wakeup_fd_info wakeup_fd; + struct grpc_kick_fd_info *next; +} grpc_kick_fd_info; + +typedef struct grpc_pollset_kick_state { + gpr_mu mu; + int kicked; + struct grpc_kick_fd_info *fd_info; +} grpc_pollset_kick_state; void grpc_pollset_kick_global_init(void); void grpc_pollset_kick_global_destroy(void); -/* Guarantees a pure posix implementation rather than a specialized one, if - * applicable. Intended for testing. */ -void grpc_pollset_kick_global_init_posix(void); - void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state); void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state); +/* Guarantees a pure posix implementation rather than a specialized one, if + * applicable. Intended for testing. */ +void grpc_pollset_kick_global_init_fallback_fd(void); + /* Must be called before entering poll(). If return value is -1, this consumed an existing kick. Otherwise the return value is an FD to add to the poll set. */ diff --git a/src/core/iomgr/wakeup_fd.c b/src/core/iomgr/wakeup_fd.c new file mode 100644 index 00000000000..b81707f2a02 --- /dev/null +++ b/src/core/iomgr/wakeup_fd.c @@ -0,0 +1,70 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_pipe.h" +#include + +static const grpc_wakeup_fd_vtable *wakeup_fd_vtable = NULL; + +void grpc_wakeup_fd_global_init(void) { + if (specialized_wakeup_fd_vtable.check_availability()) { + wakeup_fd_vtable = &specialized_wakeup_fd_vtable; + } else { + wakeup_fd_vtable = &pipe_wakeup_fd_vtable; + } +} + +void grpc_wakeup_fd_global_init_force_fallback(void) { + wakeup_fd_vtable = &pipe_wakeup_fd_vtable; +} + +void grpc_wakeup_fd_global_destroy(void) { + wakeup_fd_vtable = NULL; +} + +void grpc_wakeup_fd_create(grpc_wakeup_fd_info *fd_info) { + wakeup_fd_vtable->create(fd_info); +} + +void grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd_info *fd_info) { + wakeup_fd_vtable->consume(fd_info); +} + +void grpc_wakeup_fd_wakeup(grpc_wakeup_fd_info *fd_info) { + wakeup_fd_vtable->wakeup(fd_info); +} + +void grpc_wakeup_fd_destroy(grpc_wakeup_fd_info *fd_info) { + wakeup_fd_vtable->destroy(fd_info); +} diff --git a/src/core/iomgr/wakeup_fd.h b/src/core/iomgr/wakeup_fd.h new file mode 100644 index 00000000000..225291ca601 --- /dev/null +++ b/src/core/iomgr/wakeup_fd.h @@ -0,0 +1,102 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * wakeup_fd abstracts the concept of a file descriptor for the purpose of + * waking up a thread in select()/poll()/epoll_wait()/etc. + + * The poll() family of system calls provide a way for a thread to block until + * there is activity on one (or more) of a set of file descriptors. An + * application may wish to wake up this thread to do non file related work. The + * typical way to do this is to add a pipe to the set of file descriptors, then + * write to the pipe to wake up the thread in poll(). + * + * Linux has a lighter weight eventfd specifically designed for this purpose. + * wakeup_fd abstracts the difference between the two. + * + * Setup: + * 1. Before calling anything, call global_init() at least once. + * 1. Call grpc_wakeup_fd_create() to get a wakeup_fd. + * 2. Add the result of GRPC_WAKEUP_FD_FD to the set of monitored file + * descriptors for the poll() style API you are using. Monitor the file + * descriptor for readability. + * 3. To tear down, call grpc_wakeup_fd_destroy(). This closes the underlying + * file descriptor. + * + * Usage: + * 1. To wake up a polling thread, call grpc_wakeup_fd_wakeup() on a wakeup_fd + * it is monitoring. + * 2. If the polling thread was awakened by a wakeup_fd event, call + * grpc_wakeup_fd_consume_wakeup() on it. + */ +#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ +#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ + +typedef struct grpc_wakeup_fd_info grpc_wakeup_fd_info; + +void grpc_wakeup_fd_global_init(void); +void grpc_wakeup_fd_global_destroy(void); + + +void grpc_wakeup_fd_create(grpc_wakeup_fd_info *fd_info); +void grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd_info *fd_info); +void grpc_wakeup_fd_wakeup(grpc_wakeup_fd_info *fd_info); +void grpc_wakeup_fd_destroy(grpc_wakeup_fd_info *fd_info); + +#define GRPC_WAKEUP_FD_FD(fd_info) ((fd_info)->read_fd) + +/* Force using the fallback implementation. This is intended for testing + * purposes only.*/ +void grpc_wakeup_fd_global_init_force_fallback(void); + +/* Private structures; don't access their fields directly outside of wakeup fd + * code. */ +struct grpc_wakeup_fd_info { + int read_fd; + int write_fd; +}; + +typedef struct grpc_wakeup_fd_vtable { + void (*create)(grpc_wakeup_fd_info *fd_info); + void (*consume)(grpc_wakeup_fd_info *fd_info); + void (*wakeup)(grpc_wakeup_fd_info *fd_info); + void (*destroy)(grpc_wakeup_fd_info *fd_info); + /* Must be called before calling any other functions */ + int (*check_availability)(void); +} grpc_wakeup_fd_vtable; + +/* Defined in some specialized implementation's .c file, or by + * wakeup_fd_nospecial.c if no such implementation exists. */ +extern const grpc_wakeup_fd_vtable specialized_wakeup_fd_vtable; + +#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ */ diff --git a/src/core/iomgr/pollset_kick_eventfd.c b/src/core/iomgr/wakeup_fd_eventfd.c similarity index 76% rename from src/core/iomgr/pollset_kick_eventfd.c rename to src/core/iomgr/wakeup_fd_eventfd.c index 301ebad8758..4c495e675a6 100644 --- a/src/core/iomgr/pollset_kick_eventfd.c +++ b/src/core/iomgr/wakeup_fd_eventfd.c @@ -31,17 +31,18 @@ * */ -#include "src/core/iomgr/pollset_kick_eventfd.h" +#include #ifdef GPR_LINUX_EVENTFD + #include #include #include -#include +#include "src/core/iomgr/wakeup_fd.h" #include -static void eventfd_create(grpc_kick_fd_info *fd_info) { +static void eventfd_create(grpc_wakeup_fd_info *fd_info) { int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); /* TODO(klempner): Handle failure more gracefully */ GPR_ASSERT(efd >= 0); @@ -49,7 +50,7 @@ static void eventfd_create(grpc_kick_fd_info *fd_info) { fd_info->write_fd = -1; } -static void eventfd_consume(grpc_kick_fd_info *fd_info) { +static void eventfd_consume(grpc_wakeup_fd_info *fd_info) { eventfd_t value; int err; do { @@ -57,29 +58,25 @@ static void eventfd_consume(grpc_kick_fd_info *fd_info) { } while (err < 0 && errno == EINTR); } -static void eventfd_kick(grpc_kick_fd_info *fd_info) { +static void eventfd_wakeup(grpc_wakeup_fd_info *fd_info) { int err; do { err = eventfd_write(fd_info->read_fd, 1); } while (err < 0 && errno == EINTR); } -static void eventfd_destroy(grpc_kick_fd_info *fd_info) { +static void eventfd_destroy(grpc_wakeup_fd_info *fd_info) { close(fd_info->read_fd); } -static const grpc_pollset_kick_vtable eventfd_kick_vtable = { - eventfd_create, eventfd_consume, eventfd_kick, eventfd_destroy -}; - -const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void) { - /* TODO(klempner): Check that eventfd works */ - return &eventfd_kick_vtable; +static int eventfd_check_availability(void) { + /* TODO(klempner): Actually check if eventfd is available */ + return 1; } -#else /* GPR_LINUX_EVENTFD not defined */ -const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void) { - return NULL; -} +const grpc_wakeup_fd_vtable specialized_wakeup_fd_vtable = { + eventfd_create, eventfd_consume, eventfd_wakeup, eventfd_destroy, + eventfd_check_availability +}; #endif /* GPR_LINUX_EVENTFD */ diff --git a/src/core/iomgr/pollset_kick_posix.h b/src/core/iomgr/wakeup_fd_nospecial.c similarity index 68% rename from src/core/iomgr/pollset_kick_posix.h rename to src/core/iomgr/wakeup_fd_nospecial.c index 5eb49987607..21e8074d50e 100644 --- a/src/core/iomgr/pollset_kick_posix.h +++ b/src/core/iomgr/wakeup_fd_nospecial.c @@ -31,28 +31,23 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ +/* + * This is a dummy file to provide an invalid specialized_wakeup_fd_vtable on + * systems without anything better than pipe. + */ + +#include -#include +#ifndef GPR_POSIX_HAS_SPECIAL_WAKEUP_FD -typedef struct grpc_kick_fd_info { - int read_fd; - int write_fd; - struct grpc_kick_fd_info *next; -} grpc_kick_fd_info; +#include "src/core/iomgr/wakeup_fd.h" -typedef struct grpc_pollset_kick_vtable { - void (*create)(struct grpc_kick_fd_info *fd_info); - void (*consume)(struct grpc_kick_fd_info *fd_info); - void (*kick)(struct grpc_kick_fd_info *fd_info); - void (*destroy)(struct grpc_kick_fd_info *fd_info); -} grpc_pollset_kick_vtable; +static int check_availability_invalid(void) { + return 0; +} -typedef struct grpc_pollset_kick_state { - gpr_mu mu; - int kicked; - struct grpc_kick_fd_info *fd_info; -} grpc_pollset_kick_state; +const grpc_wakeup_fd_vtable specialized_wakeup_fd_vtable = { + NULL, NULL, NULL, NULL, check_availability_invalid +}; -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ */ +#endif /* GPR_POSIX_HAS_SPECIAL_WAKEUP */ diff --git a/src/core/iomgr/wakeup_fd_pipe.c b/src/core/iomgr/wakeup_fd_pipe.c new file mode 100644 index 00000000000..f8a0aeb606c --- /dev/null +++ b/src/core/iomgr/wakeup_fd_pipe.c @@ -0,0 +1,93 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* TODO(klempner): Allow this code to be disabled. */ +#include "src/core/iomgr/wakeup_fd.h" + +#include +#include +#include + +#include "src/core/iomgr/socket_utils_posix.h" +#include + +static void pipe_create(grpc_wakeup_fd_info *fd_info) { + int pipefd[2]; + /* TODO(klempner): Make this nonfatal */ + GPR_ASSERT(0 == pipe(pipefd)); + GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); + GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); + fd_info->read_fd = pipefd[0]; + fd_info->write_fd = pipefd[1]; +} + +static void pipe_consume(grpc_wakeup_fd_info *fd_info) { + char buf[128]; + int r; + + for (;;) { + r = read(fd_info->read_fd, buf, sizeof(buf)); + if (r > 0) continue; + if (r == 0) return; + switch (errno) { + case EAGAIN: + return; + case EINTR: + continue; + default: + gpr_log(GPR_ERROR, "error reading pipe: %s", strerror(errno)); + return; + } + } +} + +static void pipe_wakeup(grpc_wakeup_fd_info *fd_info) { + char c = 0; + while (write(fd_info->write_fd, &c, 1) != 1 && errno == EINTR) + ; +} + +static void pipe_destroy(grpc_wakeup_fd_info *fd_info) { + close(fd_info->read_fd); + close(fd_info->write_fd); +} + +static int pipe_check_availability(void) { + /* Assume that pipes are always available. */ + return 1; +} + +const grpc_wakeup_fd_vtable pipe_wakeup_fd_vtable = { + pipe_create, pipe_consume, pipe_wakeup, pipe_destroy, pipe_check_availability +}; + diff --git a/src/core/iomgr/pollset_kick_eventfd.h b/src/core/iomgr/wakeup_fd_pipe.h similarity index 81% rename from src/core/iomgr/pollset_kick_eventfd.h rename to src/core/iomgr/wakeup_fd_pipe.h index f06f7f65ec3..8e2ed85885b 100644 --- a/src/core/iomgr/pollset_kick_eventfd.h +++ b/src/core/iomgr/wakeup_fd_pipe.h @@ -31,12 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ +#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ +#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ -#include "src/core/iomgr/pollset_kick_posix.h" +#include "src/core/iomgr/wakeup_fd.h" -/* Tries to enable eventfd support, returns a kick vtable if successful. */ -const grpc_pollset_kick_vtable *grpc_pollset_kick_eventfd_init(void); +extern grpc_wakeup_fd_vtable pipe_wakeup_fd_vtable; -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_EVENTFD_H_ */ +#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ */ diff --git a/test/core/iomgr/poll_kick_test.c b/test/core/iomgr/poll_kick_test.c index b1d134d746f..3c6d815c9de 100644 --- a/test/core/iomgr/poll_kick_test.c +++ b/test/core/iomgr/poll_kick_test.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) { run_tests(); grpc_pollset_kick_global_destroy(); - grpc_pollset_kick_global_init_posix(); + grpc_pollset_kick_global_init_fallback_fd(); run_tests(); grpc_pollset_kick_global_destroy(); return 0; diff --git a/vsprojects/vs2013/grpc.vcxproj b/vsprojects/vs2013/grpc.vcxproj index cdfe2b391ea..8cec7944395 100644 --- a/vsprojects/vs2013/grpc.vcxproj +++ b/vsprojects/vs2013/grpc.vcxproj @@ -120,8 +120,6 @@ - - @@ -133,6 +131,7 @@ + @@ -249,9 +248,7 @@ - - - + @@ -275,6 +272,14 @@ + + + + + + + + diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj b/vsprojects/vs2013/grpc_unsecure.vcxproj index cdfe2b391ea..8cec7944395 100644 --- a/vsprojects/vs2013/grpc_unsecure.vcxproj +++ b/vsprojects/vs2013/grpc_unsecure.vcxproj @@ -120,8 +120,6 @@ - - @@ -133,6 +131,7 @@ + @@ -249,9 +248,7 @@ - - - + @@ -275,6 +272,14 @@ + + + + + + + + From 8bfbc88d5f2b05bc9e703b96bfe4831521e71f1d Mon Sep 17 00:00:00 2001 From: David Klempner Date: Mon, 26 Jan 2015 17:23:33 -0800 Subject: [PATCH 3/5] Rename wakeup_fd.[hc] to wakeup_fd_posix.[hc] Fix the transitive closure of this change, including reintroducing pollset_kick_posix/windows where the latter is just a stub. --- Makefile | 10 ++-- build.json | 7 ++- src/core/iomgr/pollset_kick.c | 2 +- src/core/iomgr/pollset_kick.h | 22 ++++---- src/core/iomgr/pollset_kick_posix.h | 51 +++++++++++++++++++ src/core/iomgr/pollset_kick_windows.h | 45 ++++++++++++++++ src/core/iomgr/wakeup_fd_eventfd.c | 2 +- src/core/iomgr/wakeup_fd_pipe.c | 2 +- src/core/iomgr/wakeup_fd_pipe.h | 2 +- .../iomgr/{wakeup_fd.c => wakeup_fd_posix.c} | 2 +- .../iomgr/{wakeup_fd.h => wakeup_fd_posix.h} | 6 +-- vsprojects/vs2013/grpc.vcxproj | 9 ++-- vsprojects/vs2013/grpc.vcxproj.filters | 17 +++++-- vsprojects/vs2013/grpc_unsecure.vcxproj | 9 ++-- .../vs2013/grpc_unsecure.vcxproj.filters | 17 +++++-- 15 files changed, 161 insertions(+), 42 deletions(-) create mode 100644 src/core/iomgr/pollset_kick_posix.h create mode 100644 src/core/iomgr/pollset_kick_windows.h rename src/core/iomgr/{wakeup_fd.c => wakeup_fd_posix.c} (98%) rename src/core/iomgr/{wakeup_fd.h => wakeup_fd_posix.h} (96%) diff --git a/Makefile b/Makefile index bb7f613eefa..763d340bba6 100644 --- a/Makefile +++ b/Makefile @@ -1405,10 +1405,10 @@ LIBGRPC_SRC = \ src/core/iomgr/tcp_posix.c \ src/core/iomgr/tcp_server_posix.c \ src/core/iomgr/time_averaged_stats.c \ - src/core/iomgr/wakeup_fd.c \ src/core/iomgr/wakeup_fd_eventfd.c \ src/core/iomgr/wakeup_fd_nospecial.c \ src/core/iomgr/wakeup_fd_pipe.c \ + src/core/iomgr/wakeup_fd_posix.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ @@ -1528,10 +1528,10 @@ src/core/iomgr/tcp_client_posix.c: $(OPENSSL_DEP) src/core/iomgr/tcp_posix.c: $(OPENSSL_DEP) src/core/iomgr/tcp_server_posix.c: $(OPENSSL_DEP) src/core/iomgr/time_averaged_stats.c: $(OPENSSL_DEP) -src/core/iomgr/wakeup_fd.c: $(OPENSSL_DEP) src/core/iomgr/wakeup_fd_eventfd.c: $(OPENSSL_DEP) src/core/iomgr/wakeup_fd_nospecial.c: $(OPENSSL_DEP) src/core/iomgr/wakeup_fd_pipe.c: $(OPENSSL_DEP) +src/core/iomgr/wakeup_fd_posix.c: $(OPENSSL_DEP) src/core/statistics/census_init.c: $(OPENSSL_DEP) src/core/statistics/census_log.c: $(OPENSSL_DEP) src/core/statistics/census_rpc_stats.c: $(OPENSSL_DEP) @@ -1672,10 +1672,10 @@ objs/$(CONFIG)/src/core/iomgr/tcp_client_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_server_posix.o: objs/$(CONFIG)/src/core/iomgr/time_averaged_stats.o: -objs/$(CONFIG)/src/core/iomgr/wakeup_fd.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_eventfd.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_nospecial.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_pipe.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_posix.o: objs/$(CONFIG)/src/core/statistics/census_init.o: objs/$(CONFIG)/src/core/statistics/census_log.o: objs/$(CONFIG)/src/core/statistics/census_rpc_stats.o: @@ -1836,10 +1836,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/iomgr/tcp_posix.c \ src/core/iomgr/tcp_server_posix.c \ src/core/iomgr/time_averaged_stats.c \ - src/core/iomgr/wakeup_fd.c \ src/core/iomgr/wakeup_fd_eventfd.c \ src/core/iomgr/wakeup_fd_nospecial.c \ src/core/iomgr/wakeup_fd_pipe.c \ + src/core/iomgr/wakeup_fd_posix.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ @@ -1963,10 +1963,10 @@ objs/$(CONFIG)/src/core/iomgr/tcp_client_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_posix.o: objs/$(CONFIG)/src/core/iomgr/tcp_server_posix.o: objs/$(CONFIG)/src/core/iomgr/time_averaged_stats.o: -objs/$(CONFIG)/src/core/iomgr/wakeup_fd.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_eventfd.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_nospecial.o: objs/$(CONFIG)/src/core/iomgr/wakeup_fd_pipe.o: +objs/$(CONFIG)/src/core/iomgr/wakeup_fd_posix.o: objs/$(CONFIG)/src/core/statistics/census_init.o: objs/$(CONFIG)/src/core/statistics/census_log.o: objs/$(CONFIG)/src/core/statistics/census_rpc_stats.o: diff --git a/build.json b/build.json index bd3f26dd0a4..85973d3eeaf 100644 --- a/build.json +++ b/build.json @@ -47,6 +47,8 @@ "src/core/iomgr/iomgr_posix.h", "src/core/iomgr/pollset.h", "src/core/iomgr/pollset_kick.h", + "src/core/iomgr/pollset_kick_posix.h", + "src/core/iomgr/pollset_kick_windows.h", "src/core/iomgr/pollset_posix.h", "src/core/iomgr/pollset_windows.h", "src/core/iomgr/resolve_address.h", @@ -59,7 +61,8 @@ "src/core/iomgr/tcp_posix.h", "src/core/iomgr/tcp_server.h", "src/core/iomgr/time_averaged_stats.h", - "src/core/iomgr/wakeup_fd.h", + "src/core/iomgr/wakeup_fd_posix.h", + "src/core/iomgr/wakeup_fd_pipe.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_log.h", "src/core/statistics/census_rpc_stats.h", @@ -137,10 +140,10 @@ "src/core/iomgr/tcp_posix.c", "src/core/iomgr/tcp_server_posix.c", "src/core/iomgr/time_averaged_stats.c", - "src/core/iomgr/wakeup_fd.c", "src/core/iomgr/wakeup_fd_eventfd.c", "src/core/iomgr/wakeup_fd_nospecial.c", "src/core/iomgr/wakeup_fd_pipe.c", + "src/core/iomgr/wakeup_fd_posix.c", "src/core/statistics/census_init.c", "src/core/statistics/census_log.c", "src/core/statistics/census_rpc_stats.c", diff --git a/src/core/iomgr/pollset_kick.c b/src/core/iomgr/pollset_kick.c index 9158f9077ca..e4a9caf97a6 100644 --- a/src/core/iomgr/pollset_kick.c +++ b/src/core/iomgr/pollset_kick.c @@ -41,7 +41,7 @@ #include #include "src/core/iomgr/socket_utils_posix.h" -#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_posix.h" #include #include diff --git a/src/core/iomgr/pollset_kick.h b/src/core/iomgr/pollset_kick.h index 5e909312611..b224177d317 100644 --- a/src/core/iomgr/pollset_kick.h +++ b/src/core/iomgr/pollset_kick.h @@ -34,22 +34,18 @@ #ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ #define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ -#include "src/core/iomgr/wakeup_fd.h" -#include +#include -/* This is an abstraction around the typical pipe mechanism for waking up a - thread sitting in a poll() style call. */ +#ifdef GPR_POSIX_SOCKET +#include "src/core/iomgr/pollset_kick_posix.h" +#endif -typedef struct grpc_kick_fd_info { - grpc_wakeup_fd_info wakeup_fd; - struct grpc_kick_fd_info *next; -} grpc_kick_fd_info; +#ifdef GPR_WIN32 +#include "src/core/iomgr/pollset_kick_windows.h" +#endif -typedef struct grpc_pollset_kick_state { - gpr_mu mu; - int kicked; - struct grpc_kick_fd_info *fd_info; -} grpc_pollset_kick_state; +/* This is an abstraction around the typical pipe mechanism for waking up a + thread sitting in a poll() style call. */ void grpc_pollset_kick_global_init(void); void grpc_pollset_kick_global_destroy(void); diff --git a/src/core/iomgr/pollset_kick_posix.h b/src/core/iomgr/pollset_kick_posix.h new file mode 100644 index 00000000000..162ae5bd8f1 --- /dev/null +++ b/src/core/iomgr/pollset_kick_posix.h @@ -0,0 +1,51 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ +#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ + +#include "src/core/iomgr/wakeup_fd_posix.h" +#include + +typedef struct grpc_kick_fd_info { + grpc_wakeup_fd_info wakeup_fd; + struct grpc_kick_fd_info *next; +} grpc_kick_fd_info; + +typedef struct grpc_pollset_kick_state { + gpr_mu mu; + int kicked; + struct grpc_kick_fd_info *fd_info; +} grpc_pollset_kick_state; + +#endif /* __GRPC_INTERNALIOMGR_POLLSET_KICK_POSIX_H_ */ diff --git a/src/core/iomgr/pollset_kick_windows.h b/src/core/iomgr/pollset_kick_windows.h new file mode 100644 index 00000000000..1053230a983 --- /dev/null +++ b/src/core/iomgr/pollset_kick_windows.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_WINDOWS_H_ +#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_WINDOWS_H_ + +#include + +struct grpc_kick_fd_info; + +typedef struct grpc_pollset_kick_state { + int unused; +} grpc_pollset_kick_state; + +#endif /* __GRPC_INTERNALIOMGR_POLLSET_KICK_WINDOWS_H_ */ diff --git a/src/core/iomgr/wakeup_fd_eventfd.c b/src/core/iomgr/wakeup_fd_eventfd.c index 4c495e675a6..3ee7f941285 100644 --- a/src/core/iomgr/wakeup_fd_eventfd.c +++ b/src/core/iomgr/wakeup_fd_eventfd.c @@ -39,7 +39,7 @@ #include #include -#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_posix.h" #include static void eventfd_create(grpc_wakeup_fd_info *fd_info) { diff --git a/src/core/iomgr/wakeup_fd_pipe.c b/src/core/iomgr/wakeup_fd_pipe.c index f8a0aeb606c..f36e6eeb9f5 100644 --- a/src/core/iomgr/wakeup_fd_pipe.c +++ b/src/core/iomgr/wakeup_fd_pipe.c @@ -32,7 +32,7 @@ */ /* TODO(klempner): Allow this code to be disabled. */ -#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_posix.h" #include #include diff --git a/src/core/iomgr/wakeup_fd_pipe.h b/src/core/iomgr/wakeup_fd_pipe.h index 8e2ed85885b..fc2898f570e 100644 --- a/src/core/iomgr/wakeup_fd_pipe.h +++ b/src/core/iomgr/wakeup_fd_pipe.h @@ -34,7 +34,7 @@ #ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ #define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ -#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_posix.h" extern grpc_wakeup_fd_vtable pipe_wakeup_fd_vtable; diff --git a/src/core/iomgr/wakeup_fd.c b/src/core/iomgr/wakeup_fd_posix.c similarity index 98% rename from src/core/iomgr/wakeup_fd.c rename to src/core/iomgr/wakeup_fd_posix.c index b81707f2a02..9107cf37b1e 100644 --- a/src/core/iomgr/wakeup_fd.c +++ b/src/core/iomgr/wakeup_fd_posix.c @@ -31,7 +31,7 @@ * */ -#include "src/core/iomgr/wakeup_fd.h" +#include "src/core/iomgr/wakeup_fd_posix.h" #include "src/core/iomgr/wakeup_fd_pipe.h" #include diff --git a/src/core/iomgr/wakeup_fd.h b/src/core/iomgr/wakeup_fd_posix.h similarity index 96% rename from src/core/iomgr/wakeup_fd.h rename to src/core/iomgr/wakeup_fd_posix.h index 225291ca601..2d785976b33 100644 --- a/src/core/iomgr/wakeup_fd.h +++ b/src/core/iomgr/wakeup_fd_posix.h @@ -59,8 +59,8 @@ * 2. If the polling thread was awakened by a wakeup_fd event, call * grpc_wakeup_fd_consume_wakeup() on it. */ -#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ -#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ +#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ +#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ typedef struct grpc_wakeup_fd_info grpc_wakeup_fd_info; @@ -99,4 +99,4 @@ typedef struct grpc_wakeup_fd_vtable { * wakeup_fd_nospecial.c if no such implementation exists. */ extern const grpc_wakeup_fd_vtable specialized_wakeup_fd_vtable; -#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_H_ */ +#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ */ diff --git a/vsprojects/vs2013/grpc.vcxproj b/vsprojects/vs2013/grpc.vcxproj index 1f2f30d6be1..9808a451bb9 100644 --- a/vsprojects/vs2013/grpc.vcxproj +++ b/vsprojects/vs2013/grpc.vcxproj @@ -120,6 +120,8 @@ + + @@ -132,7 +134,8 @@ - + + @@ -275,14 +278,14 @@ - - + + diff --git a/vsprojects/vs2013/grpc.vcxproj.filters b/vsprojects/vs2013/grpc.vcxproj.filters index 36971604dfd..d080ce986d7 100644 --- a/vsprojects/vs2013/grpc.vcxproj.filters +++ b/vsprojects/vs2013/grpc.vcxproj.filters @@ -157,9 +157,6 @@ src\core\iomgr - - src\core\iomgr - src\core\iomgr @@ -169,6 +166,9 @@ src\core\iomgr + + src\core\iomgr + src\core\statistics @@ -434,6 +434,12 @@ src\core\iomgr + + src\core\iomgr + + + src\core\iomgr + src\core\iomgr @@ -470,7 +476,10 @@ src\core\iomgr - + + src\core\iomgr + + src\core\iomgr diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj b/vsprojects/vs2013/grpc_unsecure.vcxproj index 1f2f30d6be1..9808a451bb9 100644 --- a/vsprojects/vs2013/grpc_unsecure.vcxproj +++ b/vsprojects/vs2013/grpc_unsecure.vcxproj @@ -120,6 +120,8 @@ + + @@ -132,7 +134,8 @@ - + + @@ -275,14 +278,14 @@ - - + + diff --git a/vsprojects/vs2013/grpc_unsecure.vcxproj.filters b/vsprojects/vs2013/grpc_unsecure.vcxproj.filters index 4d3bbd92554..5b12fabf6e9 100644 --- a/vsprojects/vs2013/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vs2013/grpc_unsecure.vcxproj.filters @@ -118,9 +118,6 @@ src\core\iomgr - - src\core\iomgr - src\core\iomgr @@ -130,6 +127,9 @@ src\core\iomgr + + src\core\iomgr + src\core\statistics @@ -359,6 +359,12 @@ src\core\iomgr + + src\core\iomgr + + + src\core\iomgr + src\core\iomgr @@ -395,7 +401,10 @@ src\core\iomgr - + + src\core\iomgr + + src\core\iomgr From e360568a70783d5bb5da1b3a51098ffdcc59d2d5 Mon Sep 17 00:00:00 2001 From: David Klempner Date: Mon, 26 Jan 2015 17:27:21 -0800 Subject: [PATCH 4/5] Rename poll_kick_test to poll_kick_posix_test --- Makefile | 26 +++++++++---------- build.json | 4 +-- ...oll_kick_test.c => poll_kick_posix_test.c} | 0 tools/run_tests/tests.json | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename test/core/iomgr/{poll_kick_test.c => poll_kick_posix_test.c} (100%) diff --git a/Makefile b/Makefile index 763d340bba6..9e423327fe4 100644 --- a/Makefile +++ b/Makefile @@ -363,7 +363,7 @@ message_compress_test: bins/$(CONFIG)/message_compress_test metadata_buffer_test: bins/$(CONFIG)/metadata_buffer_test murmur_hash_test: bins/$(CONFIG)/murmur_hash_test no_server_test: bins/$(CONFIG)/no_server_test -poll_kick_test: bins/$(CONFIG)/poll_kick_test +poll_kick_posix_test: bins/$(CONFIG)/poll_kick_posix_test resolve_address_test: bins/$(CONFIG)/resolve_address_test secure_endpoint_test: bins/$(CONFIG)/secure_endpoint_test sockaddr_utils_test: bins/$(CONFIG)/sockaddr_utils_test @@ -565,7 +565,7 @@ privatelibs_cxx: libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libtips_cl buildtests: buildtests_c buildtests_cxx -buildtests_c: privatelibs_c bins/$(CONFIG)/alarm_heap_test bins/$(CONFIG)/alarm_list_test bins/$(CONFIG)/alarm_test bins/$(CONFIG)/alpn_test bins/$(CONFIG)/bin_encoder_test bins/$(CONFIG)/census_hash_table_test bins/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test bins/$(CONFIG)/census_statistics_multiple_writers_test bins/$(CONFIG)/census_statistics_performance_test bins/$(CONFIG)/census_statistics_quick_test bins/$(CONFIG)/census_statistics_small_log_test bins/$(CONFIG)/census_stub_test bins/$(CONFIG)/census_window_stats_test bins/$(CONFIG)/chttp2_status_conversion_test bins/$(CONFIG)/chttp2_stream_encoder_test bins/$(CONFIG)/chttp2_stream_map_test bins/$(CONFIG)/chttp2_transport_end2end_test bins/$(CONFIG)/dualstack_socket_test bins/$(CONFIG)/echo_client bins/$(CONFIG)/echo_server bins/$(CONFIG)/echo_test bins/$(CONFIG)/fd_posix_test bins/$(CONFIG)/fling_client bins/$(CONFIG)/fling_server bins/$(CONFIG)/fling_stream_test bins/$(CONFIG)/fling_test bins/$(CONFIG)/gpr_cancellable_test bins/$(CONFIG)/gpr_cmdline_test bins/$(CONFIG)/gpr_histogram_test bins/$(CONFIG)/gpr_host_port_test bins/$(CONFIG)/gpr_log_test bins/$(CONFIG)/gpr_slice_buffer_test bins/$(CONFIG)/gpr_slice_test bins/$(CONFIG)/gpr_string_test bins/$(CONFIG)/gpr_sync_test bins/$(CONFIG)/gpr_thd_test bins/$(CONFIG)/gpr_time_test bins/$(CONFIG)/gpr_useful_test bins/$(CONFIG)/grpc_base64_test bins/$(CONFIG)/grpc_byte_buffer_reader_test bins/$(CONFIG)/grpc_channel_stack_test bins/$(CONFIG)/grpc_completion_queue_test bins/$(CONFIG)/grpc_credentials_test bins/$(CONFIG)/grpc_json_token_test bins/$(CONFIG)/grpc_stream_op_test bins/$(CONFIG)/hpack_parser_test bins/$(CONFIG)/hpack_table_test bins/$(CONFIG)/httpcli_format_request_test bins/$(CONFIG)/httpcli_parser_test bins/$(CONFIG)/httpcli_test bins/$(CONFIG)/lame_client_test bins/$(CONFIG)/message_compress_test bins/$(CONFIG)/metadata_buffer_test bins/$(CONFIG)/murmur_hash_test bins/$(CONFIG)/no_server_test bins/$(CONFIG)/poll_kick_test bins/$(CONFIG)/resolve_address_test bins/$(CONFIG)/secure_endpoint_test bins/$(CONFIG)/sockaddr_utils_test bins/$(CONFIG)/tcp_client_posix_test bins/$(CONFIG)/tcp_posix_test bins/$(CONFIG)/tcp_server_posix_test bins/$(CONFIG)/time_averaged_stats_test bins/$(CONFIG)/time_test bins/$(CONFIG)/timeout_encoding_test bins/$(CONFIG)/transport_metadata_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fake_security_census_simple_request_test bins/$(CONFIG)/chttp2_fake_security_disappearing_server_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fake_security_invoke_large_request_test bins/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fake_security_no_op_test bins/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test bins/$(CONFIG)/chttp2_fake_security_simple_request_test bins/$(CONFIG)/chttp2_fake_security_thread_stress_test bins/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fullstack_no_op_test bins/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_no_op_test bins/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test +buildtests_c: privatelibs_c bins/$(CONFIG)/alarm_heap_test bins/$(CONFIG)/alarm_list_test bins/$(CONFIG)/alarm_test bins/$(CONFIG)/alpn_test bins/$(CONFIG)/bin_encoder_test bins/$(CONFIG)/census_hash_table_test bins/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test bins/$(CONFIG)/census_statistics_multiple_writers_test bins/$(CONFIG)/census_statistics_performance_test bins/$(CONFIG)/census_statistics_quick_test bins/$(CONFIG)/census_statistics_small_log_test bins/$(CONFIG)/census_stub_test bins/$(CONFIG)/census_window_stats_test bins/$(CONFIG)/chttp2_status_conversion_test bins/$(CONFIG)/chttp2_stream_encoder_test bins/$(CONFIG)/chttp2_stream_map_test bins/$(CONFIG)/chttp2_transport_end2end_test bins/$(CONFIG)/dualstack_socket_test bins/$(CONFIG)/echo_client bins/$(CONFIG)/echo_server bins/$(CONFIG)/echo_test bins/$(CONFIG)/fd_posix_test bins/$(CONFIG)/fling_client bins/$(CONFIG)/fling_server bins/$(CONFIG)/fling_stream_test bins/$(CONFIG)/fling_test bins/$(CONFIG)/gpr_cancellable_test bins/$(CONFIG)/gpr_cmdline_test bins/$(CONFIG)/gpr_histogram_test bins/$(CONFIG)/gpr_host_port_test bins/$(CONFIG)/gpr_log_test bins/$(CONFIG)/gpr_slice_buffer_test bins/$(CONFIG)/gpr_slice_test bins/$(CONFIG)/gpr_string_test bins/$(CONFIG)/gpr_sync_test bins/$(CONFIG)/gpr_thd_test bins/$(CONFIG)/gpr_time_test bins/$(CONFIG)/gpr_useful_test bins/$(CONFIG)/grpc_base64_test bins/$(CONFIG)/grpc_byte_buffer_reader_test bins/$(CONFIG)/grpc_channel_stack_test bins/$(CONFIG)/grpc_completion_queue_test bins/$(CONFIG)/grpc_credentials_test bins/$(CONFIG)/grpc_json_token_test bins/$(CONFIG)/grpc_stream_op_test bins/$(CONFIG)/hpack_parser_test bins/$(CONFIG)/hpack_table_test bins/$(CONFIG)/httpcli_format_request_test bins/$(CONFIG)/httpcli_parser_test bins/$(CONFIG)/httpcli_test bins/$(CONFIG)/lame_client_test bins/$(CONFIG)/message_compress_test bins/$(CONFIG)/metadata_buffer_test bins/$(CONFIG)/murmur_hash_test bins/$(CONFIG)/no_server_test bins/$(CONFIG)/poll_kick_posix_test bins/$(CONFIG)/resolve_address_test bins/$(CONFIG)/secure_endpoint_test bins/$(CONFIG)/sockaddr_utils_test bins/$(CONFIG)/tcp_client_posix_test bins/$(CONFIG)/tcp_posix_test bins/$(CONFIG)/tcp_server_posix_test bins/$(CONFIG)/time_averaged_stats_test bins/$(CONFIG)/time_test bins/$(CONFIG)/timeout_encoding_test bins/$(CONFIG)/transport_metadata_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fake_security_census_simple_request_test bins/$(CONFIG)/chttp2_fake_security_disappearing_server_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fake_security_invoke_large_request_test bins/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fake_security_no_op_test bins/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test bins/$(CONFIG)/chttp2_fake_security_simple_request_test bins/$(CONFIG)/chttp2_fake_security_thread_stress_test bins/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fullstack_no_op_test bins/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_no_op_test bins/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test buildtests_cxx: privatelibs_cxx bins/$(CONFIG)/channel_arguments_test bins/$(CONFIG)/credentials_test bins/$(CONFIG)/end2end_test bins/$(CONFIG)/interop_client bins/$(CONFIG)/interop_server bins/$(CONFIG)/tips_client bins/$(CONFIG)/tips_client_test bins/$(CONFIG)/qps_client bins/$(CONFIG)/qps_server bins/$(CONFIG)/status_test bins/$(CONFIG)/sync_client_async_server_test bins/$(CONFIG)/thread_pool_test @@ -674,8 +674,8 @@ test_c: buildtests_c $(Q) ./bins/$(CONFIG)/murmur_hash_test || ( echo test murmur_hash_test failed ; exit 1 ) $(E) "[RUN] Testing no_server_test" $(Q) ./bins/$(CONFIG)/no_server_test || ( echo test no_server_test failed ; exit 1 ) - $(E) "[RUN] Testing poll_kick_test" - $(Q) ./bins/$(CONFIG)/poll_kick_test || ( echo test poll_kick_test failed ; exit 1 ) + $(E) "[RUN] Testing poll_kick_posix_test" + $(Q) ./bins/$(CONFIG)/poll_kick_posix_test || ( echo test poll_kick_posix_test failed ; exit 1 ) $(E) "[RUN] Testing resolve_address_test" $(Q) ./bins/$(CONFIG)/resolve_address_test || ( echo test resolve_address_test failed ; exit 1 ) $(E) "[RUN] Testing secure_endpoint_test" @@ -5036,33 +5036,33 @@ endif endif -POLL_KICK_TEST_SRC = \ - test/core/iomgr/poll_kick_test.c \ +POLL_KICK_POSIX_TEST_SRC = \ + test/core/iomgr/poll_kick_posix_test.c \ -POLL_KICK_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(POLL_KICK_TEST_SRC)))) +POLL_KICK_POSIX_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(POLL_KICK_POSIX_TEST_SRC)))) ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL with ALPN. -bins/$(CONFIG)/poll_kick_test: openssl_dep_error +bins/$(CONFIG)/poll_kick_posix_test: openssl_dep_error else -bins/$(CONFIG)/poll_kick_test: $(POLL_KICK_TEST_OBJS) libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a +bins/$(CONFIG)/poll_kick_posix_test: $(POLL_KICK_POSIX_TEST_OBJS) libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(POLL_KICK_TEST_OBJS) libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/poll_kick_test + $(Q) $(LD) $(LDFLAGS) $(POLL_KICK_POSIX_TEST_OBJS) libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/poll_kick_posix_test endif -objs/$(CONFIG)/test/core/iomgr/poll_kick_test.o: libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a +objs/$(CONFIG)/test/core/iomgr/poll_kick_posix_test.o: libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a -deps_poll_kick_test: $(POLL_KICK_TEST_OBJS:.o=.dep) +deps_poll_kick_posix_test: $(POLL_KICK_POSIX_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) --include $(POLL_KICK_TEST_OBJS:.o=.dep) +-include $(POLL_KICK_POSIX_TEST_OBJS:.o=.dep) endif endif diff --git a/build.json b/build.json index 85973d3eeaf..430988a02ea 100644 --- a/build.json +++ b/build.json @@ -1268,11 +1268,11 @@ ] }, { - "name": "poll_kick_test", + "name": "poll_kick_posix_test", "build": "test", "language": "c", "src": [ - "test/core/iomgr/poll_kick_test.c" + "test/core/iomgr/poll_kick_posix_test.c" ], "deps": [ "grpc_test_util", diff --git a/test/core/iomgr/poll_kick_test.c b/test/core/iomgr/poll_kick_posix_test.c similarity index 100% rename from test/core/iomgr/poll_kick_test.c rename to test/core/iomgr/poll_kick_posix_test.c diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 90571eaec6c..a610e92307a 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -207,7 +207,7 @@ }, { "language": "c", - "name": "poll_kick_test" + "name": "poll_kick_posix_test" }, { "language": "c", From bb915ace545bc4342a90877ed8ac359b2267929c Mon Sep 17 00:00:00 2001 From: David Klempner Date: Tue, 27 Jan 2015 16:24:09 -0800 Subject: [PATCH 5/5] Rename wakeup fd accessor --- src/core/iomgr/pollset_kick.c | 2 +- src/core/iomgr/wakeup_fd_posix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/iomgr/pollset_kick.c b/src/core/iomgr/pollset_kick.c index e4a9caf97a6..5ee1cef2334 100644 --- a/src/core/iomgr/pollset_kick.c +++ b/src/core/iomgr/pollset_kick.c @@ -113,7 +113,7 @@ int grpc_pollset_kick_pre_poll(grpc_pollset_kick_state *kick_state) { } kick_state->fd_info = allocate_wfd(); gpr_mu_unlock(&kick_state->mu); - return GRPC_WAKEUP_FD_FD(&kick_state->fd_info->wakeup_fd); + return GRPC_WAKEUP_FD_GET_READ_FD(&kick_state->fd_info->wakeup_fd); } void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state) { diff --git a/src/core/iomgr/wakeup_fd_posix.h b/src/core/iomgr/wakeup_fd_posix.h index 2d785976b33..c2769afb2a4 100644 --- a/src/core/iomgr/wakeup_fd_posix.h +++ b/src/core/iomgr/wakeup_fd_posix.h @@ -73,7 +73,7 @@ void grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd_info *fd_info); void grpc_wakeup_fd_wakeup(grpc_wakeup_fd_info *fd_info); void grpc_wakeup_fd_destroy(grpc_wakeup_fd_info *fd_info); -#define GRPC_WAKEUP_FD_FD(fd_info) ((fd_info)->read_fd) +#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd) /* Force using the fallback implementation. This is intended for testing * purposes only.*/