From 210f3c4b8e3088fc26e674841c7c992ef1c7d609 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 20 May 2016 13:24:59 -0700 Subject: Added comments to node generation, also refactored some plugin code --- src/node/test/math/math_grpc_pb.js | 75 +++++++++++++++++++++++++++++--------- src/node/test/math/math_pb.js | 10 ++--- 2 files changed, 63 insertions(+), 22 deletions(-) (limited to 'src/node') diff --git a/src/node/test/math/math_grpc_pb.js b/src/node/test/math/math_grpc_pb.js index 083ed66913..17a4bf7243 100644 --- a/src/node/test/math/math_grpc_pb.js +++ b/src/node/test/math/math_grpc_pb.js @@ -1,94 +1,135 @@ // GENERATED CODE -- DO NOT EDIT! +// Original file comments: +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// 'use strict'; var grpc = require('grpc'); -var math_pb = require('./math_pb.js'); +var math_math_pb = require('../math/math_pb.js'); function serialize_DivArgs(arg) { - if (!(arg instanceof math_pb.DivArgs)) { + if (!(arg instanceof math_math_pb.DivArgs)) { throw new Error('Expected argument of type DivArgs'); } return new Buffer(arg.serializeBinary()); } function deserialize_DivArgs(buffer_arg) { - return math_pb.DivArgs.deserializeBinary(new Uint8Array(buffer_arg)); + return math_math_pb.DivArgs.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_DivReply(arg) { - if (!(arg instanceof math_pb.DivReply)) { + if (!(arg instanceof math_math_pb.DivReply)) { throw new Error('Expected argument of type DivReply'); } return new Buffer(arg.serializeBinary()); } function deserialize_DivReply(buffer_arg) { - return math_pb.DivReply.deserializeBinary(new Uint8Array(buffer_arg)); + return math_math_pb.DivReply.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_FibArgs(arg) { - if (!(arg instanceof math_pb.FibArgs)) { + if (!(arg instanceof math_math_pb.FibArgs)) { throw new Error('Expected argument of type FibArgs'); } return new Buffer(arg.serializeBinary()); } function deserialize_FibArgs(buffer_arg) { - return math_pb.FibArgs.deserializeBinary(new Uint8Array(buffer_arg)); + return math_math_pb.FibArgs.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_Num(arg) { - if (!(arg instanceof math_pb.Num)) { + if (!(arg instanceof math_math_pb.Num)) { throw new Error('Expected argument of type Num'); } return new Buffer(arg.serializeBinary()); } function deserialize_Num(buffer_arg) { - return math_pb.Num.deserializeBinary(new Uint8Array(buffer_arg)); + return math_math_pb.Num.deserializeBinary(new Uint8Array(buffer_arg)); } var MathService = exports.MathService = { + // Div divides args.dividend by args.divisor and returns the quotient and + // remainder. div: { path: '/math.Math/Div', requestStream: false, responseStream: false, - requestType: math_pb.DivArgs, - responseType: math_pb.DivReply, + requestType: math_math_pb.DivArgs, + responseType: math_math_pb.DivReply, requestSerialize: serialize_DivArgs, requestDeserialize: deserialize_DivArgs, responseSerialize: serialize_DivReply, responseDeserialize: deserialize_DivReply, }, + // DivMany accepts an arbitrary number of division args from the client stream + // and sends back the results in the reply stream. The stream continues until + // the client closes its end; the server does the same after sending all the + // replies. The stream ends immediately if either end aborts. divMany: { path: '/math.Math/DivMany', requestStream: true, responseStream: true, - requestType: math_pb.DivArgs, - responseType: math_pb.DivReply, + requestType: math_math_pb.DivArgs, + responseType: math_math_pb.DivReply, requestSerialize: serialize_DivArgs, requestDeserialize: deserialize_DivArgs, responseSerialize: serialize_DivReply, responseDeserialize: deserialize_DivReply, }, + // Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib + // generates up to limit numbers; otherwise it continues until the call is + // canceled. Unlike Fib above, Fib has no final FibReply. fib: { path: '/math.Math/Fib', requestStream: false, responseStream: true, - requestType: math_pb.FibArgs, - responseType: math_pb.Num, + requestType: math_math_pb.FibArgs, + responseType: math_math_pb.Num, requestSerialize: serialize_FibArgs, requestDeserialize: deserialize_FibArgs, responseSerialize: serialize_Num, responseDeserialize: deserialize_Num, }, + // Sum sums a stream of numbers, returning the final result once the stream + // is closed. sum: { path: '/math.Math/Sum', requestStream: true, responseStream: false, - requestType: math_pb.Num, - responseType: math_pb.Num, + requestType: math_math_pb.Num, + responseType: math_math_pb.Num, requestSerialize: serialize_Num, requestDeserialize: deserialize_Num, responseSerialize: serialize_Num, diff --git a/src/node/test/math/math_pb.js b/src/node/test/math/math_pb.js index 3489143bec..ccc05c6e06 100644 --- a/src/node/test/math/math_pb.js +++ b/src/node/test/math/math_pb.js @@ -65,7 +65,7 @@ proto.math.DivArgs.toObject = function(includeInstance, msg) { }; if (includeInstance) { - obj.$jspbMessageInstance = msg + obj.$jspbMessageInstance = msg; } return obj; }; @@ -251,7 +251,7 @@ proto.math.DivReply.toObject = function(includeInstance, msg) { }; if (includeInstance) { - obj.$jspbMessageInstance = msg + obj.$jspbMessageInstance = msg; } return obj; }; @@ -436,7 +436,7 @@ proto.math.FibArgs.toObject = function(includeInstance, msg) { }; if (includeInstance) { - obj.$jspbMessageInstance = msg + obj.$jspbMessageInstance = msg; } return obj; }; @@ -595,7 +595,7 @@ proto.math.Num.toObject = function(includeInstance, msg) { }; if (includeInstance) { - obj.$jspbMessageInstance = msg + obj.$jspbMessageInstance = msg; } return obj; }; @@ -754,7 +754,7 @@ proto.math.FibReply.toObject = function(includeInstance, msg) { }; if (includeInstance) { - obj.$jspbMessageInstance = msg + obj.$jspbMessageInstance = msg; } return obj; }; -- cgit v1.2.3 From 325a0591a536a390ce67a5ec402461f4060204e2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 25 May 2016 06:31:12 -0700 Subject: Mark port as non-listening --- src/node/ext/server.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'src/node') diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index b9e1fe9160..dd1b777ac8 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -35,15 +35,15 @@ #include "server.h" -#include #include +#include #include +#include "call.h" +#include "completion_queue_async_worker.h" #include "grpc/grpc.h" #include "grpc/grpc_security.h" #include "grpc/support/log.h" -#include "call.h" -#include "completion_queue_async_worker.h" #include "server_credentials.h" #include "timeval.h" @@ -100,8 +100,8 @@ class NewCallOp : public Op { Nan::Set(obj, Nan::New("host").ToLocalChecked(), Nan::New(details.host).ToLocalChecked()); Nan::Set(obj, Nan::New("deadline").ToLocalChecked(), - Nan::New( - TimespecToMilliseconds(details.deadline)).ToLocalChecked()); + Nan::New(TimespecToMilliseconds(details.deadline)) + .ToLocalChecked()); Nan::Set(obj, Nan::New("metadata").ToLocalChecked(), ParseMetadata(&request_metadata)); return scope.Escape(obj); @@ -117,14 +117,13 @@ class NewCallOp : public Op { grpc_metadata_array request_metadata; protected: - std::string GetTypeString() const { - return "new_call"; - } + std::string GetTypeString() const { return "new_call"; } }; Server::Server(grpc_server *server) : wrapped_server(server) { shutdown_queue = grpc_completion_queue_create(NULL); - grpc_server_register_completion_queue(server, shutdown_queue, NULL); + grpc_server_register_non_listening_completion_queue(server, shutdown_queue, + NULL); } Server::~Server() { @@ -156,8 +155,7 @@ bool Server::HasInstance(Local val) { } void Server::ShutdownServer() { - grpc_server_shutdown_and_notify(this->wrapped_server, - this->shutdown_queue, + grpc_server_shutdown_and_notify(this->wrapped_server, this->shutdown_queue, NULL); grpc_server_cancel_all_calls(this->wrapped_server); grpc_completion_queue_pluck(this->shutdown_queue, NULL, @@ -170,8 +168,8 @@ NAN_METHOD(Server::New) { if (!info.IsConstructCall()) { const int argc = 1; Local argv[argc] = {info[0]}; - MaybeLocal maybe_instance = constructor->GetFunction()->NewInstance( - argc, argv); + MaybeLocal maybe_instance = + constructor->GetFunction()->NewInstance(argc, argv); if (maybe_instance.IsEmpty()) { // There's probably a pending exception return; @@ -185,8 +183,9 @@ NAN_METHOD(Server::New) { grpc_channel_args *channel_args; if (!ParseChannelArgs(info[0], &channel_args)) { DeallocateChannelArgs(channel_args); - return Nan::ThrowTypeError("Server options must be an object with " - "string keys and integer or string values"); + return Nan::ThrowTypeError( + "Server options must be an object with " + "string keys and integer or string values"); } wrapped_server = grpc_server_create(channel_args, NULL); DeallocateChannelArgs(channel_args); @@ -218,8 +217,7 @@ NAN_METHOD(Server::RequestCall) { NAN_METHOD(Server::AddHttp2Port) { if (!HasInstance(info.This())) { - return Nan::ThrowTypeError( - "addHttp2Port can only be called on a Server"); + return Nan::ThrowTypeError("addHttp2Port can only be called on a Server"); } if (!info[0]->IsString()) { return Nan::ThrowTypeError( @@ -239,8 +237,7 @@ NAN_METHOD(Server::AddHttp2Port) { *Utf8String(info[0])); } else { port = grpc_server_add_secure_http2_port(server->wrapped_server, - *Utf8String(info[0]), - creds); + *Utf8String(info[0]), creds); } info.GetReturnValue().Set(Nan::New(port)); } @@ -262,8 +259,7 @@ NAN_METHOD(Server::TryShutdown) { Server *server = ObjectWrap::Unwrap(info.This()); unique_ptr ops(new OpVec()); grpc_server_shutdown_and_notify( - server->wrapped_server, - CompletionQueueAsyncWorker::GetQueue(), + server->wrapped_server, CompletionQueueAsyncWorker::GetQueue(), new struct tag(new Nan::Callback(info[0].As()), ops.release(), shared_ptr(nullptr))); CompletionQueueAsyncWorker::Next(); -- cgit v1.2.3 From c04b80cb4797bb51a8350eebcdad87c17661f4ce Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 25 May 2016 15:14:39 -0700 Subject: Make Node not segfault when it receives a compressed message --- src/node/ext/byte_buffer.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/node') diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index 8e0b6916e9..56e0b45ece 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -38,6 +38,7 @@ #include "grpc/grpc.h" #include "grpc/byte_buffer_reader.h" #include "grpc/support/slice.h" +#include "grpc/support/log.h" #include "byte_buffer.h" @@ -72,17 +73,13 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { if (buffer == NULL) { return scope.Escape(Nan::Null()); } - size_t length = grpc_byte_buffer_length(buffer); - char *result = new char[length]; - size_t offset = 0; + gpr_log(GPR_DEBUG, "Compressed size: %d", grpc_byte_buffer_length(buffer)); grpc_byte_buffer_reader reader; grpc_byte_buffer_reader_init(&reader, buffer); - gpr_slice next; - while (grpc_byte_buffer_reader_next(&reader, &next) != 0) { - memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); - offset += GPR_SLICE_LENGTH(next); - gpr_slice_unref(next); - } + gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + size_t length = GPR_SLICE_LENGTH(slice); + char *result = new char[length]; + memcpy(result, GPR_SLICE_START_PTR(slice), length); return scope.Escape(MakeFastBuffer( Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked())); } -- cgit v1.2.3 From 8678bb424e0c8839cd280a5da7f3d7d652830559 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 25 May 2016 15:16:23 -0700 Subject: Remove extraneous logging code --- src/node/ext/byte_buffer.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/node') diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index 56e0b45ece..d17e468354 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -38,7 +38,6 @@ #include "grpc/grpc.h" #include "grpc/byte_buffer_reader.h" #include "grpc/support/slice.h" -#include "grpc/support/log.h" #include "byte_buffer.h" @@ -73,7 +72,6 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { if (buffer == NULL) { return scope.Escape(Nan::Null()); } - gpr_log(GPR_DEBUG, "Compressed size: %d", grpc_byte_buffer_length(buffer)); grpc_byte_buffer_reader reader; grpc_byte_buffer_reader_init(&reader, buffer); gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); -- cgit v1.2.3 From c04f7b155bab666e9cdaae17920d3f5867b47355 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 25 May 2016 15:19:09 -0700 Subject: Remember to unref the slice --- src/node/ext/byte_buffer.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/node') diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index d17e468354..3479a67702 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -78,6 +78,7 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { size_t length = GPR_SLICE_LENGTH(slice); char *result = new char[length]; memcpy(result, GPR_SLICE_START_PTR(slice), length); + gpr_slice_unref(slice); return scope.Escape(MakeFastBuffer( Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked())); } -- cgit v1.2.3 From 48ed92ea38f40d62467eb7955bd4b8bb7cd0ef24 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 2 Jun 2016 11:07:12 -0700 Subject: GRPC_CHANNEL_FATAL_FAILURE --> GRPC_CHANNEL_SHUTDOWN --- include/grpc/impl/codegen/connectivity_state.h | 2 +- src/core/ext/client_config/channel_connectivity.c | 2 +- src/core/ext/client_config/client_channel.c | 13 ++++++------- src/core/ext/client_config/subchannel.c | 4 ++-- src/core/ext/lb_policy/pick_first/pick_first.c | 10 +++++----- src/core/ext/lb_policy/round_robin/round_robin.c | 6 +++--- .../ext/transport/chttp2/transport/chttp2_transport.c | 4 ++-- src/core/lib/surface/lame_client.c | 4 ++-- src/core/lib/surface/server.c | 2 +- src/core/lib/transport/connectivity_state.c | 8 ++++---- src/node/ext/node_grpc.cc | 2 +- src/php/ext/grpc/php_grpc.c | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 2 +- src/ruby/ext/grpc/rb_channel.c | 2 +- test/core/end2end/fuzzers/api_fuzzer.c | 2 +- test/core/surface/lame_client_test.c | 4 ++-- test/core/transport/connectivity_state_test.c | 15 +++++++-------- 18 files changed, 42 insertions(+), 44 deletions(-) (limited to 'src/node') diff --git a/include/grpc/impl/codegen/connectivity_state.h b/include/grpc/impl/codegen/connectivity_state.h index 5bb9eb8f4e..71865d8a56 100644 --- a/include/grpc/impl/codegen/connectivity_state.h +++ b/include/grpc/impl/codegen/connectivity_state.h @@ -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 diff --git a/src/core/ext/client_config/channel_connectivity.c b/src/core/ext/client_config/channel_connectivity.c index 3ebc333608..cc60f2485a 100644 --- a/src/core/ext/client_config/channel_connectivity.c +++ b/src/core/ext/client_config/channel_connectivity.c @@ -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 { diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 9b5a078aec..b80eeb54b2 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -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( @@ -136,8 +136,7 @@ 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"); @@ -145,7 +144,7 @@ static void on_lb_policy_state_changed_locked( } 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); } } @@ -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); } @@ -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; diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c index cfd39e7cfb..22032d95df 100644 --- a/src/core/ext/client_config/subchannel.c +++ b/src/core/ext/client_config/subchannel.c @@ -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); diff --git a/src/core/ext/lb_policy/pick_first/pick_first.c b/src/core/ext/lb_policy/pick_first/pick_first.c index 0d215cd196..b5797da832 100644 --- a/src/core/ext/lb_policy/pick_first/pick_first.c +++ b/src/core/ext/lb_policy/pick_first/pick_first.c @@ -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( @@ -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); @@ -343,7 +343,7 @@ 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]); @@ -351,7 +351,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg, "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; diff --git a/src/core/ext/lb_policy/round_robin/round_robin.c b/src/core/ext/lb_policy/round_robin/round_robin.c index dcdc0c6285..7ab913b645 100644 --- a/src/core/ext/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/lb_policy/round_robin/round_robin.c @@ -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, @@ -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; @@ -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; diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index b6886a2201..d0403cc6a2 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -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); @@ -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"); } diff --git a/src/core/lib/surface/lame_client.c b/src/core/lib/surface/lame_client.c index f50ec54cea..0038f85330 100644 --- a/src/core/lib/surface/lame_client.c +++ b/src/core/lib/surface/lame_client.c @@ -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); } diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 505b501968..9c006fcebf 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -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, diff --git a/src/core/lib/transport/connectivity_state.c b/src/core/lib/transport/connectivity_state.c index e24ee638fd..74a5ef5c13 100644 --- a/src/core/lib/transport/connectivity_state.c +++ b/src/core/lib/transport/connectivity_state.c @@ -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"); @@ -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; @@ -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; diff --git a/src/node/ext/node_grpc.cc b/src/node/ext/node_grpc.cc index 6b6e42737b..f18ce01c6f 100644 --- a/src/node/ext/node_grpc.cc +++ b/src/node/ext/node_grpc.cc @@ -220,7 +220,7 @@ void InitConnectivityStateConstants(Local exports) { Nan::Set(channel_state, Nan::New("TRANSIENT_FAILURE").ToLocalChecked(), TRANSIENT_FAILURE); Local FATAL_FAILURE( - Nan::New(GRPC_CHANNEL_FATAL_FAILURE)); + Nan::New(GRPC_CHANNEL_SHUTDOWN)); Nan::Set(channel_state, Nan::New("FATAL_FAILURE").ToLocalChecked(), FATAL_FAILURE); } diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index 762c01385c..f4cb5b28cc 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -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); diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index d42c58050f..05b8886df7 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -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 diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index c7539f0d49..47800c067d 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -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: diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 013321ffc8..6943c93d4a 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -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() { diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index e6cd88acee..6bcddbd769 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -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)); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 12fa9de6cf..3286db5b1b 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -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); } @@ -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); diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.c index 6bb7c3b06b..38dea01cc6 100644 --- a/test/core/transport/connectivity_state_test.c +++ b/test/core/transport/connectivity_state_test.c @@ -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) { @@ -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); } -- cgit v1.2.3