Fixes, and some test code

reviewable/pr4232/r5
Craig Tiller 9 years ago
parent 486130455f
commit 2a1bb7f0ca
  1. 5
      src/core/client_config/lb_policies/pick_first.c
  2. 16
      src/core/client_config/lb_policies/round_robin.c
  3. 2
      src/core/client_config/subchannel.c
  4. 2
      src/core/iomgr/fd_posix.h
  5. 7
      test/core/end2end/fixtures/h2_uchannel.c

@ -96,7 +96,6 @@ void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
pending_pick *pp;
gpr_mu_lock(&p->mu);
gpr_log(GPR_DEBUG, "LB_POLICY: pf_shutdown: %p", p);
p->shutdown = 1;
pp = p->pending_picks;
p->pending_picks = NULL;
@ -105,7 +104,7 @@ void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
if (p->selected != NULL) {
grpc_connected_subchannel_notify_on_state_change(exec_ctx, p->selected, NULL, &p->connectivity_changed);
} else {
grpc_subchannel_notify_on_state_change(exec_ctx, p->subchannels[p->checking_connectivity], NULL, NULL, &p->connectivity_changed);
grpc_subchannel_notify_on_state_change(exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL, &p->connectivity_changed);
}
gpr_mu_unlock(&p->mu);
while (pp != NULL) {
@ -218,8 +217,6 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_lock(&p->mu);
gpr_log(GPR_DEBUG, "LB_POLICY: pf_connectivity_changed: %p success=%d shutdown=%d", p, iomgr_success, p->shutdown);
if (p->shutdown) {
gpr_mu_unlock(&p->mu);
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pick_first_connectivity");

@ -232,6 +232,10 @@ void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
pending_pick *pp;
size_t i;
gpr_log(GPR_DEBUG, "LB_POLICY: rr_shutdown: p=%p num_subchannels=%d", p, p->num_subchannels);
gpr_mu_lock(&p->mu);
p->shutdown = 1;
@ -243,6 +247,12 @@ void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE, "shutdown");
for (i = 0; i < p->num_subchannels; i++) {
grpc_subchannel_notify_on_state_change(exec_ctx, p->subchannels[i],
NULL,
NULL,
&p->connectivity_changed_cbs[i]);
}
gpr_mu_unlock(&p->mu);
}
@ -273,13 +283,15 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) {
size_t i;
p->started_picking = 1;
gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%d", p, p->num_subchannels);
for (i = 0; i < p->num_subchannels; i++) {
p->subchannel_connectivity[i] = GRPC_CHANNEL_IDLE;
grpc_subchannel_notify_on_state_change(exec_ctx, p->subchannels[i],
&p->base.interested_parties,
&p->subchannel_connectivity[i],
&p->connectivity_changed_cbs[i]);
GRPC_LB_POLICY_REF(&p->base, "round_robin_connectivity");
GRPC_LB_POLICY_WEAK_REF(&p->base, "round_robin_connectivity");
}
}
@ -447,7 +459,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_unlock(&p->mu);
if (unref) {
GRPC_LB_POLICY_UNREF(exec_ctx, &p->base, "round_robin_connectivity");
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "round_robin_connectivity");
}
}

@ -348,6 +348,8 @@ void grpc_subchannel_notify_on_state_change(grpc_exec_ctx *exec_ctx,
int do_connect = 0;
external_state_watcher *w;
gpr_log(GPR_DEBUG, "sc.nosc: c=%p s=%p n=%p", c, state, notify);
if (state == NULL) {
gpr_mu_lock(&c->mu);
for (w = c->root_external_state_watcher.next;

@ -168,7 +168,7 @@ void grpc_fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd);
void grpc_fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd);
/* Reference counting for fds */
#define GRPC_FD_REF_COUNT_DEBUG
/*#define GRPC_FD_REF_COUNT_DEBUG*/
#ifdef GRPC_FD_REF_COUNT_DEBUG
void grpc_fd_ref(grpc_fd *fd, const char *reason, const char *file, int line);
void grpc_fd_unref(grpc_fd *fd, const char *reason, const char *file, int line);

@ -163,6 +163,7 @@ static grpc_subchannel *subchannel_factory_create_subchannel(
grpc_connector_unref(exec_ctx, &c->base);
grpc_channel_args_destroy(final_args);
*f->sniffed_subchannel = s;
GRPC_SUBCHANNEL_REF(s, "sniffed");
return s;
}
@ -316,11 +317,15 @@ static void chttp2_init_server_micro_fullstack(grpc_end2end_test_fixture *f,
}
static void chttp2_tear_down_micro_fullstack(grpc_end2end_test_fixture *f) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
micro_fullstack_fixture_data *ffd = f->fixture_data;
grpc_channel_destroy(ffd->master_channel);
ffd->master_channel = NULL;
if (ffd->sniffed_subchannel) {
GRPC_SUBCHANNEL_UNREF(&exec_ctx, ffd->sniffed_subchannel, "sniffed");
}
gpr_free(ffd->localaddr);
gpr_free(ffd);
grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */

Loading…
Cancel
Save