Skip to content

Commit

Permalink
Merge pull request grpc#6761 from ctiller/there-were-no-fatalities
Browse files Browse the repository at this point in the history
Rename GRPC_CHANNEL_FATAL_FAILURE --> GRPC_CHANNEL_SHUTDOWN
  • Loading branch information
jtattermusch committed Jun 3, 2016
2 parents 3dbafd5 + 48ed92e commit d38b2c4
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 44 deletions.
2 changes: 1 addition & 1 deletion include/grpc/impl/codegen/connectivity_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef enum {
/** channel has seen a failure but expects to recover */
GRPC_CHANNEL_TRANSIENT_FAILURE,
/** channel has seen a failure that it cannot recover from */
GRPC_CHANNEL_FATAL_FAILURE
GRPC_CHANNEL_SHUTDOWN
} grpc_connectivity_state;

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/core/ext/client_config/channel_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
"not a (u)client channel, but '%s'",
client_channel_elem->filter->name);
grpc_exec_ctx_finish(&exec_ctx);
return GRPC_CHANNEL_FATAL_FAILURE;
return GRPC_CHANNEL_SHUTDOWN;
}

typedef enum {
Expand Down
13 changes: 6 additions & 7 deletions src/core/ext/client_config/client_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
grpc_connectivity_state state,
const char *reason) {
if ((state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
state == GRPC_CHANNEL_FATAL_FAILURE) &&
state == GRPC_CHANNEL_SHUTDOWN) &&
chand->lb_policy != NULL) {
/* cancel fail-fast picks */
grpc_lb_policy_cancel_picks(
Expand All @@ -136,16 +136,15 @@ static void on_lb_policy_state_changed_locked(
/* check if the notification is for a stale policy */
if (w->lb_policy != w->chand->lb_policy) return;

if (publish_state == GRPC_CHANNEL_FATAL_FAILURE &&
w->chand->resolver != NULL) {
if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != NULL) {
publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
grpc_resolver_channel_saw_error(exec_ctx, w->chand->resolver);
GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel");
w->chand->lb_policy = NULL;
}
set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
"lb_changed");
if (w->state != GRPC_CHANNEL_FATAL_FAILURE) {
if (w->state != GRPC_CHANNEL_SHUTDOWN) {
watch_lb_policy(exec_ctx, w->chand, w->lb_policy, w->state);
}
}
Expand Down Expand Up @@ -237,7 +236,7 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg,
chand->resolver = NULL;
}
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_FATAL_FAILURE, "resolver_gone");
exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN, "resolver_gone");
gpr_mu_unlock(&chand->mu_config);
}

Expand Down Expand Up @@ -292,8 +291,8 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
}

