diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c index 7570ff18c59..bcef7c35b5d 100644 --- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c +++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c @@ -172,6 +172,9 @@ static int multipoll_with_poll_pollset_maybe_work( } r = poll(h->pfds, h->pfd_count, timeout); + + end_polling(pollset); + if (r < 0) { if (errno != EINTR) { gpr_log(GPR_ERROR, "poll() failed: %s", strerror(errno)); @@ -192,7 +195,6 @@ static int multipoll_with_poll_pollset_maybe_work( } } grpc_pollset_kick_post_poll(&pollset->kick_state); - end_polling(pollset); gpr_mu_lock(&pollset->mu); pollset->counter = 0; diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 0bb722e2b12..03fd94f1364 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -396,6 +396,9 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout); + + grpc_fd_end_poll(&fd_watcher); + if (r < 0) { if (errno != EINTR) { gpr_log(GPR_ERROR, "poll() failed: %s", strerror(errno)); @@ -415,7 +418,6 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, } grpc_pollset_kick_post_poll(&pollset->kick_state); - grpc_fd_end_poll(&fd_watcher); gpr_mu_lock(&pollset->mu); pollset->counter = 0;