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

Merge pull request #5529 from ctiller/racy

Fix esan detected race in subchannel state
parents e788e8bf 8e19f61d
No related branches found
No related tags found
No related merge requests found
...@@ -395,7 +395,6 @@ void grpc_subchannel_notify_on_state_change( ...@@ -395,7 +395,6 @@ void grpc_subchannel_notify_on_state_change(
grpc_exec_ctx *exec_ctx, grpc_subchannel *c, grpc_exec_ctx *exec_ctx, grpc_subchannel *c,
grpc_pollset_set *interested_parties, grpc_connectivity_state *state, grpc_pollset_set *interested_parties, grpc_connectivity_state *state,
grpc_closure *notify) { grpc_closure *notify) {
int do_connect = 0;
external_state_watcher *w; external_state_watcher *w;
if (state == NULL) { if (state == NULL) {
...@@ -425,17 +424,13 @@ void grpc_subchannel_notify_on_state_change( ...@@ -425,17 +424,13 @@ void grpc_subchannel_notify_on_state_change(
w->next->prev = w->prev->next = w; w->next->prev = w->prev->next = w;
if (grpc_connectivity_state_notify_on_state_change( if (grpc_connectivity_state_notify_on_state_change(
exec_ctx, &c->state_tracker, state, &w->closure)) { exec_ctx, &c->state_tracker, state, &w->closure)) {
do_connect = 1;
c->connecting = 1; c->connecting = 1;
/* released by connection */ /* released by connection */
GRPC_SUBCHANNEL_WEAK_REF(c, "connecting"); GRPC_SUBCHANNEL_WEAK_REF(c, "connecting");
start_connect(exec_ctx, c);
} }
gpr_mu_unlock(&c->mu); gpr_mu_unlock(&c->mu);
} }
if (do_connect) {
start_connect(exec_ctx, c);
}
} }
void grpc_connected_subchannel_process_transport_op( void grpc_connected_subchannel_process_transport_op(
...@@ -635,11 +630,12 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, bool iomgr_success) { ...@@ -635,11 +630,12 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, bool iomgr_success) {
if (c->disconnected) { if (c->disconnected) {
iomgr_success = 0; iomgr_success = 0;
} }
gpr_mu_unlock(&c->mu);
if (iomgr_success) { if (iomgr_success) {
update_reconnect_parameters(c); update_reconnect_parameters(c);
continue_connect(exec_ctx, c); continue_connect(exec_ctx, c);
gpr_mu_unlock(&c->mu);
} else { } else {
gpr_mu_unlock(&c->mu);
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
} }
} }
......
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