Progress converting to new error system

pull/6897/head
Craig Tiller 9 years ago
parent 94f8453d0a
commit 0f75fbe7ed
  1. 10
      src/core/lib/iomgr/ev_poll_and_epoll_posix.c
  2. 20
      src/core/lib/iomgr/wakeup_fd_eventfd.c

@ -1655,7 +1655,7 @@ static void multipoll_with_epoll_pollset_add_fd(grpc_exec_ctx *exec_ctx,
/* TODO(klempner): We probably want to turn this down a bit */ /* TODO(klempner): We probably want to turn this down a bit */
#define GRPC_EPOLL_MAX_EVENTS 1000 #define GRPC_EPOLL_MAX_EVENTS 1000
static void multipoll_with_epoll_pollset_maybe_work_and_unlock( static grpc_error *multipoll_with_epoll_pollset_maybe_work_and_unlock(
grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *worker, grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *worker,
gpr_timespec deadline, gpr_timespec now) { gpr_timespec deadline, gpr_timespec now) {
struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS]; struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS];
@ -1664,6 +1664,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
epoll_hdr *h = pollset->data.ptr; epoll_hdr *h = pollset->data.ptr;
int timeout_ms; int timeout_ms;
struct pollfd pfds[2]; struct pollfd pfds[2];
grpc_error *error = GRPC_ERROR_NONE;
/* If you want to ignore epoll's ability to sanely handle parallel pollers, /* If you want to ignore epoll's ability to sanely handle parallel pollers,
* for a more apples-to-apples performance comparison with poll, add a * for a more apples-to-apples performance comparison with poll, add a
@ -1698,7 +1699,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
/* do nothing */ /* do nothing */
} else { } else {
if (pfds[0].revents) { if (pfds[0].revents) {
grpc_wakeup_fd_consume_wakeup(&worker->wakeup_fd->fd); work_combine_error(&error, grpc_wakeup_fd_consume_wakeup(&worker->wakeup_fd->fd));
} }
if (pfds[1].revents) { if (pfds[1].revents) {
do { do {
@ -1706,7 +1707,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
ep_rv = epoll_wait(h->epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, 0); ep_rv = epoll_wait(h->epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, 0);
if (ep_rv < 0) { if (ep_rv < 0) {
if (errno != EINTR) { if (errno != EINTR) {
gpr_log(GPR_ERROR, "epoll_wait() failed: %s", strerror(errno)); work_combine_error(&error, GRPC_OS_ERROR(errno, "epoll_wait"));
} }
} else { } else {
int i; int i;
@ -1718,7 +1719,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI); int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
int write_ev = ep_ev[i].events & EPOLLOUT; int write_ev = ep_ev[i].events & EPOLLOUT;
if (fd == NULL) { if (fd == NULL) {
grpc_wakeup_fd_consume_wakeup(&grpc_global_wakeup_fd); work_combine_error(&error, grpc_wakeup_fd_consume_wakeup(&grpc_global_wakeup_fd));
} else { } else {
if (read_ev || cancel) { if (read_ev || cancel) {
fd_become_readable(exec_ctx, fd); fd_become_readable(exec_ctx, fd);
@ -1732,6 +1733,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
} while (ep_rv == GRPC_EPOLL_MAX_EVENTS); } while (ep_rv == GRPC_EPOLL_MAX_EVENTS);
} }
} }
return error;
} }
static void multipoll_with_epoll_pollset_finish_shutdown( static void multipoll_with_epoll_pollset_finish_shutdown(

@ -44,29 +44,39 @@
#include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h"
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
static void 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); int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
/* TODO(klempner): Handle failure more gracefully */ if (efd < 0) {
GPR_ASSERT(efd >= 0); return GRPC_OS_ERROR(errno, "eventfd");
}
fd_info->read_fd = efd; fd_info->read_fd = efd;
fd_info->write_fd = -1; fd_info->write_fd = -1;
return GRPC_ERROR_NONE;
} }
static void eventfd_consume(grpc_wakeup_fd* fd_info) { static grpc_error *eventfd_consume(grpc_wakeup_fd* fd_info) {
eventfd_t value; eventfd_t value;
int err; int err;
do { do {
err = eventfd_read(fd_info->read_fd, &value); err = eventfd_read(fd_info->read_fd, &value);
} while (err < 0 && errno == EINTR); } while (err < 0 && errno == EINTR);
if (err < 0) {
return GRPC_OS_ERROR(errno, "eventfd_read");
}
return GRPC_ERROR_NONE;
} }
static void eventfd_wakeup(grpc_wakeup_fd* fd_info) { static grpc_error* eventfd_wakeup(grpc_wakeup_fd* fd_info) {
int err; int err;
GPR_TIMER_BEGIN("eventfd_wakeup", 0); GPR_TIMER_BEGIN("eventfd_wakeup", 0);
do { do {
err = eventfd_write(fd_info->read_fd, 1); err = eventfd_write(fd_info->read_fd, 1);
} while (err < 0 && errno == EINTR); } while (err < 0 && errno == EINTR);
if (err < 0) {
return GRPC_OS_ERROR(errno, "eventfd_read");
}
GPR_TIMER_END("eventfd_wakeup", 0); GPR_TIMER_END("eventfd_wakeup", 0);
return GRPC_ERROR_NONE;
} }
static void eventfd_destroy(grpc_wakeup_fd* fd_info) { static void eventfd_destroy(grpc_wakeup_fd* fd_info) {

Loading…
Cancel
Save