From 3d073c261eafe3ba1d9f7fb098ee1ddd1037334a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 4 Oct 2017 22:10:58 +0000 Subject: [PATCH] Fix kicking --- src/core/lib/iomgr/ev_epollex_linux.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index 396731758e0..45aee891cbd 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -542,7 +542,7 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx *exec_ctx, static grpc_error *pollset_kick_one(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *specific_worker) { - pollable *p = pollset->active_pollable; + pollable *p = specific_worker->pollable_obj; GPR_ASSERT(specific_worker != NULL); if (specific_worker->kicked) { if (GRPC_TRACER_ON(grpc_polling_trace)) { @@ -563,6 +563,7 @@ GPR_ASSERT(specific_worker != NULL); specific_worker->kicked = true; return grpc_wakeup_fd_wakeup(&p->wakeup); } else { + GPR_ASSERT(specific_worker->initialized_cv); if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p); } @@ -577,20 +578,17 @@ GPR_ASSERT(specific_worker != NULL); static grpc_error *pollset_kick_inner(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *specific_worker) { - pollable *p = pollset->active_pollable; if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, - "PS:%p kick %p tls_pollset=%p tls_worker=%p " - "root_worker=(pollset:%p pollable:%p)", - p, specific_worker, (void *)gpr_tls_get(&g_current_thread_pollset), - (void *)gpr_tls_get(&g_current_thread_worker), pollset->root_worker, - p->root_worker); + "PS:%p kick %p tls_pollset=%p tls_worker=%p pollset.root_worker=%p", + pollset, specific_worker, (void *)gpr_tls_get(&g_current_thread_pollset), + (void *)gpr_tls_get(&g_current_thread_worker), pollset->root_worker); } if (specific_worker == NULL) { if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) { if (pollset->root_worker == NULL) { if (GRPC_TRACER_ON(grpc_polling_trace)) { - gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", p); + gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset); } pollset->kicked_without_poller = true; return GRPC_ERROR_NONE; @@ -599,7 +597,7 @@ static grpc_error *pollset_kick_inner(grpc_exec_ctx *exec_ctx, } } else { if (GRPC_TRACER_ON(grpc_polling_trace)) { - gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", p); + gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", pollset); } return GRPC_ERROR_NONE; } @@ -905,9 +903,11 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, if (worker->initialized_cv) { gpr_cv_destroy(&worker->cv); } - gpr_mu_unlock(&worker->pollable_obj->mu); if (worker_remove(&pollset->root_worker, worker, PWLINK_POLLSET)) { + gpr_mu_unlock(&worker->pollable_obj->mu); pollset_maybe_finish_shutdown(exec_ctx, pollset); + } else { + gpr_mu_unlock(&worker->pollable_obj->mu); } POLLABLE_UNREF(worker->pollable_obj, "pollset_worker"); }