Signal back to resolver on error

reviewable/pr4232/r5
Craig Tiller 9 years ago
parent d6ddc49da3
commit cb2609f475
  1. 7
      src/core/channel/client_channel.c
  2. 4
      src/core/client_config/lb_policies/pick_first.c
  3. 5
      src/core/client_config/resolver.c
  4. 6
      src/core/client_config/resolver.h
  5. 6
      src/core/client_config/resolvers/dns_resolver.c
  6. 6
      src/core/client_config/resolvers/sockaddr_resolver.c

@ -114,10 +114,15 @@ static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand,
static void on_lb_policy_state_changed_locked( static void on_lb_policy_state_changed_locked(
grpc_exec_ctx *exec_ctx, lb_policy_connectivity_watcher *w) { grpc_exec_ctx *exec_ctx, lb_policy_connectivity_watcher *w) {
grpc_connectivity_state publish_state = w->state;
/* check if the notification is for a stale policy */ /* check if the notification is for a stale policy */
if (w->lb_policy != w->chand->lb_policy) return; if (w->lb_policy != w->chand->lb_policy) return;
grpc_connectivity_state_set(exec_ctx, &w->chand->state_tracker, w->state, if ((publish_state == GRPC_CHANNEL_FATAL_FAILURE || publish_state == GRPC_CHANNEL_TRANSIENT_FAILURE) && w->chand->resolver != NULL) {
publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
grpc_resolver_channel_saw_error(exec_ctx, w->chand->resolver);
}
grpc_connectivity_state_set(exec_ctx, &w->chand->state_tracker, publish_state,
"lb_changed"); "lb_changed");
if (w->state != GRPC_CHANNEL_FATAL_FAILURE) { if (w->state != GRPC_CHANNEL_FATAL_FAILURE) {
watch_lb_policy(exec_ctx, w->chand, w->lb_policy, w->state); watch_lb_policy(exec_ctx, w->chand, w->lb_policy, w->state);

@ -243,6 +243,10 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_LB_POLICY_UNREF(exec_ctx, &p->base, "pick_first_connectivity"); GRPC_LB_POLICY_UNREF(exec_ctx, &p->base, "pick_first_connectivity");
return; return;
} else if (p->selected != NULL) { } else if (p->selected != NULL) {
if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* if the selected channel goes bad, we're done */
p->checking_connectivity = GRPC_CHANNEL_FATAL_FAILURE;
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker, grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
p->checking_connectivity, "selected_changed"); p->checking_connectivity, "selected_changed");
if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) { if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) {

@ -71,9 +71,8 @@ void grpc_resolver_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) {
} }
void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver, grpc_resolver *resolver) {
grpc_subchannel *subchannel) { resolver->vtable->channel_saw_error(exec_ctx, resolver);
resolver->vtable->channel_saw_error(exec_ctx, resolver, subchannel);
} }
void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,

@ -51,8 +51,7 @@ struct grpc_resolver {
struct grpc_resolver_vtable { struct grpc_resolver_vtable {
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
grpc_subchannel *subchannel);
void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_client_config **target_config, grpc_closure *on_complete); grpc_client_config **target_config, grpc_closure *on_complete);
}; };
@ -80,8 +79,7 @@ void grpc_resolver_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
/** Notification that the channel has seen an error on some address. /** Notification that the channel has seen an error on some address.
Can be used as a hint that re-resolution is desirable soon. */ Can be used as a hint that re-resolution is desirable soon. */
void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver, grpc_resolver *resolver);
grpc_subchannel *subchannel);
/** Get the next client config. Called by the channel to fetch a new /** Get the next client config. Called by the channel to fetch a new
configuration. Expected to set *target_config with a new configuration, configuration. Expected to set *target_config with a new configuration,

@ -81,8 +81,7 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
dns_resolver *r); dns_resolver *r);
static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r, static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
grpc_subchannel *subchannel);
static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r,
grpc_client_config **target_config, grpc_client_config **target_config,
grpc_closure *on_complete); grpc_closure *on_complete);
@ -102,8 +101,7 @@ static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) {
} }
static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver, grpc_resolver *resolver) {
grpc_subchannel *subchannel) {
dns_resolver *r = (dns_resolver *)resolver; dns_resolver *r = (dns_resolver *)resolver;
gpr_mu_lock(&r->mu); gpr_mu_lock(&r->mu);
if (!r->resolving) { if (!r->resolving) {

@ -83,8 +83,7 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx,
grpc_resolver *r, grpc_resolver *r);
grpc_subchannel *subchannel);
static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r,
grpc_client_config **target_config, grpc_client_config **target_config,
grpc_closure *on_complete); grpc_closure *on_complete);
@ -106,8 +105,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx,
} }
static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver, grpc_resolver *resolver) {
grpc_subchannel *subchannel) {
sockaddr_resolver *r = (sockaddr_resolver *)resolver; sockaddr_resolver *r = (sockaddr_resolver *)resolver;
gpr_mu_lock(&r->mu); gpr_mu_lock(&r->mu);
r->published = 0; r->published = 0;

Loading…
Cancel
Save