Merge pull request #16161 from yashykt/pollforceset

Add API to grpc event engines to forcibly set underlying fd to be rea…
pull/16235/head
Yash Tibrewal 7 years ago committed by GitHub
commit 037d9ab177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/core/lib/iomgr/ev_epoll1_linux.cc
  2. 3
      src/core/lib/iomgr/ev_epollex_linux.cc
  3. 15
      src/core/lib/iomgr/ev_epollsig_linux.cc
  4. 21
      src/core/lib/iomgr/ev_poll_posix.cc
  5. 6
      src/core/lib/iomgr/ev_posix.cc
  6. 18
      src/core/lib/iomgr/ev_posix.h

@ -1203,6 +1203,9 @@ static const grpc_event_engine_vtable vtable = {
fd_notify_on_read,
fd_notify_on_write,
fd_notify_on_error,
fd_become_readable,
fd_become_writable,
fd_has_errors,
fd_is_shutdown,
pollset_init,

@ -1615,6 +1615,9 @@ static const grpc_event_engine_vtable vtable = {
fd_notify_on_read,
fd_notify_on_write,
fd_notify_on_error,
fd_become_readable,
fd_become_writable,
fd_has_errors,
fd_is_shutdown,
pollset_init,

@ -948,6 +948,12 @@ static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) {
fd->error_closure->NotifyOn(closure);
}
static void fd_become_readable(grpc_fd* fd) { fd->read_closure->SetReady(); }
static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
static void fd_has_errors(grpc_fd* fd) { fd->error_closure->SetReady(); }
/*******************************************************************************
* Pollset Definitions
*/
@ -1105,12 +1111,6 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) {
return static_cast<int>(delta);
}
static void fd_become_readable(grpc_fd* fd) { fd->read_closure->SetReady(); }
static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
static void fd_has_errors(grpc_fd* fd) { fd->error_closure->SetReady(); }
static void pollset_release_polling_island(grpc_pollset* ps,
const char* reason) {
if (ps->po.pi != nullptr) {
@ -1647,6 +1647,9 @@ static const grpc_event_engine_vtable vtable = {
fd_notify_on_read,
fd_notify_on_write,
fd_notify_on_error,
fd_become_readable,
fd_become_writable,
fd_has_errors,
fd_is_shutdown,
pollset_init,

@ -538,6 +538,24 @@ static void fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) {
GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CANCELLED);
}
static void fd_set_readable(grpc_fd* fd) {
gpr_mu_lock(&fd->mu);
set_ready_locked(fd, &fd->read_closure);
gpr_mu_unlock(&fd->mu);
}
static void fd_set_writable(grpc_fd* fd) {
gpr_mu_lock(&fd->mu);
set_ready_locked(fd, &fd->write_closure);
gpr_mu_unlock(&fd->mu);
}
static void fd_set_error(grpc_fd* fd) {
if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "Polling engine does not support tracking errors.");
}
}
static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
grpc_pollset_worker* worker, uint32_t read_mask,
uint32_t write_mask, grpc_fd_watcher* watcher) {
@ -1700,6 +1718,9 @@ static const grpc_event_engine_vtable vtable = {
fd_notify_on_read,
fd_notify_on_write,
fd_notify_on_error,
fd_set_readable,
fd_set_writable,
fd_set_error,
fd_is_shutdown,
pollset_init,

@ -239,6 +239,12 @@ void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure) {
g_event_engine->fd_notify_on_error(fd, closure);
}
void grpc_fd_set_readable(grpc_fd* fd) { g_event_engine->fd_set_readable(fd); }
void grpc_fd_set_writable(grpc_fd* fd) { g_event_engine->fd_set_writable(fd); }
void grpc_fd_set_error(grpc_fd* fd) { g_event_engine->fd_set_error(fd); }
static size_t pollset_size(void) { return g_event_engine->pollset_size; }
static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {

@ -51,6 +51,9 @@ typedef struct grpc_event_engine_vtable {
void (*fd_notify_on_read)(grpc_fd* fd, grpc_closure* closure);
void (*fd_notify_on_write)(grpc_fd* fd, grpc_closure* closure);
void (*fd_notify_on_error)(grpc_fd* fd, grpc_closure* closure);
void (*fd_set_readable)(grpc_fd* fd);
void (*fd_set_writable)(grpc_fd* fd);
void (*fd_set_error)(grpc_fd* fd);
bool (*fd_is_shutdown)(grpc_fd* fd);
void (*pollset_init)(grpc_pollset* pollset, gpr_mu** mu);
@ -141,6 +144,21 @@ void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure);
* needs to have been set on grpc_fd_create */
void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure);
/* Forcibly set the fd to be readable, resulting in the closure registered with
* grpc_fd_notify_on_read being invoked.
*/
void grpc_fd_set_readable(grpc_fd* fd);
/* Forcibly set the fd to be writable, resulting in the closure registered with
* grpc_fd_notify_on_write being invoked.
*/
void grpc_fd_set_writable(grpc_fd* fd);
/* Forcibly set the fd to have errored, resulting in the closure registered with
* grpc_fd_notify_on_error being invoked.
*/
void grpc_fd_set_error(grpc_fd* fd);
/* pollset_posix functions */
/* Add an fd to a pollset */

Loading…
Cancel
Save