Skip to content
Snippets Groups Projects
Commit 06ba6cb9 authored by Vijay Pai's avatar Vijay Pai
Browse files

Merge pull request #5625 from ctiller/node_failure

Potential fix for race condition exposed by Node
parents 6537ab9d 84774b6c
No related branches found
No related tags found
No related merge requests found
...@@ -168,21 +168,23 @@ retry: ...@@ -168,21 +168,23 @@ retry:
static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, bool success) { static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
grpc_subchannel_call_holder *holder = arg; grpc_subchannel_call_holder *holder = arg;
grpc_subchannel_call *call;
gpr_mu_lock(&holder->mu); gpr_mu_lock(&holder->mu);
GPR_ASSERT(holder->creation_phase == GPR_ASSERT(holder->creation_phase ==
GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL);
call = GET_CALL(holder);
GPR_ASSERT(call == NULL || call == CANCELLED_CALL);
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
if (holder->connected_subchannel == NULL) { if (holder->connected_subchannel == NULL) {
fail_locked(exec_ctx, holder); fail_locked(exec_ctx, holder);
} else { } else {
gpr_atm_rel_store( if (!gpr_atm_rel_cas(
&holder->subchannel_call, &holder->subchannel_call, 0,
(gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call( (gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call(
exec_ctx, holder->connected_subchannel, holder->pollset)); exec_ctx, holder->connected_subchannel, holder->pollset))) {
retry_waiting_locked(exec_ctx, holder); GPR_ASSERT(gpr_atm_acq_load(&holder->subchannel_call) == 1);
/* if this cas fails, the call was cancelled before the pick completed */
fail_locked(exec_ctx, holder);
} else {
retry_waiting_locked(exec_ctx, holder);
}
} }
gpr_mu_unlock(&holder->mu); gpr_mu_unlock(&holder->mu);
GRPC_CALL_STACK_UNREF(exec_ctx, holder->owning_call, "pick_subchannel"); GRPC_CALL_STACK_UNREF(exec_ctx, holder->owning_call, "pick_subchannel");
......
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