From bc544be002b864e808cbca54ea64fa9b68262302 Mon Sep 17 00:00:00 2001
From: Ken Payson <kpayson@google.com>
Date: Thu, 6 Oct 2016 19:23:47 -0700
Subject: [PATCH] Fix platform detection

---
 src/core/lib/iomgr/ev_epoll_linux.c | 4 ++++
 src/core/lib/iomgr/ev_poll_posix.c  | 3 +++
 src/core/lib/iomgr/ev_posix.c       | 1 +
 src/core/lib/iomgr/wakeup_fd_pipe.c | 3 +--
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c
index ab77ebc78b..249bc98735 100644
--- a/src/core/lib/iomgr/ev_epoll_linux.c
+++ b/src/core/lib/iomgr/ev_epoll_linux.c
@@ -1892,6 +1892,10 @@ const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
     return NULL;
   }
 
+  if (!grpc_has_wakeup_fd) {
+    return NULL;
+  }
+
   if (!is_epoll_available()) {
     return NULL;
   }
diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c
index 16a5e3083e..97e71d968e 100644
--- a/src/core/lib/iomgr/ev_poll_posix.c
+++ b/src/core/lib/iomgr/ev_poll_posix.c
@@ -1277,6 +1277,9 @@ static const grpc_event_engine_vtable vtable = {
 };
 
 const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
+  if (!grpc_has_wakeup_fd) {
+    return NULL;
+  }
   if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
     return NULL;
   }
diff --git a/src/core/lib/iomgr/ev_posix.c b/src/core/lib/iomgr/ev_posix.c
index 2fc8ccfa91..a4102b429f 100644
--- a/src/core/lib/iomgr/ev_posix.c
+++ b/src/core/lib/iomgr/ev_posix.c
@@ -65,6 +65,7 @@ typedef struct {
 } event_engine_factory;
 
 static const event_engine_factory g_factories[] = {
+    {"poll-cv", grpc_init_poll_cv_posix},
     {"epoll", grpc_init_epoll_linux},
     {"poll", grpc_init_poll_posix},
     {"poll-cv", grpc_init_poll_cv_posix},
diff --git a/src/core/lib/iomgr/wakeup_fd_pipe.c b/src/core/lib/iomgr/wakeup_fd_pipe.c
index 3dc94c94ba..d0ea216aa0 100644
--- a/src/core/lib/iomgr/wakeup_fd_pipe.c
+++ b/src/core/lib/iomgr/wakeup_fd_pipe.c
@@ -47,11 +47,10 @@
 
 static grpc_error* pipe_init(grpc_wakeup_fd* fd_info) {
   int pipefd[2];
-  /* TODO(klempner): Make this nonfatal */
   int r = pipe(pipefd);
   if (0 != r) {
     gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno, strerror(errno));
-    abort();
+    return GRPC_OS_ERROR(errno, "pipe");
   }
   grpc_error* err;
   err = grpc_set_socket_nonblocking(pipefd[0], 1);
-- 
GitLab