Fix exec_ctx in executor
diff --git a/src/core/lib/iomgr/executor.c b/src/core/lib/iomgr/executor.c
index 05ab928..2a2544d 100644
--- a/src/core/lib/iomgr/executor.c
+++ b/src/core/lib/iomgr/executor.c
@@ -124,6 +124,9 @@
thread_state *ts = arg;
gpr_tls_set(&g_this_thread_state, (intptr_t)ts);
+ grpc_exec_ctx exec_ctx =
+ GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
+
size_t subtract_depth = 0;
for (;;) {
gpr_mu_lock(&ts->mu);
@@ -139,10 +142,10 @@
ts->elems = (grpc_closure_list)GRPC_CLOSURE_LIST_INIT;
gpr_mu_unlock(&ts->mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
subtract_depth = run_closures(&exec_ctx, exec);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_exec_ctx_flush(&exec_ctx);
}
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void executor_push(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
@@ -157,6 +160,9 @@
ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
}
gpr_mu_lock(&ts->mu);
+ if (grpc_closure_list_empty(ts->elems)) {
+ gpr_cv_signal(&ts->cv);
+ }
grpc_closure_list_append(&ts->elems, closure, error);
ts->depth++;
bool try_new_thread =