Undo adding new API to tranport

reviewable/pr16760/r2
ncteisen 6 years ago
parent 3545d754d5
commit 8362e7042d
  1. 5
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  2. 7
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  3. 5
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  4. 4
      src/core/ext/transport/inproc/inproc_transport.cc
  5. 17
      src/core/lib/channel/channelz.cc
  6. 9
      src/core/lib/channel/connected_channel.cc
  7. 3
      src/core/lib/channel/connected_channel.h
  8. 31
      src/core/lib/surface/server.cc
  9. 9
      src/core/lib/surface/server.h
  10. 4
      src/core/lib/transport/transport.cc
  11. 3
      src/core/lib/transport/transport.h
  12. 2
      src/core/lib/transport/transport_impl.h
  13. 6
      test/core/end2end/tests/channelz.cc
  14. 10
      test/cpp/microbenchmarks/bm_call_create.cc

@ -131,9 +131,10 @@ static void on_handshake_done(void* arg, grpc_error* error) {
if (args->endpoint != nullptr) {
grpc_transport* transport =
grpc_create_chttp2_transport(args->args, args->endpoint, false);
grpc_server_setup_transport(
grpc_server_setup_transport_with_socket_uuid(
connection_state->svr_state->server, transport,
connection_state->accepting_pollset, args->args);
connection_state->accepting_pollset, args->args,
grpc_chttp2_transport_get_socket_uuid(transport));
// Use notify_on_receive_settings callback to enforce the
// handshake deadline.
connection_state->transport =

@ -3157,10 +3157,6 @@ static grpc_endpoint* chttp2_get_endpoint(grpc_transport* t) {
return (reinterpret_cast<grpc_chttp2_transport*>(t))->ep;
}
static intptr_t get_socket_uuid(grpc_transport* t) {
return grpc_chttp2_transport_get_socket_uuid(t);
}
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
"chttp2",
init_stream,
@ -3170,8 +3166,7 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
perform_transport_op,
destroy_stream,
destroy_transport,
chttp2_get_endpoint,
get_socket_uuid};
chttp2_get_endpoint};
static const grpc_transport_vtable* get_vtable(void) { return &vtable; }

@ -1437,8 +1437,6 @@ static void destroy_transport(grpc_transport* gt) {}
static grpc_endpoint* get_endpoint(grpc_transport* gt) { return nullptr; }
static intptr_t get_socket_uuid(grpc_transport* t) { return 0; }
static void perform_op(grpc_transport* gt, grpc_transport_op* op) {}
static const grpc_transport_vtable grpc_cronet_vtable = {
@ -1451,8 +1449,7 @@ static const grpc_transport_vtable grpc_cronet_vtable = {
perform_op,
destroy_stream,
destroy_transport,
get_endpoint,
get_socket_uuid};
get_endpoint};
grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
const grpc_channel_args* args,

@ -1170,8 +1170,6 @@ static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
static grpc_endpoint* get_endpoint(grpc_transport* t) { return nullptr; }
static intptr_t get_socket_uuid(grpc_transport* t) { return 0; }
/*******************************************************************************
* GLOBAL INIT AND DESTROY
*/
@ -1196,7 +1194,7 @@ static const grpc_transport_vtable inproc_vtable = {
sizeof(inproc_stream), "inproc", init_stream,
set_pollset, set_pollset_set, perform_stream_op,
perform_transport_op, destroy_stream, destroy_transport,
get_endpoint, get_socket_uuid};
get_endpoint};
/*******************************************************************************
* Main inproc transport functions

@ -166,7 +166,7 @@ char* ServerNode::RenderServerSockets(intptr_t start_socket_id) {
// reserved). However, we want to support requests coming in with
// start_server_id=0, which signifies "give me everything."
size_t start_idx = start_socket_id == 0 ? 0 : start_socket_id - 1;
grpc_server_populate_listen_sockets(server_, &socket_refs, start_idx);
grpc_server_populate_server_sockets(server_, &socket_refs, start_idx);
if (!socket_refs.empty()) {
// create list of socket refs
grpc_json* array_parent = grpc_json_create_child(
@ -217,21 +217,6 @@ grpc_json* ServerNode::RenderJson() {
}
// ask CallCountingHelper to populate trace and call count data.
call_counter_.PopulateCallCounts(json);
json = top_level_json;
ChildRefsList listen_sockets;
grpc_server_populate_listen_sockets(server_, &listen_sockets,
0 /* start_idx*/);
if (!listen_sockets.empty()) {
grpc_json* array_parent = grpc_json_create_child(
nullptr, json, "listenSocket", nullptr, GRPC_JSON_ARRAY, false);
for (size_t i = 0; i < listen_sockets.size(); ++i) {
json_iterator =
grpc_json_create_child(json_iterator, array_parent, nullptr, nullptr,
GRPC_JSON_OBJECT, false);
grpc_json_add_number_string_child(json_iterator, nullptr, "socketId",
listen_sockets[i]);
}
}
return top_level_json;
}

