Cleanup poll-cv setup

pull/7664/head
Ken Payson 8 years ago
parent 131a1065fb
commit cd7d0479a2
  1. 2
      src/core/lib/iomgr/ev_epoll_linux.c
  2. 13
      src/core/lib/iomgr/ev_poll_cv_posix.c
  3. 2
      src/core/lib/iomgr/ev_poll_posix.c
  4. 30
      src/core/lib/iomgr/wakeup_fd_posix.c
  5. 5
      src/core/lib/iomgr/wakeup_fd_posix.h

@ -1892,7 +1892,7 @@ const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
return NULL;
}
if (!grpc_has_wakeup_fd) {
if (!grpc_has_wakeup_fd()) {
return NULL;
}

@ -255,21 +255,12 @@ static void shutdown_engine(void) {
}
const grpc_event_engine_vtable* grpc_init_poll_cv_posix(void) {
int has_wakeup_fd = grpc_has_wakeup_fd;
int allow_specialized_wakeup_fd = grpc_allow_specialized_wakeup_fd;
int allow_pipe_wakeup_fd = grpc_allow_pipe_wakeup_fd;
grpc_global_cv_fd_table_init();
grpc_allow_specialized_wakeup_fd = 0;
grpc_allow_pipe_wakeup_fd = 0;
grpc_wakeup_fd_global_init();
grpc_has_wakeup_fd = 1;
grpc_enable_cv_wakeup_fds(1);
ev_poll_vtable = grpc_init_poll_posix();
if (!ev_poll_vtable) {
grpc_global_cv_fd_table_shutdown();
grpc_has_wakeup_fd = has_wakeup_fd;
grpc_allow_specialized_wakeup_fd = allow_specialized_wakeup_fd;
grpc_allow_pipe_wakeup_fd = allow_pipe_wakeup_fd;
grpc_global_cv_fd_table_init();
grpc_enable_cv_wakeup_fds(0);
return NULL;
}
vtable = *ev_poll_vtable;

@ -1277,7 +1277,7 @@ static const grpc_event_engine_vtable vtable = {
};
const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
if (!grpc_has_wakeup_fd) {
if (!grpc_has_wakeup_fd()) {
return NULL;
}
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {

@ -41,9 +41,11 @@
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
static const grpc_wakeup_fd_vtable *wakeup_fd_vtable = NULL;
int grpc_allow_specialized_wakeup_fd = 1;
int grpc_allow_pipe_wakeup_fd = 1;
int grpc_has_wakeup_fd = 1;
int grpc_has_real_wakeup_fd = 1;
int grpc_cv_wakeup_fds_enabled = 0;
void grpc_wakeup_fd_global_init(void) {
if (grpc_allow_specialized_wakeup_fd &&
@ -53,27 +55,47 @@ void grpc_wakeup_fd_global_init(void) {
grpc_pipe_wakeup_fd_vtable.check_availability()) {
wakeup_fd_vtable = &grpc_pipe_wakeup_fd_vtable;
} else {
grpc_has_wakeup_fd = 0;
wakeup_fd_vtable = &grpc_cv_wakeup_fd_vtable;
grpc_has_real_wakeup_fd = 0;
}
}
void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = NULL; }
int grpc_has_wakeup_fd(void) {
return grpc_has_real_wakeup_fd || grpc_cv_wakeup_fds_enabled;
}
void grpc_enable_cv_wakeup_fds(int enable) {
grpc_cv_wakeup_fds_enabled = enable;
}
grpc_error *grpc_wakeup_fd_init(grpc_wakeup_fd *fd_info) {
if (grpc_cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.init(fd_info);
}
return wakeup_fd_vtable->init(fd_info);
}
grpc_error *grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd *fd_info) {
if (grpc_cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.consume(fd_info);
}
return wakeup_fd_vtable->consume(fd_info);
}
grpc_error *grpc_wakeup_fd_wakeup(grpc_wakeup_fd *fd_info) {
if (grpc_cv_wakeup_fds_enabled) {
return grpc_cv_wakeup_fd_vtable.wakeup(fd_info);
}
return wakeup_fd_vtable->wakeup(fd_info);
}
void grpc_wakeup_fd_destroy(grpc_wakeup_fd *fd_info) {
wakeup_fd_vtable->destroy(fd_info);
if (grpc_cv_wakeup_fds_enabled) {
grpc_cv_wakeup_fd_vtable.destroy(fd_info);
} else {
wakeup_fd_vtable->destroy(fd_info);
}
}
#endif /* GPR_POSIX_WAKEUP_FD */

@ -71,6 +71,9 @@ void grpc_wakeup_fd_global_destroy(void);
* purposes only.*/
void grpc_wakeup_fd_global_init_force_fallback(void);
int grpc_has_wakeup_fd(void);
void grpc_enable_cv_wakeup_fds(int enable);
typedef struct grpc_wakeup_fd grpc_wakeup_fd;
typedef struct grpc_wakeup_fd_vtable {
@ -89,7 +92,7 @@ struct grpc_wakeup_fd {
extern int grpc_allow_specialized_wakeup_fd;
extern int grpc_allow_pipe_wakeup_fd;
extern int grpc_has_wakeup_fd;
extern int grpc_has_real_wakeup_fd;
#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd)

Loading…
Cancel
Save