diff options
author | Craig Tiller <ctiller@google.com> | 2017-10-12 00:36:12 +0000 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-10-12 00:36:12 +0000 |
commit | 9d5d07f1e73f056d7838d2112fca204f9788e383 (patch) | |
tree | 473d373af6cc8712bcfe2164bb429923ccdf5e9f /src/core/lib | |
parent | bfec10fdcf00a6fdb196b29b3b759a3e113fc66b (diff) | |
parent | 147a45ae8037332b15ec1e9ce9259aa8be6c915a (diff) |
Merge branch 'fix_no_poll' of github.com:vjpai/grpc into epexinf
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/iomgr/ev_posix.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 86eae5f95b..677ee675a6 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -62,18 +62,31 @@ typedef struct { } 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; + +grpc_poll_function_type real_poll_function; + +int dummy_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; + } } } // extern "C" const grpc_event_engine_vtable *init_non_polling(bool explicit_request) { + if (!explicit_request) { + return nullptr; + } // return the simplest engine as a dummy but also override the poller auto ret = grpc_init_poll_posix(explicit_request); - grpc_poll_function = dummypoll; + real_poll_function = grpc_poll_function; + grpc_poll_function = dummy_poll; + return ret; } } // namespace |