Remove optional parameter from watch connectivity state
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index b33d2cd..8db9587 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -414,14 +414,10 @@
Once the channel connectivity state is different from last_observed_state,
tag will be enqueued on cq with success=1.
If deadline expires BEFORE the state is changed, tag will be enqueued on cq
- with success=0.
- If optional_new_state is non-NULL, it will be set to the newly observed
- connectivity state of the channel at the same point as tag is enqueued onto
- the completion queue. */
+ with success=0. */
void grpc_channel_watch_connectivity_state(
grpc_channel *channel, grpc_connectivity_state last_observed_state,
- grpc_connectivity_state *optional_new_state, gpr_timespec deadline,
- grpc_completion_queue *cq, void *tag);
+ gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
/** Create a call given a grpc_channel, in order to call 'method'. All
completions are sent to 'completion_queue'. 'method' and 'host' need only
diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c
index b6ea86d..1223706 100644
--- a/src/core/surface/channel_connectivity.c
+++ b/src/core/surface/channel_connectivity.c
@@ -70,7 +70,6 @@
grpc_iomgr_closure on_complete;
grpc_alarm alarm;
grpc_connectivity_state state;
- grpc_connectivity_state *optional_new_state;
grpc_completion_queue *cq;
grpc_cq_completion completion_storage;
grpc_channel *channel;
@@ -124,9 +123,6 @@
switch (w->phase) {
case WAITING:
w->phase = CALLING_BACK;
- if (w->optional_new_state) {
- *w->optional_new_state = w->state;
- }
grpc_cq_end_op(w->cq, w->tag, w->success, finished_completion, w,
&w->completion_storage);
break;
@@ -154,8 +150,7 @@
void grpc_channel_watch_connectivity_state(
grpc_channel *channel, grpc_connectivity_state last_observed_state,
- grpc_connectivity_state *optional_new_state, gpr_timespec deadline,
- grpc_completion_queue *cq, void *tag) {
+ gpr_timespec deadline, grpc_completion_queue *cq, void *tag) {
grpc_channel_element *client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
state_watcher *w = gpr_malloc(sizeof(*w));
@@ -167,7 +162,6 @@
w->phase = WAITING;
w->state = last_observed_state;
w->success = 0;
- w->optional_new_state = optional_new_state;
w->cq = cq;
w->tag = tag;
w->channel = channel;
diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c
index 3917cad..c7568e1 100644
--- a/test/core/end2end/tests/channel_connectivity.c
+++ b/test/core/end2end/tests/channel_connectivity.c
@@ -54,7 +54,7 @@
/* start watching for a change */
grpc_channel_watch_connectivity_state(
- f.client, GRPC_CHANNEL_IDLE, &state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(1));
+ f.client, GRPC_CHANNEL_IDLE, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(1));
/* nothing should happen */
cq_verify_empty(cqv);
@@ -64,14 +64,17 @@
/* and now the watch should trigger */
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
GPR_ASSERT(state == GRPC_CHANNEL_CONNECTING);
/* quickly followed by a transition to TRANSIENT_FAILURE */
grpc_channel_watch_connectivity_state(
- f.client, GRPC_CHANNEL_CONNECTING, &state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(2));
+ f.client, GRPC_CHANNEL_CONNECTING, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(2));
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);
- GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
+ state == GRPC_CHANNEL_CONNECTING);
gpr_log(GPR_DEBUG, "*** STARTING SERVER ***");
@@ -84,10 +87,13 @@
READY is reached */
while (state != GRPC_CHANNEL_READY) {
grpc_channel_watch_connectivity_state(
- f.client, state, &state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3));
+ f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3));
cq_expect_completion(cqv, tag(3), 1);
cq_verify(cqv);
- GPR_ASSERT(state == GRPC_CHANNEL_READY || state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_READY ||
+ state == GRPC_CHANNEL_CONNECTING ||
+ state == GRPC_CHANNEL_TRANSIENT_FAILURE);
}
/* bring down the server again */
@@ -95,14 +101,16 @@
gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***");
grpc_channel_watch_connectivity_state(
- f.client, GRPC_CHANNEL_READY, &state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(4));
+ f.client, GRPC_CHANNEL_READY, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(4));
grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
cq_expect_completion(cqv, tag(4), 1);
cq_expect_completion(cqv, tag(0xdead), 1);
cq_verify(cqv);
- GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE);
+ state = grpc_channel_check_connectivity_state(f.client, 0);
+ GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
+ state == GRPC_CHANNEL_CONNECTING);
/* cleanup server */
grpc_server_destroy(f.server);