From 7a514915a38c33a536777a5e851d037ed6dd4f74 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 16 Sep 2015 17:00:59 -0700 Subject: Move in-flight callback check up Fixes #3203 We entered a live lock race between the promotion callback and pollers, which was only resolved when the background executor got lucky enough to pick up the async work. --- src/core/iomgr/pollset_posix.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index dec2f5490f..f3e424e83c 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -187,6 +187,12 @@ void grpc_pollset_work(grpc_pollset *pollset, grpc_pollset_worker *worker, if (pollset->shutting_down) { goto done; } + if (pollset->in_flight_cbs) { + /* Give do_promote priority so we don't starve it out */ + gpr_mu_unlock(&pollset->mu); + gpr_mu_lock(&pollset->mu); + goto done; + } if (!pollset->kicked_without_pollers) { push_front_worker(pollset, worker); added_worker = 1; @@ -422,12 +428,6 @@ static void basic_pollset_maybe_work(grpc_pollset *pollset, int r; nfds_t nfds; - if (pollset->in_flight_cbs) { - /* Give do_promote priority so we don't starve it out */ - gpr_mu_unlock(&pollset->mu); - gpr_mu_lock(&pollset->mu); - return; - } fd = pollset->data.ptr; if (fd && grpc_fd_is_orphaned(fd)) { GRPC_FD_UNREF(fd, "basicpoll"); -- cgit v1.2.3