Check epoll is actually available. set GPR_LINUX_EPOLL only in GLIBC ver

2.9 and above
pull/6803/head
Sree Kuchibhotla 9 years ago
parent 0553a43661
commit 7274402165
  1. 2
      include/grpc/impl/codegen/port_platform.h
  2. 19
      src/core/lib/iomgr/ev_epoll_linux.c

@ -189,7 +189,6 @@
#define GPR_GCC_ATOMIC 1
#define GPR_GCC_TLS 1
#define GPR_LINUX 1
#define GPR_LINUX_EPOLL 1
#define GPR_LINUX_LOG
#define GPR_LINUX_MULTIPOLL_WITH_EPOLL 1
#define GPR_POSIX_WAKEUP_FD 1
@ -201,6 +200,7 @@
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 9)
#define GPR_LINUX_EVENTFD 1
#define GPR_LINUX_EPOLL 1
#endif
#if __GLIBC_PREREQ(2, 10)
#define GPR_LINUX_SOCKETUTILS 1

@ -1481,7 +1481,26 @@ static const grpc_event_engine_vtable vtable = {
.shutdown_engine = shutdown_engine,
};
/* It is possible that GLIBC has epoll but the underlying kernel doesn't.
* Create a dummy epoll_fd to make sure epoll support is available */
static bool is_epoll_available() {
int fd = epoll_create1(EPOLL_CLOEXEC);
if (fd < 0) {
gpr_log(
GPR_ERROR,
"epoll_create1 failed with error: %d. Not using epoll polling engine",
fd);
return false;
}
close(fd);
return true;
}
const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
if (!is_epoll_available()) {
return NULL;
}
fd_global_init();
pollset_global_init();
polling_island_global_init();

Loading…
Cancel
Save