diff options
author | 2017-10-11 10:43:26 -0700 | |
---|---|---|
committer | 2017-10-11 10:43:26 -0700 | |
commit | 5b87a52b43c1e182ef60cdbdad01b04e07a0e134 (patch) | |
tree | 5f1e2b45f68c108d23702b11946350d4d9e6d444 /src/core | |
parent | 49cca04bfaa3e3a9f8851ca9f6f638ff814c7ba5 (diff) | |
parent | 1ba537069ca8ac3b97502f66e815f9e84a73acbc (diff) |
Merge pull request #12953 from vjpai/sanitized_non_polling
Sanity check that tests declared non-polling actually don't poll
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lib/iomgr/ev_posix.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index e4033fab1d..369baa621f 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -61,12 +61,30 @@ typedef struct { event_engine_factory_fn factory; } event_engine_factory; +namespace { +extern "C" { +int dummypoll(struct pollfd fds[], nfds_t nfds, int timeout) { + gpr_log(GPR_ERROR, "Attempted to poll despite declaring non-polling."); + GPR_ASSERT(false); + return -1; +} +} // extern "C" + +const grpc_event_engine_vtable *init_non_polling(bool explicit_request) { + // return the simplest engine as a dummy but also override the poller + auto ret = grpc_init_poll_posix(explicit_request); + grpc_poll_function = dummypoll; + return ret; +} +} // namespace + static const event_engine_factory g_factories[] = { {"epoll1", grpc_init_epoll1_linux}, {"epollsig", grpc_init_epollsig_linux}, {"poll", grpc_init_poll_posix}, {"poll-cv", grpc_init_poll_cv_posix}, {"epollex", grpc_init_epollex_linux}, + {"none", init_non_polling}, }; static void add(const char *beg, const char *end, char ***ss, size_t *ns) { |