diff options
author | murgatroid99 <mlumish@google.com> | 2015-09-22 14:13:44 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-09-22 14:13:44 -0700 |
commit | 521300e6e882529c08362321afb9821a2912e265 (patch) | |
tree | fd22df2fa1b1aebc5ebac62181e9a4d2b482202b /src/core/surface/channel_connectivity.c | |
parent | 08fac99e73d815c7f3527c84a84dce315816e13c (diff) | |
parent | e456f77644e5ef5b60c7332136047ab3f5d4454e (diff) |
Merge branch 'master' into core_gyp
Diffstat (limited to 'src/core/surface/channel_connectivity.c')
-rw-r--r-- | src/core/surface/channel_connectivity.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c index 88a7c16598..5c55ad3655 100644 --- a/src/core/surface/channel_connectivity.c +++ b/src/core/surface/channel_connectivity.c @@ -67,6 +67,7 @@ typedef struct { gpr_mu mu; callback_phase phase; int success; + int removed; grpc_iomgr_closure on_complete; grpc_alarm alarm; grpc_connectivity_state state; @@ -77,10 +78,6 @@ typedef struct { } state_watcher; static void delete_state_watcher(state_watcher *w) { - grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element( - grpc_channel_get_channel_stack(w->channel)); - grpc_client_channel_del_interested_party(client_channel_elem, - grpc_cq_pollset(w->cq)); GRPC_CHANNEL_INTERNAL_UNREF(w->channel, "watch_connectivity"); gpr_mu_destroy(&w->mu); gpr_free(w); @@ -112,7 +109,17 @@ static void finished_completion(void *pw, grpc_cq_completion *ignored) { static void partly_done(state_watcher *w, int due_to_completion) { int delete = 0; + grpc_channel_element *client_channel_elem = NULL; + gpr_mu_lock(&w->mu); + if (w->removed == 0) { + w->removed = 1; + client_channel_elem = grpc_channel_stack_last_element( + grpc_channel_get_channel_stack(w->channel)); + grpc_client_channel_del_interested_party(client_channel_elem, + grpc_cq_pollset(w->cq)); + } + gpr_mu_unlock(&w->mu); if (due_to_completion) { gpr_mu_lock(&w->mu); w->success = 1; @@ -163,6 +170,7 @@ void grpc_channel_watch_connectivity_state( w->phase = WAITING; w->state = last_observed_state; w->success = 0; + w->removed = 0; w->cq = cq; w->tag = tag; w->channel = channel; |