aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/surface/channel_connectivity.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-07-16 16:19:14 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-07-16 16:19:14 -0700
commit1ada6ad8e57e9033f9cc9a6b0082e27a413e9584 (patch)
tree282cbc4f22d5e25edf155654b9734501845f1ebf /src/core/surface/channel_connectivity.c
parent48cb07c9096250374d8d9288452195cd9b90ce16 (diff)
Added connectivity tests, fixed bugs
Diffstat (limited to 'src/core/surface/channel_connectivity.c')
-rw-r--r--src/core/surface/channel_connectivity.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c
index bdd9678d66..dd12ff5611 100644
--- a/src/core/surface/channel_connectivity.c
+++ b/src/core/surface/channel_connectivity.c
@@ -73,10 +73,15 @@ typedef struct {
grpc_connectivity_state *optional_new_state;
grpc_completion_queue *cq;
grpc_cq_completion completion_storage;
+ grpc_channel *channel;
void *tag;
} 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);
}
@@ -143,9 +148,9 @@ static void partly_done(state_watcher *w, int due_to_completion) {
}
}
-static void watch_complete(void *pw, int success) { partly_done(pw, 0); }
+static void watch_complete(void *pw, int success) { partly_done(pw, 1); }
-static void timeout_complete(void *pw, int success) { partly_done(pw, 1); }
+static void timeout_complete(void *pw, int success) { partly_done(pw, 0); }
void grpc_channel_watch_connectivity_state(
grpc_channel *channel, grpc_connectivity_state last_observed_state,
@@ -165,6 +170,7 @@ void grpc_channel_watch_connectivity_state(
w->optional_new_state = optional_new_state;
w->cq = cq;
w->tag = tag;
+ w->channel = channel;
grpc_alarm_init(&w->alarm, deadline, timeout_complete, w,
gpr_now(GPR_CLOCK_REALTIME));
@@ -176,6 +182,8 @@ void grpc_channel_watch_connectivity_state(
client_channel_elem->filter->name);
grpc_iomgr_add_delayed_callback(&w->on_complete, 1);
} else {
+ GRPC_CHANNEL_INTERNAL_REF(channel, "watch_connectivity");
+ grpc_client_channel_add_interested_party(client_channel_elem, grpc_cq_pollset(cq));
grpc_client_channel_watch_connectivity_state(client_channel_elem, &w->state,
&w->on_complete);
}