if (op->disconnect && chand->resolver != NULL) {
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_FATAL_FAILURE, "disconnect");
set_channel_connectivity_state_locked(exec_ctx, chand,
GRPC_CHANNEL_SHUTDOWN, "disconnect");
grpc_resolver_shutdown(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
chand->resolver = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/core/ext/client_config/subchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,11 @@ static void subchannel_on_child_state_changed(grpc_exec_ctx *exec_ctx, void *p,
if (iomgr_success) {
if (sw->connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* any errors on a subchannel ==> we're done, create a new one */
sw->connectivity_state = GRPC_CHANNEL_FATAL_FAILURE;
sw->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
}
grpc_connectivity_state_set(exec_ctx, &c->state_tracker,
sw->connectivity_state, "reflect_child");
if (sw->connectivity_state != GRPC_CHANNEL_FATAL_FAILURE) {
if (sw->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, GET_CONNECTED_SUBCHANNEL(c, no_barrier), NULL,
&sw->connectivity_state, &sw->closure);
Expand Down
10 changes: 5 additions & 5 deletions src/core/ext/lb_policy/pick_first/pick_first.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
pp = p->pending_picks;
p->pending_picks = NULL;
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE, "shutdown");
GRPC_CHANNEL_SHUTDOWN, "shutdown");
/* cancel subscription */
if (selected != NULL) {
grpc_connected_subchannel_notify_on_state_change(
Expand Down Expand Up @@ -273,11 +273,11 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
} else if (selected != NULL) {
if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* if the selected channel goes bad, we're done */
p->checking_connectivity = GRPC_CHANNEL_FATAL_FAILURE;
p->checking_connectivity = GRPC_CHANNEL_SHUTDOWN;
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
p->checking_connectivity, "selected_changed");
if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) {
if (p->checking_connectivity != GRPC_CHANNEL_SHUTDOWN) {
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, selected, p->base.interested_parties,
&p->checking_connectivity, &p->connectivity_changed);
Expand Down Expand Up @@ -343,15 +343,15 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
p->base.interested_parties, &p->checking_connectivity,
&p->connectivity_changed);
break;
case GRPC_CHANNEL_FATAL_FAILURE:
case GRPC_CHANNEL_SHUTDOWN:
p->num_subchannels--;
GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel],
p->subchannels[p->num_subchannels]);
GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[p->num_subchannels],
"pick_first");
if (p->num_subchannels == 0) {
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE,
GRPC_CHANNEL_SHUTDOWN,
"no_more_channels");
while ((pp = p->pending_picks)) {
p->pending_picks = pp->next;
Expand Down
6 changes: 3 additions & 3 deletions src/core/ext/lb_policy/round_robin/round_robin.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static void rr_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
gpr_free(pp);
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE, "shutdown");
GRPC_CHANNEL_SHUTDOWN, "shutdown");
for (i = 0; i < p->num_subchannels; i++) {
subchannel_data *sd = p->subchannels[i];
grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL,
Expand Down Expand Up @@ -439,7 +439,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_CHANNEL_TRANSIENT_FAILURE,
"connecting_transient_failure");
break;
case GRPC_CHANNEL_FATAL_FAILURE:
case GRPC_CHANNEL_SHUTDOWN:
if (sd->ready_list_node != NULL) {
remove_disconnected_sc_locked(p, sd->ready_list_node);
sd->ready_list_node = NULL;
Expand All @@ -455,7 +455,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
unref = 1;
if (p->num_subchannels == 0) {
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE,
GRPC_CHANNEL_SHUTDOWN,
"no_more_channels");
while ((pp = p->pending_picks)) {
p->pending_picks = pp->next;
Expand Down
4 changes: 2 additions & 2 deletions src/core/ext/transport/chttp2/transport/chttp2_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
void *arg_ignored) {
if (!t->closed) {
t->closed = 1;
connectivity_state_set(exec_ctx, &t->global, GRPC_CHANNEL_FATAL_FAILURE,
connectivity_state_set(exec_ctx, &t->global, GRPC_CHANNEL_SHUTDOWN,
"close_transport");
if (t->ep) {
allow_endpoint_shutdown_locked(exec_ctx, t);
Expand Down Expand Up @@ -804,7 +804,7 @@ void grpc_chttp2_add_incoming_goaway(
gpr_free(msg);
gpr_slice_unref(goaway_text);
transport_global->seen_goaway = 1;
connectivity_state_set(exec_ctx, transport_global, GRPC_CHANNEL_FATAL_FAILURE,
connectivity_state_set(exec_ctx, transport_global, GRPC_CHANNEL_SHUTDOWN,
"got_goaway");
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/lib/surface/lame_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_transport_op *op) {
if (op->on_connectivity_state_change) {
GPR_ASSERT(*op->connectivity_state != GRPC_CHANNEL_FATAL_FAILURE);
*op->connectivity_state = GRPC_CHANNEL_FATAL_FAILURE;
GPR_ASSERT(*op->connectivity_state != GRPC_CHANNEL_SHUTDOWN);
*op->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
op->on_connectivity_state_change->cb(
exec_ctx, op->on_connectivity_state_change->cb_arg, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/surface/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ static void channel_connectivity_changed(grpc_exec_ctx *exec_ctx, void *cd,
bool iomgr_status_ignored) {
channel_data *chand = cd;
grpc_server *server = chand->server;
if (chand->connectivity_state != GRPC_CHANNEL_FATAL_FAILURE) {
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_transport_op op;
memset(&op, 0, sizeof(op));
op.on_connectivity_state_change = &chand->channel_connectivity_changed,
Expand Down
8 changes: 4 additions & 4 deletions src/core/lib/transport/connectivity_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const char *grpc_connectivity_state_name(grpc_connectivity_state state) {
return "READY";
case GRPC_CHANNEL_TRANSIENT_FAILURE:
return "TRANSIENT_FAILURE";
case GRPC_CHANNEL_FATAL_FAILURE:
case GRPC_CHANNEL_SHUTDOWN:
return "FATAL_FAILURE";
}
GPR_UNREACHABLE_CODE(return "UNKNOWN");
Expand All @@ -72,8 +72,8 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
while ((w = tracker->watchers)) {
tracker->watchers = w->next;

if (GRPC_CHANNEL_FATAL_FAILURE != *w->current) {
*w->current = GRPC_CHANNEL_FATAL_FAILURE;
if (GRPC_CHANNEL_SHUTDOWN != *w->current) {
*w->current = GRPC_CHANNEL_SHUTDOWN;
success = 1;
} else {
success = 0;
Expand Down Expand Up @@ -153,7 +153,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
if (tracker->current_state == state) {
return;
}
GPR_ASSERT(tracker->current_state != GRPC_CHANNEL_FATAL_FAILURE);
GPR_ASSERT(tracker->current_state != GRPC_CHANNEL_SHUTDOWN);
tracker->current_state = state;
while ((w = tracker->watchers) != NULL) {
*w->current = tracker->current_state;
Expand Down
2 changes: 1 addition & 1 deletion src/node/ext/node_grpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void InitConnectivityStateConstants(Local<Object> exports) {
Nan::Set(channel_state, Nan::New("TRANSIENT_FAILURE").ToLocalChecked(),
TRANSIENT_FAILURE);
Local<Value> FATAL_FAILURE(
Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_FATAL_FAILURE));
Nan::New<Uint32, uint32_t>(GRPC_CHANNEL_SHUTDOWN));
Nan::Set(channel_state, Nan::New("FATAL_FAILURE").ToLocalChecked(),
FATAL_FAILURE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/php/ext/grpc/php_grpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ PHP_MINIT_FUNCTION(grpc) {
GRPC_CHANNEL_TRANSIENT_FAILURE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("Grpc\\CHANNEL_FATAL_FAILURE",
GRPC_CHANNEL_FATAL_FAILURE,
GRPC_CHANNEL_SHUTDOWN,
CONST_CS | CONST_PERSISTENT);

grpc_init_call(TSRMLS_C);
Expand Down
2 changes: 1 addition & 1 deletion src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ cdef extern from "grpc/_cython/loader.h":
GRPC_CHANNEL_CONNECTING
GRPC_CHANNEL_READY
GRPC_CHANNEL_TRANSIENT_FAILURE
GRPC_CHANNEL_FATAL_FAILURE
GRPC_CHANNEL_SHUTDOWN

ctypedef struct grpc_metadata:
const char *key
Expand Down
2 changes: 1 addition & 1 deletion src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ConnectivityState:
connecting = GRPC_CHANNEL_CONNECTING
ready = GRPC_CHANNEL_READY
transient_failure = GRPC_CHANNEL_TRANSIENT_FAILURE
fatal_failure = GRPC_CHANNEL_FATAL_FAILURE
fatal_failure = GRPC_CHANNEL_SHUTDOWN


class ChannelArgKey:
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/ext/grpc/rb_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void Init_grpc_connectivity_states() {
rb_define_const(grpc_rb_mConnectivityStates, "TRANSIENT_FAILURE",
LONG2NUM(GRPC_CHANNEL_TRANSIENT_FAILURE));
rb_define_const(grpc_rb_mConnectivityStates, "FATAL_FAILURE",
LONG2NUM(GRPC_CHANNEL_FATAL_FAILURE));
LONG2NUM(GRPC_CHANNEL_SHUTDOWN));
}

void Init_grpc_channel() {
Expand Down
2 changes: 1 addition & 1 deletion test/core/end2end/fuzzers/api_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (g_channel != NULL) {
grpc_connectivity_state st =
grpc_channel_check_connectivity_state(g_channel, 0);
if (st != GRPC_CHANNEL_FATAL_FAILURE) {
if (st != GRPC_CHANNEL_SHUTDOWN) {
gpr_timespec deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN));
Expand Down
4 changes: 2 additions & 2 deletions test/core/surface/lame_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void *tag(intptr_t x) { return (void *)x; }

void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
grpc_transport_op *op = arg;
GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE == *op->connectivity_state);
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *op->connectivity_state);
GPR_ASSERT(success);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ int main(int argc, char **argv) {

test_transport_op(chan);

GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE ==
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN ==
grpc_channel_check_connectivity_state(chan, 0));

cq = grpc_completion_queue_create(NULL);
Expand Down
15 changes: 7 additions & 8 deletions test/core/transport/connectivity_state_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ static void test_connectivity_state_name(void) {
GPR_ASSERT(
0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_TRANSIENT_FAILURE),
"TRANSIENT_FAILURE"));
GPR_ASSERT(0 ==
strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_FATAL_FAILURE),
"FATAL_FAILURE"));
GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_SHUTDOWN),
"FATAL_FAILURE"));
}

static void test_check(void) {
Expand Down Expand Up @@ -119,26 +118,26 @@ static void test_subscribe_then_destroy(void) {
GPR_ASSERT(g_counter == 0);
grpc_connectivity_state_destroy(&exec_ctx, &tracker);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE);
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}

static void test_subscribe_with_failure_then_destroy(void) {
grpc_connectivity_state_tracker tracker;
grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG);
grpc_connectivity_state state = GRPC_CHANNEL_FATAL_FAILURE;
grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_FATAL_FAILURE, "xxx");
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_SHUTDOWN, "xxx");
GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(
&exec_ctx, &tracker, &state, closure));
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE);
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 0);
grpc_connectivity_state_destroy(&exec_ctx, &tracker);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE);
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}

Expand Down

0 comments on commit d38b2c4

Please sign in to comment.