diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 7d66d0acd9a..03e5c892813 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -433,18 +433,12 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( grpc_connectivity_state_name(connectivity_state()), p->shutdown_, subchannel_list()->shutting_down(), grpc_error_string(error)); } - // If the policy is shutting down, unref and return. - if (p->shutdown_) { - StopConnectivityWatchLocked(); - UnrefSubchannelLocked("pf_shutdown"); - subchannel_list()->UnrefForConnectivityWatch("pf_shutdown"); - return; - } // If the subchannel list is shutting down, stop watching. if (subchannel_list()->shutting_down() || error == GRPC_ERROR_CANCELLED) { StopConnectivityWatchLocked(); UnrefSubchannelLocked("pf_sl_shutdown"); subchannel_list()->UnrefForConnectivityWatch("pf_sl_shutdown"); + GRPC_ERROR_UNREF(error); return; } // If we're still here, the notification must be for a subchannel in @@ -492,6 +486,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( StartConnectivityWatchLocked(); } } + GRPC_ERROR_UNREF(error); return; } // If we get here, there are two possible cases: @@ -574,6 +569,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( case GRPC_CHANNEL_SHUTDOWN: GPR_UNREACHABLE_CODE(break); } + GRPC_ERROR_UNREF(error); } // diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index db093c8f53e..555ae62aa2d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -600,6 +600,7 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( StopConnectivityWatchLocked(); UnrefSubchannelLocked("rr_sl_shutdown"); subchannel_list()->UnrefForConnectivityWatch("rr_sl_shutdown"); + GRPC_ERROR_UNREF(error); return; } // Process the state change. @@ -640,6 +641,7 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( subchannel_list()->UpdateOverallStateLocked(); StartConnectivityWatchLocked(); } + GRPC_ERROR_UNREF(error); } grpc_connectivity_state RoundRobin::CheckConnectivityLocked( diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 73d598e9f19..b3fc5fefe9c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -124,6 +124,8 @@ class SubchannelData { if (pending_connectivity_state_unsafe_ != curr_connectivity_state_) { curr_connectivity_state_ = pending_connectivity_state_unsafe_; ProcessConnectivityChangeLocked(error); + } else { + GRPC_ERROR_UNREF(error); } } @@ -354,7 +356,7 @@ void SubchannelData:: if (sd->curr_connectivity_state_ == GRPC_CHANNEL_TRANSIENT_FAILURE) { sd->connected_subchannel_.reset(); } - sd->ProcessConnectivityChangeLocked(error); + sd->ProcessConnectivityChangeLocked(GRPC_ERROR_REF(error)); } template