diff options
author | Mehrdad Afshari <mehrdada@users.noreply.github.com> | 2018-01-17 19:55:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 19:55:33 -0800 |
commit | e607f1a42e9673bf06649f2cecbabc32d1f829ec (patch) | |
tree | 7adee2fee2020ca2eff6e93fc59cd39de0be8f14 /src | |
parent | a8891634d32ad9556921faed2707fb304304c900 (diff) | |
parent | fb66900a9ab7729d22aa83a0e60cb80ec8e642c6 (diff) |
Merge pull request #14052 from mehrdada/legacyepoll
Explicitly enable epoll1 on manylinux1
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/iomgr/ev_epoll1_linux.cc | 21 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollex_linux.cc | 10 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollsig_linux.cc | 10 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollsig_linux.h | 4 | ||||
-rw-r--r-- | src/core/lib/iomgr/is_epollexclusive_available.cc | 2 | ||||
-rw-r--r-- | src/core/lib/iomgr/port.h | 2 |
6 files changed, 24 insertions, 25 deletions
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 6ec25d761f..aa14d5931a 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -20,7 +20,8 @@ #include <grpc/support/log.h> -/* This polling engine is only relevant on linux kernels supporting epoll() */ +/* This polling engine is only relevant on linux kernels supporting epoll + epoll_create() or epoll_create1() */ #ifdef GRPC_LINUX_EPOLL #include "src/core/lib/iomgr/ev_epoll1_linux.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; } diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 5f5f45a7a5..e4a2d67e4b 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -21,7 +21,7 @@ #include <grpc/support/log.h> /* This polling engine is only relevant on linux kernels supporting epoll() */ -#ifdef GRPC_LINUX_EPOLL +#ifdef GRPC_LINUX_EPOLL_CREATE1 #include "src/core/lib/iomgr/ev_epollex_linux.h" @@ -1442,15 +1442,15 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux( return &vtable; } -#else /* defined(GRPC_LINUX_EPOLL) */ +#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */ #if defined(GRPC_POSIX_SOCKET) #include "src/core/lib/iomgr/ev_epollex_linux.h" -/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return - * NULL */ +/* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means + epoll_create1 is not available. Return NULL */ const grpc_event_engine_vtable* grpc_init_epollex_linux( bool explicitly_requested) { return nullptr; } #endif /* defined(GRPC_POSIX_SOCKET) */ -#endif /* !defined(GRPC_LINUX_EPOLL) */ +#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */ diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 8072a6cbed..3544d4f3a4 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -22,7 +22,7 @@ #include <grpc/support/log.h> /* This polling engine is only relevant on linux kernels supporting epoll() */ -#ifdef GRPC_LINUX_EPOLL +#ifdef GRPC_LINUX_EPOLL_CREATE1 #include "src/core/lib/iomgr/ev_epollsig_linux.h" @@ -1725,11 +1725,11 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux( return &vtable; } -#else /* defined(GRPC_LINUX_EPOLL) */ +#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */ #if defined(GRPC_POSIX_SOCKET) #include "src/core/lib/iomgr/ev_epollsig_linux.h" -/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return - * NULL */ +/* If GRPC_LINUX_EPOLL_CREATE1 is not defined, it means + epoll_create1 is not available. Return NULL */ const grpc_event_engine_vtable* grpc_init_epollsig_linux( bool explicit_request) { return nullptr; @@ -1737,4 +1737,4 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux( #endif /* defined(GRPC_POSIX_SOCKET) */ void grpc_use_signal(int signum) {} -#endif /* !defined(GRPC_LINUX_EPOLL) */ +#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */ diff --git a/src/core/lib/iomgr/ev_epollsig_linux.h b/src/core/lib/iomgr/ev_epollsig_linux.h index 5b8aba9d9f..48178d3713 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.h +++ b/src/core/lib/iomgr/ev_epollsig_linux.h @@ -24,10 +24,10 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux(bool explicit_request); -#ifdef GRPC_LINUX_EPOLL +#ifdef GRPC_LINUX_EPOLL_CREATE1 void* grpc_fd_get_polling_island(grpc_fd* fd); void* grpc_pollset_get_polling_island(grpc_pollset* ps); bool grpc_are_polling_islands_equal(void* p, void* q); -#endif /* defined(GRPC_LINUX_EPOLL) */ +#endif /* defined(GRPC_LINUX_EPOLL_CREATE1) */ #endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H */ diff --git a/src/core/lib/iomgr/is_epollexclusive_available.cc b/src/core/lib/iomgr/is_epollexclusive_available.cc index e5803532e7..08f9cf2b69 100644 --- a/src/core/lib/iomgr/is_epollexclusive_available.cc +++ b/src/core/lib/iomgr/is_epollexclusive_available.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/is_epollexclusive_available.h" -#ifdef GRPC_LINUX_EPOLL +#ifdef GRPC_LINUX_EPOLL_CREATE1 #include <grpc/support/log.h> diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 80867ee09f..25090898ed 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -37,6 +37,7 @@ #define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_POSIX_WAKEUP_FD 1 #define GRPC_TIMER_USE_GENERIC 1 +#define GRPC_LINUX_EPOLL 1 #elif defined(GPR_WINDOWS) #define GRPC_TIMER_USE_GENERIC 1 #define GRPC_WINSOCK_SOCKET 1 @@ -80,6 +81,7 @@ #endif #ifndef __GLIBC__ #define GRPC_LINUX_EPOLL 1 +#define GRPC_LINUX_EPOLL_CREATE1 1 #define GRPC_LINUX_EVENTFD 1 #define GRPC_MSG_IOVLEN_TYPE int #endif |