Skip to content
Snippets Groups Projects
Commit 556e5ae5 authored by Craig Tiller's avatar Craig Tiller
Browse files

Fix accelerated wakeups

We can end up in situations where a pollset needs to kick itself.

This is supposed to be an accelerated codepath, however a bug crept in
whereby we missed the opportunity to do so, resulting in needing to
round trip these wakeups redundantly through the OS and wake other
threads unnecessarily.
parent effd74c3
No related branches found
No related tags found
No related merge requests found
...@@ -824,6 +824,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ...@@ -824,6 +824,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
re-evaluate our pollers (this allows poll() based pollers to re-evaluate our pollers (this allows poll() based pollers to
ensure they don't miss wakeups) */ ensure they don't miss wakeups) */
keep_polling = 1; keep_polling = 1;
gpr_tls_set(&g_current_thread_poller, (intptr_t)pollset);
while (keep_polling) { while (keep_polling) {
keep_polling = 0; keep_polling = 0;
if (!pollset->kicked_without_pollers) { if (!pollset->kicked_without_pollers) {
...@@ -832,7 +833,6 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ...@@ -832,7 +833,6 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
added_worker = 1; added_worker = 1;
gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker); gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
} }
gpr_tls_set(&g_current_thread_poller, (intptr_t)pollset);
GPR_TIMER_BEGIN("maybe_work_and_unlock", 0); GPR_TIMER_BEGIN("maybe_work_and_unlock", 0);
#define POLLOUT_CHECK (POLLOUT | POLLHUP | POLLERR) #define POLLOUT_CHECK (POLLOUT | POLLHUP | POLLERR)
#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR) #define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR)
...@@ -926,7 +926,6 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ...@@ -926,7 +926,6 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
gpr_free(watchers); gpr_free(watchers);
GPR_TIMER_END("maybe_work_and_unlock", 0); GPR_TIMER_END("maybe_work_and_unlock", 0);
locked = 0; locked = 0;
gpr_tls_set(&g_current_thread_poller, 0);
} else { } else {
GPR_TIMER_MARK("pollset_work.kicked_without_pollers", 0); GPR_TIMER_MARK("pollset_work.kicked_without_pollers", 0);
pollset->kicked_without_pollers = 0; pollset->kicked_without_pollers = 0;
...@@ -958,6 +957,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ...@@ -958,6 +957,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
now = gpr_now(now.clock_type); now = gpr_now(now.clock_type);
} }
} }
gpr_tls_set(&g_current_thread_poller, 0);
if (added_worker) { if (added_worker) {
remove_worker(pollset, &worker); remove_worker(pollset, &worker);
gpr_tls_set(&g_current_thread_worker, 0); gpr_tls_set(&g_current_thread_worker, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment