|
|
|
@ -188,8 +188,14 @@ void PickFirst::ShutdownLocked() { |
|
|
|
|
void PickFirst::ExitIdleLocked() { |
|
|
|
|
if (idle_) { |
|
|
|
|
idle_ = false; |
|
|
|
|
if (subchannel_list_ != nullptr && |
|
|
|
|
subchannel_list_->num_subchannels() > 0) { |
|
|
|
|
if (subchannel_list_ == nullptr || |
|
|
|
|
subchannel_list_->num_subchannels() == 0) { |
|
|
|
|
grpc_error* error = |
|
|
|
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No addresses to connect to"); |
|
|
|
|
channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
} else { |
|
|
|
|
subchannel_list_->subchannel(0) |
|
|
|
|
->CheckConnectivityStateAndStartWatchingLocked(); |
|
|
|
|
} |
|
|
|
@ -253,13 +259,19 @@ void PickFirst::UpdateLocked(UpdateArgs args) { |
|
|
|
|
grpc_channel_args_destroy(new_args); |
|
|
|
|
if (subchannel_list->num_subchannels() == 0) { |
|
|
|
|
// Empty update or no valid subchannels. Unsubscribe from all current
|
|
|
|
|
// subchannels and put the channel in TRANSIENT_FAILURE.
|
|
|
|
|
// subchannels.
|
|
|
|
|
subchannel_list_ = std::move(subchannel_list); // Empty list.
|
|
|
|
|
selected_ = nullptr; |
|
|
|
|
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"); |
|
|
|
|
channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
// If not idle, put the channel in TRANSIENT_FAILURE.
|
|
|
|
|
// (If we are idle, then this will happen in ExitIdleLocked() if we
|
|
|
|
|
// haven't gotten a non-empty update by the time the application tries
|
|
|
|
|
// to start a new call.)
|
|
|
|
|
if (!idle_) { |
|
|
|
|
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"); |
|
|
|
|
channel_control_helper()->UpdateState( |
|
|
|
|
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), |
|
|
|
|
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// If one of the subchannels in the new list is already in state
|
|
|
|
|