@ -36,7 +36,6 @@
typedef struct connected_channel_channel_data {
grpc_transport* transport;
intptr_t socket_uuid;
} channel_data;
typedef struct {
@ -218,7 +217,6 @@ static void bind_transport(grpc_channel_stack* channel_stack,
GPR_ASSERT(elem->filter == &grpc_connected_filter);
GPR_ASSERT(cd->transport == nullptr);
cd->transport = static_cast<grpc_transport*>(t);
cd->socket_uuid = grpc_transport_get_socket_uuid(cd->transport);
/* HACK(ctiller): increase call stack size for the channel to make space
for channel data. We need a cleaner (but performant) way to do this,
@ -239,13 +237,6 @@ bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
builder, &grpc_connected_filter, bind_transport, t);
}
intptr_t grpc_connected_channel_get_socket_uuid(
grpc_channel_element* connected_channel_elem) {
channel_data* chand =
static_cast<channel_data*>(connected_channel_elem->channel_data);
return chand->socket_uuid;
}
grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem) {
call_data* calld = static_cast<call_data*>(elem->call_data);
return TRANSPORT_STREAM_FROM_CALL_DATA(calld);

@ -28,9 +28,6 @@ extern const grpc_channel_filter grpc_connected_filter;
bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
void* arg_must_be_null);
intptr_t grpc_connected_channel_get_socket_uuid(
grpc_channel_element* connected_channel_elem);
/* Debug helper to dig the transport stream out of a call element */
grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem);

@ -104,6 +104,7 @@ struct channel_data {
uint32_t registered_method_max_probes;
grpc_closure finish_destroy_channel_closure;
grpc_closure channel_connectivity_changed;
uint32_t socket_uuid;
};
typedef struct shutdown_tag {
@ -1116,9 +1117,9 @@ void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
*pollsets = server->pollsets;
}
void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
grpc_pollset* accepting_pollset,
const grpc_channel_args* args) {
void grpc_server_setup_transport_with_socket_uuid(
grpc_server* s, grpc_transport* transport, grpc_pollset* accepting_pollset,
const grpc_channel_args* args, intptr_t socket_uuid) {
size_t num_registered_methods;
size_t alloc;
registered_method* rm;
@ -1138,6 +1139,7 @@ void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
chand->server = s;
server_ref(s);
chand->channel = channel;
chand->socket_uuid = socket_uuid;
size_t cq_idx;
for (cq_idx = 0; cq_idx < s->cq_count; cq_idx++) {
@ -1212,21 +1214,22 @@ void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
grpc_transport_perform_op(transport, op);
}
void grpc_server_populate_listen_sockets(
grpc_server* s, grpc_core::ChildRefsList* listen_sockets,
void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
grpc_pollset* accepting_pollset,
const grpc_channel_args* args) {
grpc_server_setup_transport_with_socket_uuid(s, transport, accepting_pollset,
args, 0);
}
void grpc_server_populate_server_sockets(
grpc_server* s, grpc_core::ChildRefsList* server_sockets,
intptr_t start_idx) {
gpr_mu_lock(&s->mu_global);
channel_data* c = nullptr;
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
if (c->channel != nullptr) {
grpc_channel_element* connected_channel_elem =
grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(c->channel));
intptr_t socket_uuid =
grpc_connected_channel_get_socket_uuid(connected_channel_elem);
if (socket_uuid >= start_idx) {
listen_sockets->push_back(socket_uuid);
}
intptr_t socket_uuid = c->socket_uuid;
if (socket_uuid >= start_idx) {
server_sockets->push_back(socket_uuid);
}
}
gpr_mu_unlock(&s->mu_global);

@ -47,8 +47,13 @@ void grpc_server_setup_transport(grpc_server* server, grpc_transport* transport,
grpc_pollset* accepting_pollset,
const grpc_channel_args* args);
void grpc_server_populate_listen_sockets(
grpc_server* server, grpc_core::ChildRefsList* listen_sockets,
void grpc_server_setup_transport_with_socket_uuid(
grpc_server* server, grpc_transport* transport,
grpc_pollset* accepting_pollset, const grpc_channel_args* args,
intptr_t socket_uuid);
void grpc_server_populate_server_sockets(
grpc_server* server, grpc_core::ChildRefsList* server_sockets,
intptr_t start_idx);
grpc_core::channelz::ServerNode* grpc_server_get_channelz_node(

@ -199,10 +199,6 @@ grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport) {
return transport->vtable->get_endpoint(transport);
}
intptr_t grpc_transport_get_socket_uuid(grpc_transport* transport) {
return transport->vtable->get_socket_uuid(transport);
}
// This comment should be sung to the tune of
// "Supercalifragilisticexpialidocious":
//

@ -366,9 +366,6 @@ void grpc_transport_destroy(grpc_transport* transport);
/* Get the endpoint used by \a transport */
grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport);
/* Get the socket uuid used by the transport. Returns 0 if not availible. */
intptr_t grpc_transport_get_socket_uuid(grpc_transport* transport);
/* Allocate a grpc_transport_op, and preconfigure the on_consumed closure to
\a on_consumed and then delete the returned transport op */
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed);

@ -60,8 +60,6 @@ typedef struct grpc_transport_vtable {
/* implementation of grpc_transport_get_endpoint */
grpc_endpoint* (*get_endpoint)(grpc_transport* self);
intptr_t (*get_socket_uuid)(grpc_transport* self);
} grpc_transport_vtable;
/* an instance of a grpc transport */

@ -252,14 +252,16 @@ static void test_channelz(grpc_end2end_test_config config) {
GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"2\""));
GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\""));
GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
GPR_ASSERT(nullptr != strstr(json, "\"listenSocket\""));
GPR_ASSERT(nullptr != strstr(json, "\"socketId\""));
// channel tracing is not enabled, so these should not be preset.
GPR_ASSERT(nullptr == strstr(json, "\"trace\""));
GPR_ASSERT(nullptr == strstr(json, "\"description\":\"Channel created\""));
GPR_ASSERT(nullptr == strstr(json, "\"severity\":\"CT_INFO\""));
gpr_free(json);
json = channelz_server->RenderServerSockets(0);
GPR_ASSERT(nullptr != strstr(json, "\"socketRef\":"));
gpr_free(json);
end_test(&f);
config.tear_down_data(&f);
}

@ -446,13 +446,11 @@ void Destroy(grpc_transport* self) {}
/* implementation of grpc_transport_get_endpoint */
grpc_endpoint* GetEndpoint(grpc_transport* self) { return nullptr; }
static intptr_t GetSocketUuid(grpc_transport* t) { return 0; }
static const grpc_transport_vtable dummy_transport_vtable = {
0, "dummy_http2", InitStream,
SetPollset, SetPollsetSet, PerformStreamOp,
PerformOp, DestroyStream, Destroy,
GetEndpoint, GetSocketUuid};
0, "dummy_http2", InitStream,
SetPollset, SetPollsetSet, PerformStreamOp,
PerformOp, DestroyStream, Destroy,
GetEndpoint};
static grpc_transport dummy_transport = {&dummy_transport_vtable};

Loading…
Cancel
Save