[build] Fix GRPC_POLL_STRATEGY=none on non bazel builds (#30109)

* fix

* fix
pull/30110/head
Craig Tiller 3 years ago committed by GitHub
parent 8249bb97e2
commit 92f60f9201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      src/core/lib/iomgr/ev_poll_posix.cc
  2. 1
      src/core/lib/iomgr/ev_poll_posix.h
  3. 36
      src/core/lib/iomgr/ev_posix.cc

@ -1418,4 +1418,38 @@ const grpc_event_engine_vtable grpc_ev_poll_posix = {
add_closure_to_background_poller,
};
namespace {
grpc_poll_function_type real_poll_function;
int phony_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
if (timeout == 0) {
return real_poll_function(fds, nfds, 0);
} else {
gpr_log(GPR_ERROR, "Attempted a blocking poll when declared non-polling.");
GPR_ASSERT(false);
return -1;
}
}
} // namespace
const grpc_event_engine_vtable grpc_ev_none_posix = []() {
grpc_event_engine_vtable v = grpc_ev_poll_posix;
v.check_engine_available = [](bool explicit_request) {
if (!explicit_request) return false;
// return the simplest engine as a phony but also override the poller
if (!grpc_ev_poll_posix.check_engine_available(explicit_request)) {
return false;
}
real_poll_function = grpc_poll_function;
grpc_poll_function = phony_poll;
return true;
};
v.name = "none";
v.init_engine = []() {};
v.shutdown_engine = []() {};
return v;
}();
#endif /* GRPC_POSIX_SOCKET_EV_POLL */

@ -24,5 +24,6 @@
#include "src/core/lib/iomgr/ev_posix.h"
extern const grpc_event_engine_vtable grpc_ev_poll_posix;
extern const grpc_event_engine_vtable grpc_ev_none_posix;
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */

@ -78,40 +78,6 @@ grpc_wakeup_fd grpc_global_wakeup_fd;
static const grpc_event_engine_vtable* g_event_engine = nullptr;
static gpr_once g_choose_engine = GPR_ONCE_INIT;
namespace {
grpc_poll_function_type real_poll_function;
int phony_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
if (timeout == 0) {
return real_poll_function(fds, nfds, 0);
} else {
gpr_log(GPR_ERROR, "Attempted a blocking poll when declared non-polling.");
GPR_ASSERT(false);
return -1;
}
}
const grpc_event_engine_vtable* non_polling() {
static const grpc_event_engine_vtable vtable = []() {
grpc_event_engine_vtable v = grpc_ev_poll_posix;
v.check_engine_available = [](bool explicit_request) {
if (!explicit_request) return false;
// return the simplest engine as a phony but also override the poller
if (!grpc_ev_poll_posix.check_engine_available(explicit_request)) {
return false;
}
real_poll_function = grpc_poll_function;
grpc_poll_function = phony_poll;
return true;
};
v.name = "none";
return v;
}();
return &vtable;
}
} // namespace
// The global array of event-engine factories. Each entry is a pair with a name
// and an event-engine generator function (nullptr if there is no generator
// registered for this name). The middle entries are the engines predefined by
@ -130,7 +96,7 @@ static const grpc_event_engine_vtable* g_vtables[] = {
nullptr,
&grpc_ev_epoll1_posix,
&grpc_ev_poll_posix,
non_polling(),
&grpc_ev_none_posix,
nullptr,
nullptr,
nullptr,

Loading…
Cancel
Save