aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2017-08-21 15:20:58 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2017-08-21 15:20:58 -0700
commita2c1df4dcd5b93155389b9d1e8fad147fbb51e53 (patch)
tree2361d2966785cbb0d1b69c3910794106b45ea82f /src
parent183a9cf52304b2caf92337a06cc5a47fd023cad6 (diff)
RR: Initialize subchannel connectivity state
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
index a7f7e9542c..a63bdd933d 100644
--- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
@@ -811,19 +811,30 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
sc_args.args = new_args;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
exec_ctx, args->client_channel_factory, &sc_args);
+ grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_error *error;
+ // Get the connectivity state of the subchannel. Already existing ones may
+ // be in a state other than INIT.
+ const grpc_connectivity_state subchannel_connectivity_state =
+ grpc_subchannel_check_connectivity(subchannel, &error);
+ if (error != GRPC_ERROR_NONE) {
+ // The subchannel is in error (e.g. shutting down). Ignore it.
+ GRPC_SUBCHANNEL_UNREF(exec_ctx, subchannel, "new_sc_connectivity_error");
+ GRPC_ERROR_UNREF(error);
+ continue;
+ }
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
char *address_uri =
grpc_sockaddr_to_uri(&addresses->addresses[i].address);
gpr_log(
GPR_DEBUG,
"[RR %p] index %lu: Created subchannel %p for address uri %s into "
- "subchannel_list %p",
+ "subchannel_list %p. Connectivity state %s",
(void *)p, (unsigned long)subchannel_index, (void *)subchannel,
- address_uri, (void *)subchannel_list);
+ address_uri, (void *)subchannel_list,
+ grpc_connectivity_state_name(subchannel_connectivity_state));
gpr_free(address_uri);
}
- grpc_channel_args_destroy(exec_ctx, new_args);
-
subchannel_data *sd = &subchannel_list->subchannels[subchannel_index++];
sd->subchannel_list = subchannel_list;
sd->subchannel = subchannel;
@@ -835,7 +846,7 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
* won't be referring to this value again and it'll be overwritten after
* the first call to rr_connectivity_changed_locked */
sd->prev_connectivity_state = GRPC_CHANNEL_INIT;
- sd->curr_connectivity_state = GRPC_CHANNEL_IDLE;
+ sd->curr_connectivity_state = subchannel_connectivity_state;
sd->user_data_vtable = addresses->user_data_vtable;
if (sd->user_data_vtable != NULL) {
sd->user_data =