diff options
author | 2015-06-30 08:15:55 -0700 | |
---|---|---|
committer | 2015-06-30 08:15:55 -0700 | |
commit | 87cc0848ce279892cce562b3aa6cfae870d05e50 (patch) | |
tree | 2a73f3e12faf66bc8094492b4be4d35a76a80b6c /src/core/client_config | |
parent | b49736829a3e9bf4140b17465ff6c208462e783f (diff) |
client_config bugfixes
Diffstat (limited to 'src/core/client_config')
-rw-r--r-- | src/core/client_config/lb_policies/pick_first.c | 17 | ||||
-rw-r--r-- | src/core/client_config/subchannel.c | 7 | ||||
-rw-r--r-- | src/core/client_config/subchannel.h | 2 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index a8e5b5cc4a..ffdae75b28 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -176,15 +176,20 @@ loop: del_interested_parties_locked(p); GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel], p->subchannels[p->num_subchannels - 1]); - p->checking_subchannel %= p->num_subchannels; - p->checking_connectivity = grpc_subchannel_check_connectivity( - p->subchannels[p->checking_subchannel]); p->num_subchannels--; - GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); - add_interested_parties_locked(p); if (p->num_subchannels == 0) { - abort(); + while ((pp = p->pending_picks)) { + p->pending_picks = pp->next; + *pp->target = NULL; + grpc_iomgr_add_delayed_callback(pp->on_complete, 1); + gpr_free(pp); + } } else { + p->checking_subchannel %= p->num_subchannels; + p->checking_connectivity = grpc_subchannel_check_connectivity( + p->subchannels[p->checking_subchannel]); + GRPC_SUBCHANNEL_UNREF(p->subchannels[p->num_subchannels], "pick_first"); + add_interested_parties_locked(p); goto loop; } } diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index cae6db0110..d16786a7ad 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -546,6 +546,7 @@ static void on_alarm(void *arg, int iomgr_success) { grpc_subchannel *c = arg; gpr_mu_lock(&c->mu); c->have_alarm = 0; + connectivity_state_changed_locked(c); gpr_mu_unlock(&c->mu); if (iomgr_success) { continue_connect(c); @@ -560,6 +561,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { publish_transport(c); } else { gpr_mu_lock(&c->mu); + connectivity_state_changed_locked(c); GPR_ASSERT(!c->have_alarm); c->have_alarm = 1; c->next_attempt = gpr_time_add(c->next_attempt, c->backoff_delta); @@ -570,7 +572,7 @@ static void subchannel_connected(void *arg, int iomgr_success) { } static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { - return gpr_time_add(gpr_now(), gpr_time_from_seconds(60)); + return gpr_time_add(c->next_attempt, c->backoff_delta); } static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { @@ -578,6 +580,9 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { return GRPC_CHANNEL_FATAL_FAILURE; } if (c->connecting) { + if (c->have_alarm) { + return GRPC_CHANNEL_TRANSIENT_FAILURE; + } return GRPC_CHANNEL_CONNECTING; } if (c->active) { diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index 03bd4f63e0..5435ef703b 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -43,8 +43,6 @@ typedef struct grpc_subchannel grpc_subchannel; typedef struct grpc_subchannel_call grpc_subchannel_call; typedef struct grpc_subchannel_args grpc_subchannel_args; -#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG - #ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG #define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p), __FILE__, __LINE__, (r)) #define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p), __FILE__, __LINE__, (r)) |