From 0c4c9d78b539ae7fcbfce2b4372811bb6b4a19d8 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 5 Apr 2018 19:39:10 -0700 Subject: [PATCH] poll-cv fix for zero timeout --- src/core/lib/iomgr/ev_poll_posix.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 2e375b40226..d9aba9b6a3b 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -1530,6 +1530,12 @@ static void run_poll(void* args) { // This function overrides poll() to handle condition variable wakeup fds static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) { + if (timeout == 0) { + // Don't bother using background threads for polling if timeout is 0, + // poll-cv might not wait for a poll to return otherwise. + // https://github.com/grpc/grpc/issues/13298 + return poll(fds, nfds, 0); + } unsigned int i; int res, idx; grpc_cv_node* pollcv;