diff options
author | Mehrdad Afshari <mmx@google.com> | 2018-01-17 13:42:26 -0800 |
---|---|---|
committer | Mehrdad Afshari <mmx@google.com> | 2018-01-17 14:49:19 -0800 |
commit | 8b0e9fb17edab249f41391d877d8d03961f4f7ee (patch) | |
tree | df54674cf1f260bfe8a5458f34b5cf8cc450a6d9 /src/core/lib/iomgr/ev_epoll1_linux.cc | |
parent | 3538efb53bd6d3bfca91aa50db7a6e1b97b9c855 (diff) |
Explicitly enable epoll on manylinux1
For some reason, the glibc version check does not enable
GRPC_LINUX_EPOLL on manylinux1. This commit:
* Explicitly enables GRPC_LINUX_LEGACY_EPOLL on MANYLINUX1
* Switches the flag to enable epoll1 IO manager to
GRPC_LINUX_LEGACY_EPOLL instead of GRPC_LINUX_EPOLL.
This is to ensure epollex and epollsig that are not yet
compatible with epoll_create (not epoll_create1) do not
get activated unintentionally.
Diffstat (limited to 'src/core/lib/iomgr/ev_epoll1_linux.cc')
-rw-r--r-- | src/core/lib/iomgr/ev_epoll1_linux.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 6ec25d761f..c8899be985 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -20,8 +20,9 @@ #include <grpc/support/log.h> -/* This polling engine is only relevant on linux kernels supporting epoll() */ -#ifdef GRPC_LINUX_EPOLL +/* This polling engine is only relevant on linux kernels supporting epoll + epoll_create() or epoll_create1() */ +#ifdef GRPC_LINUX_LEGACY_EPOLL #include "src/core/lib/iomgr/ev_epoll1_linux.h" #include <assert.h> @@ -85,31 +86,27 @@ typedef struct epoll_set { /* The global singleton epoll set */ static epoll_set g_epoll_set; -static int epoll_create_and_set_flag() { +static int epoll_create_and_cloexec() { #ifdef GRPC_LINUX_EPOLL_CREATE1 int fd = epoll_create1(EPOLL_CLOEXEC); - if (fd >= 0) { - return fd; + if (fd < 0) { + gpr_log(GPR_ERROR, "epoll_create1 unavailable"); } - gpr_log(GPR_ERROR, "epoll_create1 unavailable"); - return -1; #else int fd = epoll_create(MAX_EPOLL_EVENTS); if (fd < 0) { gpr_log(GPR_ERROR, "epoll_create unavailable"); + } else if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { + gpr_log(GPR_ERROR, "fcntl following epoll_create failed"); return -1; } - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == 0) { - return fd; - } - gpr_log(GPR_ERROR, "fcntl following epoll_create failed"); - return -1; #endif + return fd; } /* Must be called *only* once */ static bool epoll_set_init() { - g_epoll_set.epfd = epoll_create_and_set_flag(); + g_epoll_set.epfd = epoll_create_and_cloexec(); if (g_epoll_set.epfd < 0) { return false; } @@ -1248,7 +1245,7 @@ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { return &vtable; } -#else /* defined(GRPC_LINUX_EPOLL) */ +#else /* defined(GRPC_LINUX_LEGACY_EPOLL) */ #if defined(GRPC_POSIX_SOCKET) #include "src/core/lib/iomgr/ev_epoll1_linux.h" /* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return @@ -1257,4 +1254,4 @@ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { return nullptr; } #endif /* defined(GRPC_POSIX_SOCKET) */ -#endif /* !defined(GRPC_LINUX_EPOLL) */ +#endif /* !defined(GRPC_LINUX_LEGACY_EPOLL) */ |