From d2cc45970b4681e214214199b9f52fc0e83cc9e9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Jul 2015 07:50:47 -0700 Subject: [PATCH] Spam cleanup, properly shut down lb_policy --- src/core/channel/client_channel.c | 3 +++ src/core/client_config/lb_policies/pick_first.c | 12 ++++++++++-- src/core/client_config/subchannel.c | 4 +++- src/core/iomgr/fd_posix.c | 1 - 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 6815ec8718e..95afc0d2e37 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -436,6 +436,9 @@ static void cc_start_transport_op(grpc_channel_element *elem, GRPC_CHANNEL_FATAL_FAILURE); destroy_resolver = chand->resolver; chand->resolver = NULL; + if (chand->lb_policy != NULL) { + grpc_lb_policy_shutdown(chand->lb_policy); + } } if (!is_empty(op, sizeof(*op))) { diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index ffdae75b283..3967350a9b8 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -85,8 +85,16 @@ void pf_destroy(grpc_lb_policy *pol) { } void pf_shutdown(grpc_lb_policy *pol) { - /* pick_first_lb_policy *p = (pick_first_lb_policy*)pol; */ - abort(); + pick_first_lb_policy *p = (pick_first_lb_policy*)pol; + pending_pick *pp; + gpr_mu_lock(&p->mu); + while ((pp = p->pending_picks)) { + p->pending_picks = pp->next; + *pp->target = NULL; + grpc_iomgr_add_delayed_callback(pp->on_complete, 0); + gpr_free(pp); + } + gpr_mu_unlock(&p->mu); } void pf_pick(grpc_lb_policy *pol, grpc_pollset *pollset, diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index cde14b92223..05fd02fb0ab 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -562,6 +562,9 @@ static void on_alarm(void *arg, int iomgr_success) { grpc_subchannel *c = arg; gpr_mu_lock(&c->mu); c->have_alarm = 0; + if (c->disconnected) { + iomgr_success = 0; + } connectivity_state_changed_locked(c); gpr_mu_unlock(&c->mu); if (iomgr_success) { @@ -609,7 +612,6 @@ static grpc_connectivity_state compute_connectivity_locked(grpc_subchannel *c) { static void connectivity_state_changed_locked(grpc_subchannel *c) { grpc_connectivity_state current = compute_connectivity_locked(c); - gpr_log(GPR_DEBUG, "SUBCHANNEL constate=%d", current); grpc_connectivity_state_set(&c->state_tracker, current); } diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index afecccae170..2075c43945d 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -159,7 +159,6 @@ void grpc_fd_global_shutdown(void) { grpc_fd *grpc_fd_create(int fd, const char *name) { grpc_fd *r = alloc_fd(fd); - gpr_log(GPR_DEBUG, "FD %d %p create", r->fd, r); grpc_iomgr_register_object(&r->iomgr_object, name); return r; }