Allow specifying a default signal iff epollsig has been explicitly requested

pull/10892/head
Craig Tiller 8 years ago
parent 6a85ee0b4d
commit 6f0af49bb2
  1. 4
      src/core/lib/iomgr/ev_epoll1_linux.c
  2. 2
      src/core/lib/iomgr/ev_epoll1_linux.h
  3. 7
      src/core/lib/iomgr/ev_epollsig_linux.c
  4. 2
      src/core/lib/iomgr/ev_epollsig_linux.h
  5. 4
      src/core/lib/iomgr/ev_poll_posix.c
  6. 4
      src/core/lib/iomgr/ev_poll_posix.h
  7. 4
      src/core/lib/iomgr/ev_posix.c

@ -676,7 +676,7 @@ static const grpc_event_engine_vtable vtable = {
/* 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 */
const grpc_event_engine_vtable *grpc_init_epoll1_linux(void) {
const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
return NULL;
}
@ -703,6 +703,6 @@ const grpc_event_engine_vtable *grpc_init_epoll1_linux(void) {
#include "src/core/lib/iomgr/ev_posix.h"
/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
* NULL */
const grpc_event_engine_vtable *grpc_init_epoll1_linux(void) { return NULL; }
const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request) { return NULL; }
#endif /* defined(GRPC_POSIX_SOCKET) */
#endif /* !defined(GRPC_LINUX_EPOLL) */

@ -39,6 +39,6 @@
// a polling engine that utilizes a singleton epoll set and turnstile polling
const grpc_event_engine_vtable *grpc_init_epoll1_linux(void);
const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request);
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */

@ -1921,7 +1921,7 @@ static bool is_epoll_available() {
return true;
}
const grpc_event_engine_vtable *grpc_init_epollsig_linux(void) {
const grpc_event_engine_vtable *grpc_init_epollsig_linux(bool explicit_request) {
/* If use of signals is disabled, we cannot use epoll engine*/
if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) {
return NULL;
@ -1936,7 +1936,8 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(void) {
}
if (!is_grpc_wakeup_signal_initialized) {
return NULL;
if (explicit_request) grpc_use_signal(SIGRTMIN + 6);
else return NULL;
}
fd_global_init();
@ -1958,7 +1959,7 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(void) {
#include "src/core/lib/iomgr/ev_posix.h"
/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
* NULL */
const grpc_event_engine_vtable *grpc_init_epollsig_linux(void) { return NULL; }
const grpc_event_engine_vtable *grpc_init_epollsig_linux(bool explicit_request) { return NULL; }
#endif /* defined(GRPC_POSIX_SOCKET) */
void grpc_use_signal(int signum) {}

@ -37,7 +37,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
const grpc_event_engine_vtable *grpc_init_epollsig_linux(void);
const grpc_event_engine_vtable *grpc_init_epollsig_linux(bool explicit_request);
#ifdef GRPC_LINUX_EPOLL
void *grpc_fd_get_polling_island(grpc_fd *fd);

@ -1569,7 +1569,7 @@ static const grpc_event_engine_vtable vtable = {
.shutdown_engine = shutdown_engine,
};
const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
return NULL;
}
@ -1579,7 +1579,7 @@ const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
return &vtable;
}
const grpc_event_engine_vtable *grpc_init_poll_cv_posix(void) {
const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request) {
global_cv_fd_table_init();
grpc_enable_cv_wakeup_fds(1);
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {

@ -36,7 +36,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
const grpc_event_engine_vtable *grpc_init_poll_posix(void);
const grpc_event_engine_vtable *grpc_init_poll_cv_posix(void);
const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request);
const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request);
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */

@ -58,7 +58,7 @@ grpc_wakeup_fd grpc_global_wakeup_fd;
static const grpc_event_engine_vtable *g_event_engine;
static const char *g_poll_strategy_name = NULL;
typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(void);
typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(bool explicit_request);
typedef struct {
const char *name;
@ -104,7 +104,7 @@ static bool is(const char *want, const char *have) {
static void try_engine(const char *engine) {
for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
if (is(engine, g_factories[i].name)) {
if ((g_event_engine = g_factories[i].factory())) {
if ((g_event_engine = g_factories[i].factory(0 == strcmp(engine, g_factories[i].name)))) {
g_poll_strategy_name = g_factories[i].name;
gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
return;

Loading…
Cancel
Save