read_fd should always have a certain value when create error occurs [fix: while using eventfd, when error occurs during creating eventfd, a random fd will be closed]

pull/10859/head
haorenfsa 8 years ago committed by shaoyue.chen
parent f15e3bbc35
commit 3cdbee6cbc
  1. 7
      src/core/lib/iomgr/wakeup_fd_eventfd.cc

@ -32,12 +32,11 @@
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
static grpc_error* eventfd_create(grpc_wakeup_fd* fd_info) { static grpc_error* eventfd_create(grpc_wakeup_fd* fd_info) {
int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); fd_info->read_fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
if (efd < 0) { fd_info->write_fd = -1;
if (fd_info->read_fd < 0) {
return GRPC_OS_ERROR(errno, "eventfd"); return GRPC_OS_ERROR(errno, "eventfd");
} }
fd_info->read_fd = efd;
fd_info->write_fd = -1;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }

Loading…
Cancel
Save