From 7d9b6358b507aef4188739c46db1ad3f39a5bf98 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 28 Dec 2017 15:04:48 -0800 Subject: Initial commit Picks up work from https://github.com/grpc/grpc/pull/10259. A merge was impossible due to the many sweeping changed that have occured since I last touched that PR (c++-ization, exec_ctx, reorganitation of filters, etc). --- src/core/lib/surface/channel.cc | 33 +++++++++++++++++++++++++++++++-- src/core/lib/surface/channel.h | 3 +++ src/core/lib/surface/init.cc | 3 +++ 3 files changed, 37 insertions(+), 2 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index cf5e8c2150..e94413e3bc 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -28,9 +28,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" @@ -51,6 +53,7 @@ typedef struct registered_call { } registered_call; struct grpc_channel { + intptr_t uuid; int is_client; grpc_compression_options compression_options; grpc_mdelem default_authority; @@ -60,6 +63,8 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; + grpc_channel_tracer* tracer; + char* target; }; @@ -91,12 +96,16 @@ grpc_channel* grpc_channel_create_with_builder( grpc_error_string(error)); GRPC_ERROR_UNREF(error); gpr_free(target); - goto done; + grpc_channel_args_destroy(args); + return channel; } memset(channel, 0, sizeof(*channel)); + channel->uuid = grpc_object_registry_register_object( + channel, GRPC_OBJECT_REGISTRY_CHANNEL); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); + channel->tracer = NULL; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -186,14 +195,34 @@ grpc_channel* grpc_channel_create_with_builder( .enabled_stream_compression_algorithms_bitset = (uint32_t)args->args[i].value.integer | 0x1; /* always support no compression */ + } else if (0 == + strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { + GPR_ASSERT(channel->tracer == NULL); + // max_nodes defaults to 10, clamped between 0 and 100. + const grpc_integer_options options = {10, 0, 100}; + size_t max_nodes = + (size_t)grpc_channel_arg_get_integer(&args->args[i], options); + if (max_nodes > 0) { + channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, channel->uuid); + } } } -done: grpc_channel_args_destroy(args); + grpc_channel_tracer_add_trace( + channel->tracer, grpc_slice_from_static_string("Channel created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, NULL); return channel; } +char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { + return channel->tracer + ? grpc_channel_tracer_render_trace(channel->tracer, recursive) + : NULL; +} + +intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 26d8fceb2f..507013f452 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -58,6 +58,9 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); +char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +intptr_t grpc_channel_get_uuid(grpc_channel* channel); + #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 0f40965f16..a33b6de8b7 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -41,6 +41,7 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/fork.h" +#include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/thd_internal.h" #include "src/core/lib/surface/alarm_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -129,6 +130,7 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); + grpc_object_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -177,6 +179,7 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); + grpc_object_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); -- cgit v1.2.3 From 1d2f23b338fee1a88db63bc5728bbe23065fbba7 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 17:42:52 -0800 Subject: Register tracers, not (sub)channels --- src/core/ext/filters/client_channel/subchannel.cc | 13 +--------- src/core/ext/filters/client_channel/subchannel.h | 4 --- src/core/lib/channel/channel_tracer.cc | 30 +++++++++-------------- src/core/lib/channel/channel_tracer.h | 16 ++++++------ src/core/lib/support/object_registry.h | 3 +-- src/core/lib/surface/channel.cc | 6 ++--- 6 files changed, 25 insertions(+), 47 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 8b8e468f16..02bcba0e73 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -188,7 +188,6 @@ void grpc_connected_subchannel_unref( static void subchannel_destroy(void* arg, grpc_error* error) { grpc_subchannel* c = (grpc_subchannel*)arg; - grpc_object_registry_unregister_object(c->uuid); gpr_free((void*)c->filters); grpc_channel_args_destroy(c->args); grpc_connectivity_state_destroy(&c->state_tracker); @@ -343,8 +342,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(); c = (grpc_subchannel*)gpr_zalloc(sizeof(*c)); - c->uuid = - grpc_object_registry_register_object(c, GPRC_OBJECT_REGISTRY_SUBCHANNEL); + c->uuid = -1; c->key = key; gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS); c->connector = connector; @@ -393,15 +391,6 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, return grpc_subchannel_index_register(key, c); } -char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive) { - return subchannel->tracer != NULL - ? grpc_channel_tracer_render_trace(subchannel->tracer, recursive) - : NULL; -} -intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel) { - return subchannel->uuid; -} - static void continue_connect_locked(grpc_subchannel* c) { grpc_connect_in_args args; args.interested_parties = c->pollset_set; diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 3584d3928a..9d34fff07a 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -165,10 +165,6 @@ struct grpc_subchannel_args { grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, const grpc_subchannel_args* args); -/// retrieves the trace for this subchannel in JSON form. -char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive); -intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel); - /// Sets \a addr from \a args. void grpc_get_subchannel_address_arg(const grpc_channel_args* args, grpc_resolved_address* addr); diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 31c1d842a0..931f4b32b5 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -25,7 +25,6 @@ #include #include -#include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/object_registry.h" @@ -62,12 +61,11 @@ struct grpc_channel_tracer { }; #ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, const char* file, int line, const char* func) { #else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - intptr_t uuid) { +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes) { #endif grpc_channel_tracer* tracer = static_cast( gpr_zalloc(sizeof(grpc_channel_tracer))); @@ -78,7 +76,8 @@ grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); } #endif - tracer->channel_uuid = uuid; + tracer->channel_uuid = grpc_object_registry_register_object( + tracer, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); tracer->max_list_size = max_nodes; tracer->time_created = gpr_now(GPR_CLOCK_REALTIME); return tracer; @@ -145,6 +144,10 @@ void grpc_channel_tracer_unref(grpc_channel_tracer* tracer) { } #endif +intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer) { + return tracer->channel_uuid; +} + void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, @@ -318,18 +321,7 @@ char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL || - type == GPRC_OBJECT_REGISTRY_SUBCHANNEL); - switch (type) { - case GRPC_OBJECT_REGISTRY_CHANNEL: - return grpc_channel_get_trace(static_cast(object), - recursive); - break; - case GPRC_OBJECT_REGISTRY_SUBCHANNEL: - return grpc_subchannel_get_trace(static_cast(object), - recursive); - break; - default: - abort(); - } + GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + return grpc_channel_tracer_render_trace( + static_cast(object), recursive); } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 34bb242ca0..5c34f1bc44 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -30,16 +30,15 @@ extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; /* Creates a new tracer. The caller owns a reference to the returned tracer. */ #ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, const char* file, int line, const char* func); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ - grpc_channel_tracer_create(max_nodes, id, __FILE__, __LINE__, __func__) +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ + grpc_channel_tracer_create(max_nodes, __FILE__, __LINE__, __func__) #else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - intptr_t uuid); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ - grpc_channel_tracer_create(max_nodes, id) +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes); +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ + grpc_channel_tracer_create(max_nodes) #endif #ifndef NDEBUG @@ -59,6 +58,9 @@ void grpc_channel_tracer_unref(grpc_channel_tracer* tracer); #define GRPC_CHANNEL_TRACER_UNREF(tracer) grpc_channel_tracer_unref(tracer) #endif +/* returns the tracers uuid */ +intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer); + /* Adds a new trace node to the tracing object */ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, grpc_error* error, diff --git a/src/core/lib/support/object_registry.h b/src/core/lib/support/object_registry.h index 3a0d056e2a..1b8e13d054 100644 --- a/src/core/lib/support/object_registry.h +++ b/src/core/lib/support/object_registry.h @@ -22,8 +22,7 @@ #include typedef enum { - GRPC_OBJECT_REGISTRY_CHANNEL, - GPRC_OBJECT_REGISTRY_SUBCHANNEL, + GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, GRPC_OBJECT_REGISTRY_UNKNOWN, } grpc_object_registry_type; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e94413e3bc..e182da2718 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -101,10 +101,9 @@ grpc_channel* grpc_channel_create_with_builder( } memset(channel, 0, sizeof(*channel)); - channel->uuid = grpc_object_registry_register_object( - channel, GRPC_OBJECT_REGISTRY_CHANNEL); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); + channel->uuid = -1; channel->tracer = NULL; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -203,7 +202,8 @@ grpc_channel* grpc_channel_create_with_builder( size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); if (max_nodes > 0) { - channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, channel->uuid); + channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); + channel->uuid = grpc_channel_tracer_get_uuid(channel->tracer); } } } -- cgit v1.2.3 From e78bd519ca433cd4945da3a6c77284a11cca8bb6 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 21:40:45 -0800 Subject: Clangify my stale code --- src/core/lib/channel/channel_tracer.cc | 30 +++++++++++++++--------------- src/core/lib/json/json.cc | 8 ++++---- src/core/lib/support/object_registry.cc | 6 +++--- src/core/lib/surface/channel.cc | 8 ++++---- test/core/channel/channel_tracer_test.cc | 15 ++++++++------- test/core/util/channel_tracing_utils.cc | 13 +++++++------ 6 files changed, 41 insertions(+), 39 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 931f4b32b5..92be5987a1 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -113,7 +113,7 @@ static void free_node(grpc_trace_node* node) { static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { grpc_trace_node* it = tracer->head_trace; - while (it != NULL) { + while (it != nullptr) { grpc_trace_node* to_free = it; it = it->next; free_node(to_free); @@ -161,11 +161,11 @@ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, new_trace_node->error = error; new_trace_node->time_created = gpr_now(GPR_CLOCK_REALTIME); new_trace_node->connectivity_state = connectivity_state; - new_trace_node->next = NULL; + new_trace_node->next = nullptr; new_trace_node->referenced_tracer = GRPC_CHANNEL_TRACER_REF(referenced_tracer); // first node case - if (tracer->head_trace == NULL) { + if (tracer->head_trace == nullptr) { tracer->head_trace = tracer->tail_trace = new_trace_node; } // regular node add case @@ -223,7 +223,7 @@ static void recursively_populate_json(grpc_channel_tracer* tracer, static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, grpc_json* json, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", grpc_slice_to_c_string(node->data), GRPC_JSON_STRING, true); @@ -239,14 +239,14 @@ static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, child, json, "state", grpc_connectivity_state_name(node->connectivity_state), GRPC_JSON_STRING, false); - if (node->referenced_tracer != NULL) { + if (node->referenced_tracer != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%ld", node->referenced_tracer->channel_uuid); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { grpc_json* referenced_tracer = grpc_json_create_child( - NULL, children, NULL, NULL, GRPC_JSON_OBJECT, false); + nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); recursively_populate_json(node->referenced_tracer, tracker, referenced_tracer, true); } @@ -256,11 +256,11 @@ static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, static void populate_node_list_data(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* nodes, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; grpc_trace_node* it = tracer->head_trace; - while (it != NULL) { - child = grpc_json_create_child(child, nodes, NULL, NULL, GRPC_JSON_OBJECT, - false); + while (it != nullptr) { + child = grpc_json_create_child(child, nodes, nullptr, nullptr, + GRPC_JSON_OBJECT, false); populate_node_data(it, tracker, child, children); it = it->next; } @@ -269,7 +269,7 @@ static void populate_node_list_data(grpc_channel_tracer* tracer, static void populate_tracer_data(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* channel_data, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; char* uuid_str; gpr_asprintf(&uuid_str, "%ld", tracer->channel_uuid); @@ -282,7 +282,7 @@ static void populate_tracer_data(grpc_channel_tracer* tracer, child = grpc_json_create_child(child, channel_data, "startTime", fmt_time(tracer->time_created), GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", NULL, + child = grpc_json_create_child(child, channel_data, "nodes", nullptr, GRPC_JSON_ARRAY, false); populate_node_list_data(tracer, tracker, child, children); } @@ -291,10 +291,10 @@ static void recursively_populate_json(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* json, bool recursive) { grpc_json* channel_data = grpc_json_create_child( - NULL, json, "channelData", NULL, GRPC_JSON_OBJECT, false); - grpc_json* children = NULL; + nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); + grpc_json* children = nullptr; if (recursive) { - children = grpc_json_create_child(channel_data, json, "children", NULL, + children = grpc_json_create_child(channel_data, json, "children", nullptr, GRPC_JSON_ARRAY, false); } seen_tracers_add(tracker, tracer); diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 2171e69455..0b84a38199 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -55,16 +55,16 @@ void grpc_json_destroy(grpc_json* json) { grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, grpc_json* sibling) { // first child case. - if (parent->child == NULL) { - GPR_ASSERT(sibling == NULL); + if (parent->child == nullptr) { + GPR_ASSERT(sibling == nullptr); parent->child = child; return child; } - if (sibling == NULL) { + if (sibling == nullptr) { sibling = parent->child; } // always find the right most sibling. - while (sibling->next != NULL) { + while (sibling->next != nullptr) { sibling = sibling->next; } sibling->next = child; diff --git a/src/core/lib/support/object_registry.cc b/src/core/lib/support/object_registry.cc index 596711804f..bd19bb13a6 100644 --- a/src/core/lib/support/object_registry.cc +++ b/src/core/lib/support/object_registry.cc @@ -73,7 +73,7 @@ intptr_t grpc_object_registry_register_object(void* object, tracker->type = type; intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); gpr_mu_lock(&g_mu); - g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, NULL); + g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, nullptr); gpr_mu_unlock(&g_mu); return prior; } @@ -91,8 +91,8 @@ grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, object_tracker* tracker = static_cast(gpr_avl_get(g_avl, (void*)uuid, nullptr)); gpr_mu_unlock(&g_mu); - if (tracker == NULL) { - *object = NULL; + if (tracker == nullptr) { + *object = nullptr; return GRPC_OBJECT_REGISTRY_UNKNOWN; } *object = tracker->object; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e182da2718..35e94f5dc1 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -104,7 +104,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); channel->uuid = -1; - channel->tracer = NULL; + channel->tracer = nullptr; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -196,7 +196,7 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel->tracer == NULL); + GPR_ASSERT(channel->tracer == nullptr); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = @@ -211,14 +211,14 @@ grpc_channel* grpc_channel_create_with_builder( grpc_channel_args_destroy(args); grpc_channel_tracer_add_trace( channel->tracer, grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, NULL); + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); return channel; } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer ? grpc_channel_tracer_render_trace(channel->tracer, recursive) - : NULL; + : nullptr; } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 47bb4302de..4f1ce160a1 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -30,9 +30,10 @@ #include "test/core/util/test_config.h" static void add_simple_trace(grpc_channel_tracer* tracer) { - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY, NULL); + grpc_channel_tracer_add_trace(tracer, + grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY, nullptr); } // checks for the existence of all the required members of the tracer. @@ -66,10 +67,10 @@ static void test_basic_channel_tracing(size_t max_nodes) { tracer, grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE, NULL); - grpc_channel_tracer_add_trace(tracer, - grpc_slice_from_static_string("trace four"), - GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN, NULL); + GRPC_CHANNEL_IDLE, nullptr); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, + GRPC_CHANNEL_SHUTDOWN, nullptr); validate_tracer(tracer, 4, max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 805726ff16..5644d1811d 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -25,11 +25,12 @@ #include "src/core/lib/json/json.h" static grpc_json* get_json_child(grpc_json* parent, const char* key) { - GPR_ASSERT(parent != NULL); - for (grpc_json* child = parent->child; child != NULL; child = child->next) { - if (child->key != NULL && strcmp(child->key, key) == 0) return child; + GPR_ASSERT(parent != nullptr); + for (grpc_json* child = parent->child; child != nullptr; + child = child->next) { + if (child->key != nullptr && strcmp(child->key, key) == 0) return child; } - return NULL; + return nullptr; } void validate_json_array_size(grpc_json* json, const char* key, @@ -38,7 +39,7 @@ void validate_json_array_size(grpc_json* json, const char* key, GPR_ASSERT(arr); GPR_ASSERT(arr->type == GRPC_JSON_ARRAY); size_t count = 0; - for (grpc_json* child = arr->child; child != NULL; child = child->next) { + for (grpc_json* child = arr->child; child != nullptr; child = child->next) { ++count; } GPR_ASSERT(count == expected_size); @@ -54,7 +55,7 @@ void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, grpc_json* start_time = get_json_child(channel_data, "startTime"); GPR_ASSERT(start_time); size_t num_nodes_logged = - (size_t)strtol(num_nodes_logged_json->value, NULL, 0); + (size_t)strtol(num_nodes_logged_json->value, nullptr, 0); GPR_ASSERT(num_nodes_logged == num_nodes_logged_expected); validate_json_array_size(channel_data, "nodes", actual_num_nodes_expected); } -- cgit v1.2.3 From 6572ce2c4a11c65cbacd6434070f21254d81e917 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 18 Jan 2018 17:50:00 -0800 Subject: Classify the tracer object --- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 370 +++++++++------------- src/core/lib/channel/channel_tracer.h | 84 +++-- src/core/lib/support/object_registry.cc | 2 +- src/core/lib/surface/channel.cc | 17 +- test/core/channel/channel_tracer_test.cc | 214 +++++++------ 6 files changed, 316 insertions(+), 373 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index f4b6c2a161..0310f152cc 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -137,7 +137,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_channel_tracer* tracer; + grpc_core::ChannelTracer* tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index e2d3b7ae08..e93fbc29d8 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -32,6 +32,8 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/connectivity_state.h" +namespace grpc_core { + grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount( false, "channel_tracer_refcount"); @@ -44,116 +46,55 @@ typedef struct grpc_trace_node { struct grpc_trace_node* next; // the tracer object for the (sub)channel that this trace node refers to. - grpc_channel_tracer* referenced_tracer; + ChannelTracer* referenced_tracer; } grpc_trace_node; -/* the channel tracing object */ -struct grpc_channel_tracer { - gpr_refcount refs; - gpr_mu tracer_mu; - intptr_t channel_uuid; - uint64_t num_nodes_logged; - size_t list_size; - size_t max_list_size; - grpc_trace_node* head_trace; - grpc_trace_node* tail_trace; - gpr_timespec time_created; -}; - -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - const char* file, int line, - const char* func) { -#else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes) { -#endif - grpc_channel_tracer* tracer = static_cast( - gpr_zalloc(sizeof(grpc_channel_tracer))); - gpr_mu_init(&tracer->tracer_mu); - gpr_ref_init(&tracer->refs, 1); -#ifndef NDEBUG - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); - } -#endif - tracer->channel_uuid = grpc_object_registry_register_object( - tracer, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - tracer->max_list_size = max_nodes; - tracer->time_created = gpr_now(GPR_CLOCK_REALTIME); - return tracer; +ChannelTracer::ChannelTracer(size_t max_nodes) + : num_nodes_logged(0), + list_size(0), + max_list_size(max_nodes), + head_trace(0), + tail_trace(0) { + gpr_mu_init(&tracer_mu); + gpr_ref_init(&refs, 1); + channel_uuid = grpc_object_registry_register_object( + this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + max_list_size = max_nodes; + time_created = gpr_now(GPR_CLOCK_REALTIME); } -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, - const char* file, int line, - const char* func) { - if (!tracer) return tracer; - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) + 1, file, line, func); - } - gpr_ref(&tracer->refs); - return tracer; +ChannelTracer* ChannelTracer::Ref() { + gpr_ref(&refs); + return this; } -#else -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer) { - if (!tracer) return tracer; - gpr_ref(&tracer->refs); - return tracer; -} -#endif static void free_node(grpc_trace_node* node) { GRPC_ERROR_UNREF(node->error); - GRPC_CHANNEL_TRACER_UNREF(node->referenced_tracer); + if (node->referenced_tracer) { + node->referenced_tracer->Unref(); + } grpc_slice_unref_internal(node->data); gpr_free(node); } -static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { - grpc_trace_node* it = tracer->head_trace; - while (it != nullptr) { - grpc_trace_node* to_free = it; - it = it->next; - free_node(to_free); - } - gpr_mu_destroy(&tracer->tracer_mu); - gpr_free(tracer); -} - -#ifndef NDEBUG -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, - int line, const char* func) { - if (!tracer) return; - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) - 1, file, line, func); - } - if (gpr_unref(&tracer->refs)) { - grpc_channel_tracer_destroy(tracer); - } -} -#else -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer) { - if (!tracer) return; - if (gpr_unref(&tracer->refs)) { - grpc_channel_tracer_destroy(tracer); +void ChannelTracer::Unref() { + if (gpr_unref(&refs)) { + grpc_trace_node* it = head_trace; + while (it != nullptr) { + grpc_trace_node* to_free = it; + it = it->next; + free_node(to_free); + } + gpr_mu_destroy(&tracer_mu); } } -#endif -intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer) { - return tracer->channel_uuid; -} +intptr_t ChannelTracer::GetUuid() { return channel_uuid; } -void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, - grpc_error* error, - grpc_connectivity_state connectivity_state, - grpc_channel_tracer* referenced_tracer) { - if (!tracer) return; - ++tracer->num_nodes_logged; +void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* referenced_tracer) { + ++num_nodes_logged; // create and fill up the new node grpc_trace_node* new_trace_node = static_cast(gpr_malloc(sizeof(grpc_trace_node))); @@ -163,23 +104,23 @@ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, new_trace_node->connectivity_state = connectivity_state; new_trace_node->next = nullptr; new_trace_node->referenced_tracer = - GRPC_CHANNEL_TRACER_REF(referenced_tracer); + (referenced_tracer) ? referenced_tracer->Ref() : nullptr; // first node case - if (tracer->head_trace == nullptr) { - tracer->head_trace = tracer->tail_trace = new_trace_node; + if (head_trace == nullptr) { + head_trace = tail_trace = new_trace_node; } // regular node add case else { - tracer->tail_trace->next = new_trace_node; - tracer->tail_trace = tracer->tail_trace->next; + tail_trace->next = new_trace_node; + tail_trace = tail_trace->next; } - ++tracer->list_size; + ++list_size; // maybe garbage collect the end - if (tracer->list_size > tracer->max_list_size) { - grpc_trace_node* to_free = tracer->head_trace; - tracer->head_trace = tracer->head_trace->next; + if (list_size > max_list_size) { + grpc_trace_node* to_free = head_trace; + head_trace = head_trace->next; free_node(to_free); - --tracer->list_size; + --list_size; } } @@ -193,135 +134,138 @@ static char* fmt_time(gpr_timespec tm) { return full_time_str; } -typedef struct seen_tracers { - grpc_channel_tracer** tracers; - size_t size; - size_t cap; -} seen_tracers; +class ChannelTracerRenderer { + public: + ChannelTracerRenderer(ChannelTracer* tracer, bool recursive) + : current_tracer_(tracer), + recursive_(recursive), + seen_tracers_(nullptr), + size_(0), + cap_(0) {} -static void seen_tracers_add(seen_tracers* tracker, - grpc_channel_tracer* tracer) { - if (tracker->size >= tracker->cap) { - tracker->cap = GPR_MAX(5 * sizeof(tracer), 3 * tracker->cap / 2); - tracker->tracers = - (grpc_channel_tracer**)gpr_realloc(tracker->tracers, tracker->cap); + char* Run() { + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + AddSeenTracer(current_tracer_); + RecursivelyPopulateJson(json); + gpr_free(seen_tracers_); + char* json_str = grpc_json_dump_to_string(json, 1); + grpc_json_destroy(json); + return json_str; } - tracker->tracers[tracker->size++] = tracer; -} -static bool seen_tracers_check(seen_tracers* tracker, - grpc_channel_tracer* tracer) { - for (size_t i = 0; i < tracker->size; ++i) { - if (tracker->tracers[i] == tracer) return true; + private: + void AddSeenTracer(ChannelTracer* newly_seen) { + if (size_ >= cap_) { + cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); + seen_tracers_ = (ChannelTracer**)gpr_realloc(seen_tracers_, cap_); + } + seen_tracers_[size_++] = newly_seen; } - return false; -} -static void recursively_populate_json(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* json, - bool recursive); - -static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, - grpc_json* json, grpc_json* children) { - grpc_json* child = nullptr; - child = grpc_json_create_child(child, json, "data", - grpc_slice_to_c_string(node->data), - GRPC_JSON_STRING, true); - if (node->error != GRPC_ERROR_NONE) { - child = grpc_json_create_child(child, json, "error", - gpr_strdup(grpc_error_string(node->error)), - GRPC_JSON_STRING, true); - } - child = - grpc_json_create_child(child, json, "time", fmt_time(node->time_created), - GRPC_JSON_STRING, true); - child = grpc_json_create_child( - child, json, "state", - grpc_connectivity_state_name(node->connectivity_state), GRPC_JSON_STRING, - false); - if (node->referenced_tracer != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, node->referenced_tracer->channel_uuid); - child = grpc_json_create_child(child, json, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { - grpc_json* referenced_tracer = grpc_json_create_child( - nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - recursively_populate_json(node->referenced_tracer, tracker, - referenced_tracer, true); + bool TracerAlreadySeen(ChannelTracer* tracer) { + for (size_t i = 0; i < size_; ++i) { + if (seen_tracers_[i] == tracer) return true; } + return false; } -} -static void populate_node_list_data(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* nodes, - grpc_json* children) { - grpc_json* child = nullptr; - grpc_trace_node* it = tracer->head_trace; - while (it != nullptr) { - child = grpc_json_create_child(child, nodes, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - populate_node_data(it, tracker, child, children); - it = it->next; + void RecursivelyPopulateJson(grpc_json* json) { + grpc_json* channel_data = grpc_json_create_child( + nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); + grpc_json* children = nullptr; + if (recursive_) { + children = grpc_json_create_child(channel_data, json, "children", nullptr, + GRPC_JSON_ARRAY, false); + } + PopulateTracer(channel_data, children); } -} -static void populate_tracer_data(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* channel_data, - grpc_json* children) { - grpc_json* child = nullptr; + void PopulateTracer(grpc_json* channel_data, grpc_json* children) { + grpc_json* child = nullptr; - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, tracer->channel_uuid); - child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - char* num_nodes_logged_str; - gpr_asprintf(&num_nodes_logged_str, "%" PRId64, tracer->num_nodes_logged); - child = grpc_json_create_child(child, channel_data, "numNodesLogged", - num_nodes_logged_str, GRPC_JSON_NUMBER, true); - child = grpc_json_create_child(child, channel_data, "startTime", - fmt_time(tracer->time_created), - GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", nullptr, - GRPC_JSON_ARRAY, false); - populate_node_list_data(tracer, tracker, child, children); -} - -static void recursively_populate_json(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* json, - bool recursive) { - grpc_json* channel_data = grpc_json_create_child( - nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); - grpc_json* children = nullptr; - if (recursive) { - children = grpc_json_create_child(channel_data, json, "children", nullptr, - GRPC_JSON_ARRAY, false); + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid); + child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + char* num_nodes_logged_str; + gpr_asprintf(&num_nodes_logged_str, "%" PRId64, + current_tracer_->num_nodes_logged); + child = + grpc_json_create_child(child, channel_data, "numNodesLogged", + num_nodes_logged_str, GRPC_JSON_NUMBER, true); + child = grpc_json_create_child(child, channel_data, "startTime", + fmt_time(current_tracer_->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child(child, channel_data, "nodes", nullptr, + GRPC_JSON_ARRAY, false); + PopulateNodeList(child, children); } - seen_tracers_add(tracker, tracer); - populate_tracer_data(tracer, tracker, channel_data, children); -} - -char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, - bool recursive) { - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - seen_tracers tracker; - memset(&tracker, 0, sizeof(tracker)); + void PopulateNodeList(grpc_json* nodes, grpc_json* children) { + grpc_json* child = nullptr; + grpc_trace_node* it = current_tracer_->head_trace; + while (it != nullptr) { + child = grpc_json_create_child(child, nodes, nullptr, nullptr, + GRPC_JSON_OBJECT, false); + PopulateNode(it, child, children); + it = it->next; + } + } - recursively_populate_json(tracer, &tracker, json, recursive); + void PopulateNode(grpc_trace_node* node, grpc_json* json, + grpc_json* children) { + grpc_json* child = nullptr; + child = grpc_json_create_child(child, json, "data", + grpc_slice_to_c_string(node->data), + GRPC_JSON_STRING, true); + if (node->error != GRPC_ERROR_NONE) { + child = grpc_json_create_child(child, json, "error", + gpr_strdup(grpc_error_string(node->error)), + GRPC_JSON_STRING, true); + } + child = grpc_json_create_child(child, json, "time", + fmt_time(node->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child( + child, json, "state", + grpc_connectivity_state_name(node->connectivity_state), + GRPC_JSON_STRING, false); + if (node->referenced_tracer != nullptr) { + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, + node->referenced_tracer->channel_uuid); + child = grpc_json_create_child(child, json, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + if (children && !TracerAlreadySeen(node->referenced_tracer)) { + grpc_json* referenced_tracer = grpc_json_create_child( + nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); + AddSeenTracer(node->referenced_tracer); + ChannelTracer* saved = current_tracer_; + current_tracer_ = node->referenced_tracer; + RecursivelyPopulateJson(referenced_tracer); + current_tracer_ = saved; + } + } + } - gpr_free(tracker.tracers); + ChannelTracer* current_tracer_; + bool recursive_; + ChannelTracer** seen_tracers_; + size_t size_; + size_t cap_; +}; - char* json_str = grpc_json_dump_to_string(json, 1); - grpc_json_destroy(json); - return json_str; +char* ChannelTracer::RenderTrace(bool recursive) { + ChannelTracerRenderer renderer(this, recursive); + return renderer.Run(); } -char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive) { +char* ChannelTracer::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - return grpc_channel_tracer_render_trace( - static_cast(object), recursive); + return static_cast(object)->RenderTrace(recursive); } + +} // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 5c34f1bc44..6b7d719028 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -23,58 +23,52 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" -/* Forward declaration */ -typedef struct grpc_channel_tracer grpc_channel_tracer; +namespace grpc_core { extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; -/* Creates a new tracer. The caller owns a reference to the returned tracer. */ -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - const char* file, int line, - const char* func); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ - grpc_channel_tracer_create(max_nodes, __FILE__, __LINE__, __func__) -#else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ - grpc_channel_tracer_create(max_nodes) -#endif +typedef struct grpc_trace_node grpc_trace_node; -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, - const char* file, int line, - const char* func); -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, - int line, const char* func); -#define GRPC_CHANNEL_TRACER_REF(tracer) \ - grpc_channel_tracer_ref(tracer, __FILE__, __LINE__, __func__) -#define GRPC_CHANNEL_TRACER_UNREF(tracer) \ - grpc_channel_tracer_unref(tracer, __FILE__, __LINE__, __func__) -#else -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer); -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer); -#define GRPC_CHANNEL_TRACER_REF(tracer) grpc_channel_tracer_ref(tracer) -#define GRPC_CHANNEL_TRACER_UNREF(tracer) grpc_channel_tracer_unref(tracer) -#endif +class ChannelTracer { + public: + ChannelTracer(size_t max_nodes); + ~ChannelTracer() {} -/* returns the tracers uuid */ -intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer); + // TODO(ncteisen): incorporate RefCounted class + ChannelTracer* Ref(); + void Unref(); -/* Adds a new trace node to the tracing object */ -void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, - grpc_error* error, - grpc_connectivity_state connectivity_state, - grpc_channel_tracer* subchannel); + /* returns the tracers uuid */ + intptr_t GetUuid(); -/* Returns the tracing data rendered as a grpc json string. - The string is owned by the caller and must be freed. If recursive - is true, then the string will include the recursive trace for all - subtracing objects. */ -char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, - bool recursive); -/* util functions that perform the uuid -> tracer step for you, and then + /* Adds a new trace node to the tracing object */ + void AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* subchannel); + + /* Returns the tracing data rendered as a grpc json string. + The string is owned by the caller and must be freed. If recursive + is true, then the string will include the recursive trace for all + subtracing objects. */ + char* RenderTrace(bool recursive); + + /* util functions that perform the uuid -> tracer step for you, and then returns the trace for the uuid given. */ -char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive); + static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); + + private: + friend class ChannelTracerRenderer; + gpr_refcount refs; + gpr_mu tracer_mu; + intptr_t channel_uuid; + uint64_t num_nodes_logged; + size_t list_size; + size_t max_list_size; + grpc_trace_node* head_trace; + grpc_trace_node* tail_trace; + gpr_timespec time_created; +}; + +} // namespace grpc_core #endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H */ diff --git a/src/core/lib/support/object_registry.cc b/src/core/lib/support/object_registry.cc index bd19bb13a6..72403a4f76 100644 --- a/src/core/lib/support/object_registry.cc +++ b/src/core/lib/support/object_registry.cc @@ -37,7 +37,7 @@ typedef struct { static void destroy_intptr(void* not_used, void* user_data) {} static void* copy_intptr(void* key, void* user_data) { return key; } static long compare_intptr(void* key1, void* key2, void* user_data) { - return key1 > key2; + return (intptr_t)key1 - (intptr_t)key2; } static void destroy_tracker(void* tracker, void* user_data) { diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 35e94f5dc1..e80c36465e 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/memory.h" #include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" @@ -63,7 +64,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_channel_tracer* tracer; + grpc_core::ChannelTracer* tracer; char* target; }; @@ -202,23 +203,21 @@ grpc_channel* grpc_channel_create_with_builder( size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); if (max_nodes > 0) { - channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - channel->uuid = grpc_channel_tracer_get_uuid(channel->tracer); + channel->tracer = grpc_core::New( + max_nodes); // TODO(ncteisen): leaky yo + channel->uuid = channel->tracer->GetUuid(); } } } grpc_channel_args_destroy(args); - grpc_channel_tracer_add_trace( - channel->tracer, grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); + channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); return channel; } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { - return channel->tracer - ? grpc_channel_tracer_render_trace(channel->tracer, recursive) - : nullptr; + return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 4f1ce160a1..131ea567fc 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -29,18 +29,19 @@ #include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" -static void add_simple_trace(grpc_channel_tracer* tracer) { - grpc_channel_tracer_add_trace(tracer, - grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY, nullptr); +using grpc_core::ChannelTracer; + +static void add_simple_trace(ChannelTracer* tracer) { + tracer->AddTrace(grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY, nullptr); } // checks for the existence of all the required members of the tracer. -static void validate_tracer(grpc_channel_tracer* tracer, +static void validate_tracer(ChannelTracer* tracer, size_t expected_num_nodes_logged, size_t max_nodes) { - char* json_str = grpc_channel_tracer_render_trace(tracer, true); + char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_channel_data(json, expected_num_nodes_logged, GPR_MIN(expected_num_nodes_logged, max_nodes)); @@ -48,10 +49,20 @@ static void validate_tracer(grpc_channel_tracer* tracer, gpr_free(json_str); } +static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { + intptr_t uuid = tracer->GetUuid(); + char* tracer_json_str = tracer->RenderTrace(true); + char* uuid_lookup_json_str = + ChannelTracer::GetChannelTraceFromUuid(uuid, true); + strcmp(tracer_json_str, uuid_lookup_json_str); + gpr_free(tracer_json_str); + gpr_free(uuid_lookup_json_str); +} + // ensures the tracer has the correct number of children tracers. -static void validate_children(grpc_channel_tracer* tracer, +static void validate_children(ChannelTracer* tracer, size_t expected_num_children) { - char* json_str = grpc_channel_tracer_render_trace(tracer, true); + char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_json_array_size(json, "children", expected_num_children); grpc_json_destroy(json); @@ -59,28 +70,29 @@ static void validate_children(grpc_channel_tracer* tracer, } static void test_basic_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("trace three"), + ChannelTracer tracer(max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer_data_matches_uuid_lookup(&tracer); + tracer.AddTrace( + grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), GRPC_CHANNEL_IDLE, nullptr); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, - GRPC_CHANNEL_SHUTDOWN, nullptr); - validate_tracer(tracer, 4, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 10, max_nodes); - GRPC_CHANNEL_TRACER_UNREF(tracer); + tracer.AddTrace(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, + GRPC_CHANNEL_SHUTDOWN, nullptr); + validate_tracer(&tracer, 4, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 6, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 10, max_nodes); + validate_tracer_data_matches_uuid_lookup(&tracer); + tracer.Unref(); } static void test_basic_channel_sizing() { @@ -93,43 +105,42 @@ static void test_basic_channel_sizing() { } static void test_complex_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); - validate_tracer(sc1, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); - validate_tracer(sc1, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 5, max_nodes); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 7, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - GRPC_CHANNEL_TRACER_UNREF(sc1); - GRPC_CHANNEL_TRACER_UNREF(sc2); - GRPC_CHANNEL_TRACER_UNREF(tracer); + ChannelTracer tracer(max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(max_nodes); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_tracer(&tracer, 3, max_nodes); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + validate_tracer(&sc1, 3, max_nodes); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + validate_tracer(&sc1, 6, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 5, max_nodes); + validate_tracer_data_matches_uuid_lookup(&tracer); + ChannelTracer sc2(max_nodes); + tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_tracer(&tracer, 7, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + // validate_tracer_data_matches_uuid_lookup(&tracer); + sc1.Unref(); + sc2.Unref(); + tracer.Unref(); } static void test_complex_channel_sizing() { @@ -142,57 +153,52 @@ static void test_complex_channel_sizing() { } static void test_delete_parent_first() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(3); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(3); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + ChannelTracer tracer(3); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(3); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); // this will cause the tracer destructor to run. - GRPC_CHANNEL_TRACER_UNREF(tracer); - GRPC_CHANNEL_TRACER_UNREF(sc1); + tracer.Unref(); + sc1.Unref(); } static void test_nesting() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(10); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(5); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + ChannelTracer tracer(10); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(5); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); // channel has only one subchannel right here. - validate_children(tracer, 1); - add_simple_trace(sc1); - grpc_channel_tracer* conn1 = GRPC_CHANNEL_TRACER_CREATE(5); + validate_children(&tracer, 1); + add_simple_trace(&sc1); + ChannelTracer conn1(5); // nesting one level deeper. - grpc_channel_tracer_add_trace( - sc1, grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); - validate_children(sc1, 1); - add_simple_trace(conn1); - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(5); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - validate_children(tracer, 2); + sc1.AddTrace(grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &conn1); + validate_children(&sc1, 1); + add_simple_trace(&conn1); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc2(5); + tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); + validate_children(&tracer, 2); // this trace should not get added to the parents children since it is already // present in the tracer. - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_children(tracer, 2); - add_simple_trace(tracer); - - GRPC_CHANNEL_TRACER_UNREF(conn1); - GRPC_CHANNEL_TRACER_UNREF(sc1); - GRPC_CHANNEL_TRACER_UNREF(sc2); - GRPC_CHANNEL_TRACER_UNREF(tracer); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_children(&tracer, 2); + add_simple_trace(&tracer); + + conn1.Unref(); + sc1.Unref(); + sc2.Unref(); + tracer.Unref(); } int main(int argc, char** argv) { -- cgit v1.2.3 From f41e24b35fe9fd79c20531cf9a51281b47733ce2 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Sat, 20 Jan 2018 11:40:12 -0800 Subject: Remove uuid from channel --- src/core/lib/surface/channel.cc | 5 ----- src/core/lib/surface/channel.h | 1 - 2 files changed, 6 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e80c36465e..12b920a2c4 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -54,7 +54,6 @@ typedef struct registered_call { } registered_call; struct grpc_channel { - intptr_t uuid; int is_client; grpc_compression_options compression_options; grpc_mdelem default_authority; @@ -104,7 +103,6 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - channel->uuid = -1; channel->tracer = nullptr; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -205,7 +203,6 @@ grpc_channel* grpc_channel_create_with_builder( if (max_nodes > 0) { channel->tracer = grpc_core::New( max_nodes); // TODO(ncteisen): leaky yo - channel->uuid = channel->tracer->GetUuid(); } } } @@ -220,8 +217,6 @@ char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; } -intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } - grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 507013f452..5820bbbd80 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -59,7 +59,6 @@ size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); -intptr_t grpc_channel_get_uuid(grpc_channel* channel); #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); -- cgit v1.2.3 From 6f196afc9ea527adf8c81cc7cf7e151e20e32116 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Sat, 20 Jan 2018 11:50:08 -0800 Subject: Switch to use manual constructor --- src/core/lib/channel/channel_tracer.cc | 8 +++++++- src/core/lib/surface/channel.cc | 15 +++++++-------- test/core/channel/channel_tracer_test.cc | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bb8ba969ea..df0e56d19a 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -56,11 +56,13 @@ struct TraceEvent { }; ChannelTracer::ChannelTracer(size_t max_nodes) - : num_nodes_logged_(0), + : channel_uuid_(-1), + num_nodes_logged_(0), list_size_(0), max_list_size_(max_nodes), head_trace_(0), tail_trace_(0) { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); gpr_ref_init(&refs_, 1); channel_uuid_ = grpc_object_registry_register_object( @@ -70,6 +72,7 @@ ChannelTracer::ChannelTracer(size_t max_nodes) } ChannelTracer* ChannelTracer::Ref() { + if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 gpr_ref(&refs_); return this; } @@ -84,6 +87,7 @@ void ChannelTracer::FreeNode(TraceEvent* node) { } void ChannelTracer::Unref() { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 if (gpr_unref(&refs_)) { TraceEvent* it = head_trace_; while (it != nullptr) { @@ -100,6 +104,7 @@ intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, ChannelTracer* referenced_tracer) { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 ++num_nodes_logged_; // create and fill up the new node TraceEvent* new_trace_node = @@ -254,6 +259,7 @@ class ChannelTracerRenderer { }; char* ChannelTracer::RenderTrace(bool recursive) { + if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 ChannelTracerRenderer renderer(this, recursive); return renderer.Run(); } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 12b920a2c4..5d36e5b313 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/manual_constructor.h" #include "src/core/lib/support/memory.h" #include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" @@ -63,7 +64,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::ChannelTracer* tracer; + grpc_core::ManualConstructor tracer; char* target; }; @@ -103,7 +104,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - channel->tracer = nullptr; + bool tracer_initialized = false; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -195,15 +196,13 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel->tracer == nullptr); + GPR_ASSERT(!tracer_initialized); + tracer_initialized = true; // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - if (max_nodes > 0) { - channel->tracer = grpc_core::New( - max_nodes); // TODO(ncteisen): leaky yo - } + channel->tracer.Init(max_nodes); } } @@ -214,7 +213,7 @@ grpc_channel* grpc_channel_create_with_builder( } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { - return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; + return channel->tracer->RenderTrace(recursive); } grpc_channel* grpc_channel_create(const char* target, diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 131ea567fc..c1c9e5b57f 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -41,6 +41,7 @@ static void add_simple_trace(ChannelTracer* tracer) { static void validate_tracer(ChannelTracer* tracer, size_t expected_num_nodes_logged, size_t max_nodes) { + if (!max_nodes) return; char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_channel_data(json, expected_num_nodes_logged, @@ -51,6 +52,7 @@ static void validate_tracer(ChannelTracer* tracer, static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { intptr_t uuid = tracer->GetUuid(); + if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(true); char* uuid_lookup_json_str = ChannelTracer::GetChannelTraceFromUuid(uuid, true); -- cgit v1.2.3 From 34ebf5dd9eea03be7f744ea456cbd4acd950da86 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 09:10:14 -0800 Subject: Move object registry out of gpr --- BUILD | 2 + CMakeLists.txt | 7 +- Makefile | 7 +- build.yaml | 4 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 5 +- package.xml | 4 +- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 3 +- src/core/lib/channel/object_registry.cc | 100 +++++++++++++++++++++ src/core/lib/channel/object_registry.h | 43 +++++++++ src/core/lib/gpr/object_registry.cc | 100 --------------------- src/core/lib/gpr/object_registry.h | 43 --------- src/core/lib/surface/channel.cc | 2 +- src/core/lib/surface/init.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 6 +- 22 files changed, 184 insertions(+), 168 deletions(-) create mode 100644 src/core/lib/channel/object_registry.cc create mode 100644 src/core/lib/channel/object_registry.h delete mode 100644 src/core/lib/gpr/object_registry.cc delete mode 100644 src/core/lib/gpr/object_registry.h (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 30b0488dc3..1df5df7f3d 100644 --- a/BUILD +++ b/BUILD @@ -626,6 +626,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_tracer.cc", "src/core/lib/channel/connected_channel.cc", + "src/core/lib/channel/object_registry.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", @@ -762,6 +763,7 @@ grpc_cc_library( "src/core/lib/channel/channel_tracer.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", + "src/core/lib/channel/object_registry.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 1057ade8ec..91aca47ddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,7 +645,6 @@ add_library(gpr src/core/lib/gpr/log_windows.cc src/core/lib/gpr/mpscq.cc src/core/lib/gpr/murmur_hash.cc - src/core/lib/gpr/object_registry.cc src/core/lib/gpr/string.cc src/core/lib/gpr/string_posix.cc src/core/lib/gpr/string_util_windows.cc @@ -803,6 +802,7 @@ add_library(grpc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1144,6 +1144,7 @@ add_library(grpc_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1469,6 +1470,7 @@ add_library(grpc_test_util src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1738,6 +1740,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1989,6 +1992,7 @@ add_library(grpc_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -2728,6 +2732,7 @@ add_library(grpc++_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc diff --git a/Makefile b/Makefile index eddd3ad6dc..69b1ed70cb 100644 --- a/Makefile +++ b/Makefile @@ -2865,7 +2865,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/log_windows.cc \ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ - src/core/lib/gpr/object_registry.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ @@ -3004,6 +3003,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3347,6 +3347,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3673,6 +3674,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3935,6 +3937,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -4166,6 +4169,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -4898,6 +4902,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ diff --git a/build.yaml b/build.yaml index 2948384596..fc64700970 100644 --- a/build.yaml +++ b/build.yaml @@ -47,7 +47,6 @@ filegroups: - src/core/lib/gpr/log_windows.cc - src/core/lib/gpr/mpscq.cc - src/core/lib/gpr/murmur_hash.cc - - src/core/lib/gpr/object_registry.cc - src/core/lib/gpr/string.cc - src/core/lib/gpr/string_posix.cc - src/core/lib/gpr/string_util_windows.cc @@ -107,7 +106,6 @@ filegroups: - src/core/lib/gpr/fork.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - - src/core/lib/gpr/object_registry.h - src/core/lib/gpr/spinlock.h - src/core/lib/gpr/string.h - src/core/lib/gpr/string_windows.h @@ -161,6 +159,7 @@ filegroups: - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc + - src/core/lib/channel/object_registry.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/message_compress.cc - src/core/lib/compression/stream_compression.cc @@ -318,6 +317,7 @@ filegroups: - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h + - src/core/lib/channel/object_registry.cc - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h - src/core/lib/compression/stream_compression.h diff --git a/config.m4 b/config.m4 index b030b37438..8a6ccc8d0d 100644 --- a/config.m4 +++ b/config.m4 @@ -60,7 +60,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/log_windows.cc \ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ - src/core/lib/gpr/object_registry.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ @@ -94,6 +93,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ diff --git a/config.w32 b/config.w32 index 838e17ae81..42a47fca15 100644 --- a/config.w32 +++ b/config.w32 @@ -37,7 +37,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\log_windows.cc " + "src\\core\\lib\\gpr\\mpscq.cc " + "src\\core\\lib\\gpr\\murmur_hash.cc " + - "src\\core\\lib\\gpr\\object_registry.cc " + "src\\core\\lib\\gpr\\string.cc " + "src\\core\\lib\\gpr\\string_posix.cc " + "src\\core\\lib\\gpr\\string_util_windows.cc " + @@ -71,6 +70,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + + "src\\core\\lib\\channel\\object_registry.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\message_compress.cc " + "src\\core\\lib\\compression\\stream_compression.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 21e39af072..8c4ae86bc4 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -197,7 +197,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', - 'src/core/lib/gpr/object_registry.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/string_windows.h', @@ -232,7 +231,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -340,6 +338,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', @@ -482,6 +481,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -727,7 +727,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', - 'src/core/lib/gpr/object_registry.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/string_windows.h', @@ -825,6 +824,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', diff --git a/grpc.gemspec b/grpc.gemspec index 085b093c8e..9d2b4a94b1 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -88,7 +88,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/fork.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) - s.files += %w( src/core/lib/gpr/object_registry.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) s.files += %w( src/core/lib/gpr/string.h ) s.files += %w( src/core/lib/gpr/string_windows.h ) @@ -123,7 +122,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/log_windows.cc ) s.files += %w( src/core/lib/gpr/mpscq.cc ) s.files += %w( src/core/lib/gpr/murmur_hash.cc ) - s.files += %w( src/core/lib/gpr/object_registry.cc ) s.files += %w( src/core/lib/gpr/string.cc ) s.files += %w( src/core/lib/gpr/string_posix.cc ) s.files += %w( src/core/lib/gpr/string_util_windows.cc ) @@ -266,6 +264,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) + s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/compression/stream_compression.h ) @@ -412,6 +411,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) + s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) s.files += %w( src/core/lib/compression/stream_compression.cc ) diff --git a/grpc.gyp b/grpc.gyp index 324f65215f..43f7724ab4 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -182,7 +182,6 @@ 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -235,6 +234,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -531,6 +531,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -745,6 +746,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -940,6 +942,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', diff --git a/package.xml b/package.xml index 00b54d3dc1..98c2707e0f 100644 --- a/package.xml +++ b/package.xml @@ -95,7 +95,6 @@ - @@ -130,7 +129,6 @@ - @@ -273,6 +271,7 @@ + @@ -419,6 +418,7 @@ + diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 32cc5fff6b..51fe70304b 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -37,8 +37,8 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bdad3c6067..0a375074ef 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -17,6 +17,7 @@ */ #include "src/core/lib/channel/channel_tracer.h" + #include #include #include @@ -25,7 +26,7 @@ #include #include -#include "src/core/lib/gpr/object_registry.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc new file mode 100644 index 0000000000..550bb6f788 --- /dev/null +++ b/src/core/lib/channel/object_registry.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/channel/object_registry.h" + +#include +#include +#include + +// file global lock and avl. +static gpr_mu g_mu; +static gpr_avl g_avl; +static intptr_t g_uuid = 0; + +typedef struct { + void* object; + grpc_object_registry_type type; +} object_tracker; + +// avl vtable for uuid (intptr_t) -> object_tracker +// this table is only looking, it does not own anything. +static void destroy_intptr(void* not_used, void* user_data) {} +static void* copy_intptr(void* key, void* user_data) { return key; } +static long compare_intptr(void* key1, void* key2, void* user_data) { + return (intptr_t)key1 - (intptr_t)key2; +} + +static void destroy_tracker(void* tracker, void* user_data) { + gpr_free((object_tracker*)tracker); +} + +static void* copy_tracker(void* value, void* user_data) { + object_tracker* old = static_cast(value); + object_tracker* new_obj = + static_cast(gpr_malloc(sizeof(object_tracker))); + new_obj->object = old->object; + new_obj->type = old->type; + return new_obj; +} +static const gpr_avl_vtable avl_vtable = { + destroy_intptr, copy_intptr, compare_intptr, destroy_tracker, copy_tracker}; + +void grpc_object_registry_init() { + gpr_mu_init(&g_mu); + g_avl = gpr_avl_create(&avl_vtable); +} + +void grpc_object_registry_shutdown() { + gpr_avl_unref(g_avl, nullptr); + gpr_mu_destroy(&g_mu); +} + +intptr_t grpc_object_registry_register_object(void* object, + grpc_object_registry_type type) { + object_tracker* tracker = + static_cast(gpr_malloc(sizeof(object_tracker))); + tracker->object = object; + tracker->type = type; + intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); + gpr_mu_lock(&g_mu); + g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, nullptr); + gpr_mu_unlock(&g_mu); + return prior; +} + +void grpc_object_registry_unregister_object(intptr_t uuid) { + gpr_mu_lock(&g_mu); + g_avl = gpr_avl_remove(g_avl, (void*)uuid, nullptr); + gpr_mu_unlock(&g_mu); +} + +grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, + void** object) { + GPR_ASSERT(object); + gpr_mu_lock(&g_mu); + object_tracker* tracker = + static_cast(gpr_avl_get(g_avl, (void*)uuid, nullptr)); + gpr_mu_unlock(&g_mu); + if (tracker == nullptr) { + *object = nullptr; + return GRPC_OBJECT_REGISTRY_UNKNOWN; + } + *object = tracker->object; + return tracker->type; +} diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h new file mode 100644 index 0000000000..cc8fc6d878 --- /dev/null +++ b/src/core/lib/channel/object_registry.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H +#define GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H + +#include + +// Different types that may be stored in the general object registry +typedef enum { + // Used to hold uuid -> ChannelTracer mappings to allow for the trace data + // to be looked up by uuid, rather then have to walk the entire tree of + // trace. + GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, + // Usually represents an error has occurred in the object lookup. + GRPC_OBJECT_REGISTRY_UNKNOWN, +} grpc_object_registry_type; + +void grpc_object_registry_init(); +void grpc_object_registry_shutdown(); + +intptr_t grpc_object_registry_register_object(void* object, + grpc_object_registry_type type); +void grpc_object_registry_unregister_object(intptr_t uuid); +grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, + void** object); + +#endif /* GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H */ diff --git a/src/core/lib/gpr/object_registry.cc b/src/core/lib/gpr/object_registry.cc deleted file mode 100644 index 5c9e5416c2..0000000000 --- a/src/core/lib/gpr/object_registry.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/lib/gpr/object_registry.h" - -#include -#include -#include - -// file global lock and avl. -static gpr_mu g_mu; -static gpr_avl g_avl; -static intptr_t g_uuid = 0; - -typedef struct { - void* object; - grpc_object_registry_type type; -} object_tracker; - -// avl vtable for uuid (intptr_t) -> object_tracker -// this table is only looking, it does not own anything. -static void destroy_intptr(void* not_used, void* user_data) {} -static void* copy_intptr(void* key, void* user_data) { return key; } -static long compare_intptr(void* key1, void* key2, void* user_data) { - return (intptr_t)key1 - (intptr_t)key2; -} - -static void destroy_tracker(void* tracker, void* user_data) { - gpr_free((object_tracker*)tracker); -} - -static void* copy_tracker(void* value, void* user_data) { - object_tracker* old = static_cast(value); - object_tracker* new_obj = - static_cast(gpr_malloc(sizeof(object_tracker))); - new_obj->object = old->object; - new_obj->type = old->type; - return new_obj; -} -static const gpr_avl_vtable avl_vtable = { - destroy_intptr, copy_intptr, compare_intptr, destroy_tracker, copy_tracker}; - -void grpc_object_registry_init() { - gpr_mu_init(&g_mu); - g_avl = gpr_avl_create(&avl_vtable); -} - -void grpc_object_registry_shutdown() { - gpr_avl_unref(g_avl, nullptr); - gpr_mu_destroy(&g_mu); -} - -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type) { - object_tracker* tracker = - static_cast(gpr_malloc(sizeof(object_tracker))); - tracker->object = object; - tracker->type = type; - intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); - gpr_mu_lock(&g_mu); - g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, nullptr); - gpr_mu_unlock(&g_mu); - return prior; -} - -void grpc_object_registry_unregister_object(intptr_t uuid) { - gpr_mu_lock(&g_mu); - g_avl = gpr_avl_remove(g_avl, (void*)uuid, nullptr); - gpr_mu_unlock(&g_mu); -} - -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object) { - GPR_ASSERT(object); - gpr_mu_lock(&g_mu); - object_tracker* tracker = - static_cast(gpr_avl_get(g_avl, (void*)uuid, nullptr)); - gpr_mu_unlock(&g_mu); - if (tracker == nullptr) { - *object = nullptr; - return GRPC_OBJECT_REGISTRY_UNKNOWN; - } - *object = tracker->object; - return tracker->type; -} diff --git a/src/core/lib/gpr/object_registry.h b/src/core/lib/gpr/object_registry.h deleted file mode 100644 index cc8fc6d878..0000000000 --- a/src/core/lib/gpr/object_registry.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H -#define GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H - -#include - -// Different types that may be stored in the general object registry -typedef enum { - // Used to hold uuid -> ChannelTracer mappings to allow for the trace data - // to be looked up by uuid, rather then have to walk the entire tree of - // trace. - GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, - // Usually represents an error has occurred in the object lookup. - GRPC_OBJECT_REGISTRY_UNKNOWN, -} grpc_object_registry_type; - -void grpc_object_registry_init(); -void grpc_object_registry_shutdown(); - -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type); -void grpc_object_registry_unregister_object(intptr_t uuid); -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object); - -#endif /* GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index c60fe51f3f..fcc5fd4311 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -29,8 +29,8 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index be930d9737..119616c23c 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -29,10 +29,10 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/fork.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gpr/thd_internal.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/call_combiner.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 17dd792be8..2cd796b52f 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -36,7 +36,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -70,6 +69,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 1cf985d1ed..60122540d6 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -943,6 +943,7 @@ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/object_registry.cc \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/message_compress.h \ src/core/lib/compression/stream_compression.h \ @@ -956,7 +957,6 @@ src/core/lib/gpr/env.h \ src/core/lib/gpr/fork.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ -src/core/lib/gpr/object_registry.h \ src/core/lib/gpr/spinlock.h \ src/core/lib/gpr/string.h \ src/core/lib/gpr/string_windows.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 998a3749a2..49642dbb66 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1050,6 +1050,8 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/object_registry.cc \ +src/core/lib/channel/object_registry.cc \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ @@ -1093,8 +1095,6 @@ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/murmur_hash.h \ -src/core/lib/gpr/object_registry.cc \ -src/core/lib/gpr/object_registry.h \ src/core/lib/gpr/spinlock.h \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c4109162aa..5fd6e5f60f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7865,7 +7865,6 @@ "src/core/lib/gpr/log_windows.cc", "src/core/lib/gpr/mpscq.cc", "src/core/lib/gpr/murmur_hash.cc", - "src/core/lib/gpr/object_registry.cc", "src/core/lib/gpr/string.cc", "src/core/lib/gpr/string_posix.cc", "src/core/lib/gpr/string_util_windows.cc", @@ -7929,7 +7928,6 @@ "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/object_registry.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", "src/core/lib/gpr/string_windows.h", @@ -7979,7 +7977,6 @@ "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/object_registry.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", "src/core/lib/gpr/string_windows.h", @@ -8086,6 +8083,7 @@ "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/message_compress.cc", "src/core/lib/compression/stream_compression.cc", @@ -8244,6 +8242,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", @@ -8386,6 +8385,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", -- cgit v1.2.3 From 7042b519e8076c10b42ad216afe8f80ba7ffcccc Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 11:31:53 -0800 Subject: Switch to using RefCounted --- src/core/ext/filters/client_channel/subchannel.cc | 3 +- src/core/lib/channel/channel_tracer.cc | 45 ++++++++++------------- src/core/lib/channel/channel_tracer.h | 19 ++++++---- src/core/lib/surface/channel.cc | 8 ++-- 4 files changed, 37 insertions(+), 38 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 51fe70304b..478fd3fbb9 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -41,6 +41,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" @@ -134,7 +135,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_core::ManualConstructor tracer; + grpc_core::RefCountedPtr tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 1198395875..077ee61193 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,12 +40,12 @@ class TraceEvent { public: TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* referenced_tracer) + RefCountedPtr referenced_tracer) : data_(data), error_(error), connectivity_state_(connectivity_state), next_(nullptr) { - referenced_tracer_ = referenced_tracer ? referenced_tracer->Ref() : nullptr; + referenced_tracer_ = referenced_tracer; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } @@ -58,7 +58,7 @@ class TraceEvent { grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace node refers to. - ChannelTracer* referenced_tracer_; + RefCountedPtr referenced_tracer_; }; ChannelTracer::ChannelTracer(size_t max_nodes) @@ -71,46 +71,34 @@ ChannelTracer::ChannelTracer(size_t max_nodes) tail_trace_(nullptr) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); - gpr_ref_init(&refs_, 1); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); max_list_size_ = max_nodes; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -ChannelTracer* ChannelTracer::Ref() { - if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 - gpr_ref(&refs_); - return this; -} - void ChannelTracer::FreeNode(TraceEvent* node) { GRPC_ERROR_UNREF(node->error_); - if (node->referenced_tracer_) { - node->referenced_tracer_->Unref(); - } grpc_slice_unref_internal(node->data_); gpr_free(node); } -void ChannelTracer::Unref() { +ChannelTracer::~ChannelTracer() { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 - if (gpr_unref(&refs_)) { - TraceEvent* it = head_trace_; - while (it != nullptr) { - TraceEvent* to_free = it; - it = it->next_; - FreeNode(to_free); - } - gpr_mu_destroy(&tracer_mu_); + TraceEvent* it = head_trace_; + while (it != nullptr) { + TraceEvent* to_free = it; + it = it->next_; + FreeNode(to_free); } + gpr_mu_destroy(&tracer_mu_); } intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* referenced_tracer) { + RefCountedPtr referenced_tracer) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 ++num_nodes_logged_; if (referenced_tracer != nullptr) ++num_children_seen_; @@ -136,6 +124,11 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, } } +void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) { + AddTrace(data, error, connectivity_state, RefCountedPtr()); +} + // returns an allocated string that represents tm according to RFC-3339. static char* fmt_time(gpr_timespec tm) { char buffer[35]; @@ -297,12 +290,12 @@ class ChannelTracerRenderer { // If we are recursively populating everything, and this node // references a tracer we haven't seen yet, we render that tracer // in full, adding it to the parent JSON's "children" field. - if (children && !TracerAlreadySeen(node->referenced_tracer_)) { + if (children && !TracerAlreadySeen(node->referenced_tracer_.get())) { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - AddSeenTracer(node->referenced_tracer_); + AddSeenTracer(node->referenced_tracer_.get()); ChannelTracer* saved = current_tracer_; - current_tracer_ = node->referenced_tracer_; + current_tracer_ = node->referenced_tracer_.get(); RecursivelyPopulateJson(referenced_tracer); current_tracer_ = saved; } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 42f6e5ccb8..ab55dcf31d 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -20,6 +20,8 @@ #define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H #include +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" @@ -27,22 +29,24 @@ namespace grpc_core { class TraceEvent; -class ChannelTracer { +class ChannelTracer : public RefCounted { public: ChannelTracer(size_t max_nodes); - ~ChannelTracer() {} - - // TODO(ncteisen): incorporate RefCounted class - ChannelTracer* Ref(); - void Unref(); + ~ChannelTracer(); /* returns the tracers uuid */ intptr_t GetUuid(); /* Adds a new trace node to the tracing object */ + void AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); + + /* Adds a new trace node to the tracing object. This trace node refers to a + an event on a child of the channel. For example this could log when a + particular subchannel becomes connected */ void AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* subchannel); + RefCountedPtr referenced_tracer); /* Returns the tracing data rendered as a grpc json string. The string is owned by the caller and must be freed. If recursive @@ -59,7 +63,6 @@ class ChannelTracer { void FreeNode(TraceEvent* node); friend class ChannelTracerRenderer; - gpr_refcount refs_; gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_nodes_logged_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index fcc5fd4311..613a83cd01 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -34,6 +34,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -64,7 +65,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::ManualConstructor tracer; + grpc_core::RefCountedPtr tracer; char* target; }; @@ -202,13 +203,14 @@ grpc_channel* grpc_channel_create_with_builder( const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - channel->tracer.Init(max_nodes); + channel->tracer = + grpc_core::MakeRefCounted(max_nodes); } } grpc_channel_args_destroy(args); channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); return channel; } -- cgit v1.2.3 From 9f9724aac1602aaca2a5af8874a2021f356cc9c8 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 13:40:41 -0800 Subject: Fix initialization bug --- src/core/lib/surface/channel.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 613a83cd01..2c40880579 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -105,7 +105,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - bool tracer_initialized = false; + int64_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -197,18 +197,17 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(!tracer_initialized); - tracer_initialized = true; + GPR_ASSERT(channel_tracer_max_nodes == -1); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; - size_t max_nodes = + channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - channel->tracer = - grpc_core::MakeRefCounted(max_nodes); } } grpc_channel_args_destroy(args); + channel->tracer = grpc_core::MakeRefCounted( + channel_tracer_max_nodes); channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); return channel; -- cgit v1.2.3 From 804507d638f3bd0b2bcec1fcb2fd1cdbc361a90b Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 24 Jan 2018 16:59:32 -0800 Subject: Add get_uuid method to channel --- src/core/lib/surface/channel.cc | 4 ++++ src/core/lib/surface/channel.h | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 2c40880579..b78a218b1c 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -217,6 +217,10 @@ char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer->RenderTrace(recursive); } +intptr_t grpc_channel_get_uuid(grpc_channel* channel) { + return channel->tracer->GetUuid(); +} + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 5820bbbd80..12a806ecd7 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -58,8 +58,14 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); +// Returns the JSON formatted channel trace for this channel. If recursive +// is true, it will render all of the trace for this channel's subchannels. char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +// Returns the channel uuid, which can be used to look up its trace at a +// later time. +intptr_t grpc_channel_get_uuid(grpc_channel* channel); + #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); -- cgit v1.2.3 From 2bdc3ee70ca1eb1976d5a96c3e1130b3f6eec75f Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 29 Jan 2018 11:07:26 -0800 Subject: Fix asan --- src/core/lib/surface/channel.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 635daca8c8..63a7bd9d91 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -398,6 +398,7 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } + channel->tracer.reset(nullptr); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); -- cgit v1.2.3 From 42403d74ea338f5729d30d4e5aae1afcae14939f Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 29 Jan 2018 13:15:57 -0800 Subject: Fix objc build --- src/core/lib/surface/channel.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 63a7bd9d91..11002eea1e 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -105,7 +105,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - int64_t channel_tracer_max_nodes = 0; // default to off + size_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -170,7 +170,7 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel_tracer_max_nodes == -1); + GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; channel_tracer_max_nodes = -- cgit v1.2.3 From 95cf05794ad43b534df75dfa3a7e146761a0cf6e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:12:41 -0800 Subject: Reviewer feedback --- include/grpc/impl/codegen/grpc_types.h | 4 +-- src/core/lib/channel/channel_tracer.cc | 63 +++++++++------------------------- src/core/lib/channel/channel_tracer.h | 2 -- src/core/lib/surface/channel.cc | 2 +- 4 files changed, 20 insertions(+), 51 deletions(-) (limited to 'src/core/lib/surface') diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 7d410c88b3..22132cc1a4 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -281,9 +281,9 @@ typedef struct { #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" /** The grpc_socket_factory instance to create and bind sockets. A pointer. */ #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" -/** The maximum number of trace nodes to keep in the tracer for each channel or +/** The maximum number of trace events to keep in the tracer for each channel or * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ -#define GRPC_ARG_CHANNEL_TRACING_MAX_NODES "grpc.channel_tracing_max_nodes" +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index d4c3312781..bd1396f04e 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -45,7 +45,7 @@ class TraceEvent { error_(error), connectivity_state_(connectivity_state), next_(nullptr), - referenced_tracer_(referenced_tracer) { + referenced_tracer_(std::move(referenced_tracer)) { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } @@ -59,6 +59,12 @@ class TraceEvent { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } + ~TraceEvent() { + GRPC_ERROR_UNREF(error_); + referenced_tracer_.reset(); + grpc_slice_unref_internal(data_); + } + private: friend class ChannelTracer; friend class ChannelTracerRenderer; @@ -79,27 +85,20 @@ ChannelTracer::ChannelTracer(size_t max_nodes) max_list_size_(max_nodes), head_trace_(nullptr), tail_trace_(nullptr) { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -void ChannelTracer::FreeNode(TraceEvent* node) { - GRPC_ERROR_UNREF(node->error_); - node->referenced_tracer_.reset(nullptr); - grpc_slice_unref_internal(node->data_); - gpr_free(node); -} - ChannelTracer::~ChannelTracer() { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 TraceEvent* it = head_trace_; while (it != nullptr) { TraceEvent* to_free = it; it = it->next_; - FreeNode(to_free); + gpr_free(to_free); } gpr_mu_destroy(&tracer_mu_); } @@ -122,7 +121,7 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { if (list_size_ > max_list_size_) { TraceEvent* to_free = head_trace_; head_trace_ = head_trace_->next_; - FreeNode(to_free); + gpr_free(to_free); --list_size_; } } @@ -130,11 +129,11 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer) { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 ++num_children_seen_; // create and fill up the new node AddTraceEventNode( - New(data, error, connectivity_state, referenced_tracer)); + New(data, error, connectivity_state, std::move(referenced_tracer))); } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, @@ -142,8 +141,10 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, AddTraceEventNode(New(data, error, connectivity_state)); } +namespace { + // returns an allocated string that represents tm according to RFC-3339. -static char* fmt_time(gpr_timespec tm) { +char* fmt_time(gpr_timespec tm) { char buffer[35]; struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); @@ -152,36 +153,7 @@ static char* fmt_time(gpr_timespec tm) { return full_time_str; } -// Helper class that is responsible for walking the tree of ChannelTracer -// objects and rendering the trace as JSON according to: -// https://github.com/grpc/proposal/pull/7 - -// The rendered JSON should be of this format: -// { -// "channelData": { -// "uuid": string, -// "numNodesLogged": number, -// "startTime": timestamp string, -// "nodes": [ -// { -// "data": string, -// "error": string, -// "time": timestamp string, -// // can only be one of the states in connectivity_state.h -// "state": enum string, -// // uuid of referenced subchannel. -// // Optional, only present if this event refers to a child object. -// // and example of a referenced child would be a trace event for a -// // subchannel being created. -// "child_uuid": string -// }, -// ] -// }, -// // Optional, only present if this channel has children -// "childData": [ -// // List of child data, which is of the exact same format as the -// ] -// } +} // anonymous namespace class ChannelTracerRenderer { public: @@ -242,7 +214,6 @@ class ChannelTracerRenderer { // recursively populate each referenced child as it passes that node. void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { grpc_json* child = nullptr; - char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 3f8849ff46..58e99d340f 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -59,8 +59,6 @@ class ChannelTracer : public RefCounted { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: - // Internal helper that frees a TraceEvent. - void FreeNode(TraceEvent* node); // Internal helper to add and link in a tracenode void AddTraceEventNode(TraceEvent* new_trace_node); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 8851aac739..76ab958256 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -171,7 +171,7 @@ grpc_channel* grpc_channel_create_with_builder( static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ } else if (0 == - strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { + strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; -- cgit v1.2.3 From 6ea7f3330e238f69925062b281185fbfaefd4ee2 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:19:25 -0800 Subject: Reviewer comments --- include/grpc/impl/codegen/grpc_types.h | 3 +- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 96 ++++++++++++----------- src/core/lib/channel/channel_tracer.h | 31 ++++---- src/core/lib/json/json.h | 1 - src/core/lib/surface/channel.cc | 13 +-- 6 files changed, 74 insertions(+), 72 deletions(-) (limited to 'src/core/lib/surface') diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 22132cc1a4..b671ad653e 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -283,7 +283,8 @@ typedef struct { #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" /** The maximum number of trace events to keep in the tracer for each channel or * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ -#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE "grpc.max_channel_trace_events_per_node" +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE \ + "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 68cd9260ba..77c0fe2c43 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -136,7 +136,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_core::RefCountedPtr tracer; + grpc_core::RefCountedPtr tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bd1396f04e..982b86447d 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,7 +40,7 @@ class TraceEvent { public: TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) + RefCountedPtr referenced_tracer) : data_(data), error_(error), connectivity_state_(connectivity_state), @@ -66,34 +66,34 @@ class TraceEvent { } private: - friend class ChannelTracer; - friend class ChannelTracerRenderer; + friend class ChannelTrace; + friend class ChannelTraceRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; grpc_connectivity_state connectivity_state_; TraceEvent* next_; - // the tracer object for the (sub)channel that this trace node refers to. - RefCountedPtr referenced_tracer_; + // the tracer object for the (sub)channel that this trace event refers to. + RefCountedPtr referenced_tracer_; }; -ChannelTracer::ChannelTracer(size_t max_nodes) +ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), - num_nodes_logged_(0), + num_events_logged_(0), num_children_seen_(0), list_size_(0), - max_list_size_(max_nodes), + max_list_size_(max_events), head_trace_(nullptr), tail_trace_(nullptr) { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -ChannelTracer::~ChannelTracer() { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 +ChannelTrace::~ChannelTrace() { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 TraceEvent* it = head_trace_; while (it != nullptr) { TraceEvent* to_free = it; @@ -103,17 +103,17 @@ ChannelTracer::~ChannelTracer() { gpr_mu_destroy(&tracer_mu_); } -intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } +intptr_t ChannelTrace::GetUuid() { return channel_uuid_; } -void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { - ++num_nodes_logged_; - // first node case +void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { + ++num_events_logged_; + // first event case if (head_trace_ == nullptr) { - head_trace_ = tail_trace_ = new_trace_node; + head_trace_ = tail_trace_ = new_trace_event; } - // regular node add case + // regular event add case else { - tail_trace_->next_ = new_trace_node; + tail_trace_->next_ = new_trace_event; tail_trace_ = tail_trace_->next_; } ++list_size_; @@ -126,19 +126,20 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { } } -void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 +void ChannelTrace::AddTraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 ++num_children_seen_; - // create and fill up the new node - AddTraceEventNode( - New(data, error, connectivity_state, std::move(referenced_tracer))); + // create and fill up the new event + AddTraceEventHelper(New(data, error, connectivity_state, + std::move(referenced_tracer))); } -void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) { - AddTraceEventNode(New(data, error, connectivity_state)); +void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) { + AddTraceEventHelper(New(data, error, connectivity_state)); } namespace { @@ -153,13 +154,13 @@ char* fmt_time(gpr_timespec tm) { return full_time_str; } -} // anonymous namespace +} // anonymous namespace -class ChannelTracerRenderer { +class ChannelTraceRenderer { public: // If recursive==true, then the entire tree of trace will be rendered. // If not, then only the top level data will be. - ChannelTracerRenderer(ChannelTracer* tracer, bool recursive) + ChannelTraceRenderer(ChannelTrace* tracer, bool recursive) : current_tracer_(tracer), recursive_(recursive), seen_tracers_(nullptr), @@ -180,16 +181,16 @@ class ChannelTracerRenderer { private: // tracks that a tracer has already been rendered to avoid infinite // recursion. - void AddSeenTracer(ChannelTracer* newly_seen) { + void AddSeenTracer(ChannelTrace* newly_seen) { if (size_ >= cap_) { cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); - seen_tracers_ = (ChannelTracer**)gpr_realloc(seen_tracers_, cap_); + seen_tracers_ = (ChannelTrace**)gpr_realloc(seen_tracers_, cap_); } seen_tracers_[size_++] = newly_seen; } // Checks if a tracer has already been seen. - bool TracerAlreadySeen(ChannelTracer* tracer) { + bool TracerAlreadySeen(ChannelTrace* tracer) { for (size_t i = 0; i < size_; ++i) { if (seen_tracers_[i] == tracer) return true; } @@ -211,19 +212,19 @@ class ChannelTracerRenderer { } // Fills up the channelData object. If children is not null, it will - // recursively populate each referenced child as it passes that node. + // recursively populate each referenced child as it passes that event. void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { grpc_json* child = nullptr; char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, GRPC_JSON_NUMBER, true); - char* num_nodes_logged_str; - gpr_asprintf(&num_nodes_logged_str, "%" PRId64, - current_tracer_->num_nodes_logged_); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, + current_tracer_->num_events_logged_); child = grpc_json_create_child(child, channel_data, "numNodesLogged", - num_nodes_logged_str, GRPC_JSON_NUMBER, true); + num_events_logged_str, GRPC_JSON_NUMBER, true); child = grpc_json_create_child(child, channel_data, "startTime", fmt_time(current_tracer_->time_created_), GRPC_JSON_STRING, true); @@ -278,7 +279,7 @@ class ChannelTracerRenderer { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); AddSeenTracer(node->referenced_tracer_.get()); - ChannelTracer* saved = current_tracer_; + ChannelTrace* saved = current_tracer_; current_tracer_ = node->referenced_tracer_.get(); RecursivelyPopulateJson(referenced_tracer); current_tracer_ = saved; @@ -287,30 +288,31 @@ class ChannelTracerRenderer { } // Tracks the current tracer we are rendering as we walk the tree of tracers. - ChannelTracer* current_tracer_; + ChannelTrace* current_tracer_; // If true, we will render the data of all of this tracer's children. bool recursive_; // These members are used to track tracers we have already rendered. This is // a dynamically growing array that is deallocated when the rendering is done. - ChannelTracer** seen_tracers_; + ChannelTrace** seen_tracers_; size_t size_; size_t cap_; }; -char* ChannelTracer::RenderTrace(bool recursive) { - if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 - ChannelTracerRenderer renderer(this, recursive); +char* ChannelTrace::RenderTrace(bool recursive) { + if (!max_list_size_) + return nullptr; // tracing is disabled if max_events == 0 + ChannelTraceRenderer renderer(this, recursive); return renderer.Run(); } -char* ChannelTracer::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { +char* ChannelTrace::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - return static_cast(object)->RenderTrace(recursive); + return static_cast(object)->RenderTrace(recursive); } } // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 58e99d340f..72bdee48f8 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -29,24 +29,24 @@ namespace grpc_core { class TraceEvent; -class ChannelTracer : public RefCounted { +class ChannelTrace : public RefCounted { public: - ChannelTracer(size_t max_nodes); - ~ChannelTracer(); + ChannelTrace(size_t max_events); + ~ChannelTrace(); - /* returns the tracers uuid */ + /* returns the tracer's uuid */ intptr_t GetUuid(); - /* Adds a new trace node to the tracing object */ - void AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + /* Adds a new trace event to the tracing object */ + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); - /* Adds a new trace node to the tracing object. This trace node refers to a + /* Adds a new trace event to the tracing object. This trace event refers to a an event on a child of the channel. For example this could log when a particular subchannel becomes connected */ - void AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); /* Returns the tracing data rendered as a grpc json string. The string is owned by the caller and must be freed. If recursive @@ -59,14 +59,13 @@ class ChannelTracer : public RefCounted { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: + // Internal helper to add and link in a trace event + void AddTraceEventHelper(TraceEvent* new_trace_event); - // Internal helper to add and link in a tracenode - void AddTraceEventNode(TraceEvent* new_trace_node); - - friend class ChannelTracerRenderer; + friend class ChannelTraceRenderer; gpr_mu tracer_mu_; intptr_t channel_uuid_; - uint64_t num_nodes_logged_; + uint64_t num_events_logged_; uint64_t num_children_seen_; size_t list_size_; size_t max_list_size_; diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index c8a87a7b87..f93b43048b 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -19,7 +19,6 @@ #ifndef GRPC_CORE_LIB_JSON_JSON_H #define GRPC_CORE_LIB_JSON_JSON_H - #include #include diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 76ab958256..837e78e85f 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -67,7 +67,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::RefCountedPtr tracer; + grpc_core::RefCountedPtr tracer; char* target; }; @@ -170,8 +170,8 @@ grpc_channel* grpc_channel_create_with_builder( channel->compression_options.enabled_algorithms_bitset = static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ - } else if (0 == - strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { + } else if (0 == strcmp(args->args[i].key, + GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; @@ -181,10 +181,11 @@ grpc_channel* grpc_channel_create_with_builder( } grpc_channel_args_destroy(args); - channel->tracer = grpc_core::MakeRefCounted( + channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); - channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); + channel->tracer->AddTraceEvent( + grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE); return channel; } -- cgit v1.2.3 From bf5237a723501c3a0c6324f7d8662b2759bfb816 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:45:26 -0800 Subject: reviewer comments --- include/grpc/grpc.h | 8 ++++ src/core/lib/channel/object_registry.cc | 5 ++- src/core/lib/channel/object_registry.h | 9 ++++- src/core/lib/surface/channel.cc | 6 +-- src/core/lib/surface/channel.h | 8 ---- test/core/channel/channel_tracer_test.cc | 68 ++++++++++++++++---------------- test/core/util/channel_tracing_utils.cc | 5 ++- test/core/util/channel_tracing_utils.h | 5 ++- 8 files changed, 62 insertions(+), 52 deletions(-) (limited to 'src/core/lib/surface') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index c129a66949..2ad247abb1 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,6 +286,14 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); +// Returns the JSON formatted channel trace for this channel. If recursive +// is true, it will render all of the trace for this channel's subchannels. +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); + +// Returns the channel uuid, which can be used to look up its trace at a +// later time. +GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); + /** Error handling for grpc_call Most grpc_call functions return a grpc_error. If the error is not GRPC_OK then the operation failed due to some unsatisfied precondition. diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc index ef2aa1d591..108552a3c6 100644 --- a/src/core/lib/channel/object_registry.cc +++ b/src/core/lib/channel/object_registry.cc @@ -18,6 +18,7 @@ #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/avl/avl.h" +#include "src/core/lib/gpr/useful.h" #include #include @@ -25,7 +26,7 @@ // file global lock and avl. static gpr_mu g_mu; static grpc_avl g_avl; -static intptr_t g_uuid = 0; +static gpr_atm g_uuid = 0; typedef struct { void* object; @@ -37,7 +38,7 @@ typedef struct { static void destroy_intptr(void* not_used, void* user_data) {} static void* copy_intptr(void* key, void* user_data) { return key; } static long compare_intptr(void* key1, void* key2, void* user_data) { - return (intptr_t)key1 - (intptr_t)key2; + return GPR_ICMP(key1, key2); } static void destroy_tracker(void* tracker, void* user_data) { diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h index 744bbd8e99..2747522cc1 100644 --- a/src/core/lib/channel/object_registry.h +++ b/src/core/lib/channel/object_registry.h @@ -21,7 +21,10 @@ #include -// Different types that may be stored in the general object registry +// TODO(ncteisen): convert this file to C++ + +// Different types that may be stored in the general object registry. For now, +// the only use case is channel tracers, but the design has been left general. typedef enum { // Used to hold uuid -> ChannelTracer mappings to allow for the trace data // to be looked up by uuid, rather then have to walk the entire tree of @@ -34,9 +37,13 @@ typedef enum { void grpc_object_registry_init(); void grpc_object_registry_shutdown(); +// globally registers the object. Returns its unique uuid intptr_t grpc_object_registry_register_object(void* object, grpc_object_registry_type type); +// globally unregisters the object that is associated to uuid. void grpc_object_registry_unregister_object(intptr_t uuid); +// if object with uuid has previously been registered, stores it in *object. +// if not, returns GRPC_OBJECT_REGISTRY_UNKNOWN and sets *object unchanged. grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, void** object); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 837e78e85f..18ff89d5bb 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -173,8 +173,8 @@ grpc_channel* grpc_channel_create_with_builder( } else if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); - // max_nodes defaults to 10, clamped between 0 and 100. - const grpc_integer_options options = {10, 0, 100}; + // max_nodes defaults to 0 (which is off), clamped between 0 and 100. + const grpc_integer_options options = {0, 0, 100}; channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } @@ -405,7 +405,7 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } - channel->tracer.reset(nullptr); + channel->tracer.reset(); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index c980151537..288313951e 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -60,14 +60,6 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); -// Returns the JSON formatted channel trace for this channel. If recursive -// is true, it will render all of the trace for this channel's subchannels. -char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); - -// Returns the channel uuid, which can be used to look up its trace at a -// later time. -intptr_t grpc_channel_get_uuid(grpc_channel* channel); - #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 52e57bafbb..1f2ed33e33 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -34,7 +34,7 @@ using grpc_core::ChannelTrace; using grpc_core::MakeRefCounted; using grpc_core::RefCountedPtr; -static void add_simple_trace(RefCountedPtr tracer) { +static void add_simple_trace_event(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY); @@ -47,8 +47,8 @@ static void validate_tracer(RefCountedPtr tracer, if (!max_nodes) return; char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); - validate_channel_data(json, expected_num_nodes_logged, - GPR_MIN(expected_num_nodes_logged, max_nodes)); + validate_channel_trace_data(json, expected_num_nodes_logged, + GPR_MIN(expected_num_nodes_logged, max_nodes)); grpc_json_destroy(json); gpr_free(json_str); } @@ -84,8 +84,8 @@ static void validate_children(RefCountedPtr tracer, static void test_basic_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer_data_matches_uuid_lookup(tracer); tracer->AddTraceEvent( grpc_slice_from_static_string("trace three"), @@ -95,13 +95,13 @@ static void test_basic_channel_tracing(size_t max_nodes) { tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); validate_tracer(tracer, 4, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 10, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); @@ -124,22 +124,22 @@ static void test_basic_channel_sizing() { static void test_complex_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc1 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); validate_tracer(sc1, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); validate_tracer(sc1, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 5, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); RefCountedPtr sc2 = MakeRefCounted(max_nodes); @@ -149,12 +149,12 @@ static void test_complex_channel_tracing(size_t max_nodes) { grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 7, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); sc1.reset(nullptr); @@ -177,22 +177,22 @@ static void test_complex_channel_sizing() { static void test_nesting() { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(10); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc1 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); // channel has only one subchannel right here. validate_children(tracer, 1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); validate_children(sc1, 1); - add_simple_trace(conn1); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(conn1); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc2 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); @@ -203,7 +203,7 @@ static void test_nesting() { grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_children(tracer, 2); - add_simple_trace(tracer); + add_simple_trace_event(tracer); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 7e96d2d57d..8262776f29 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -45,8 +45,9 @@ void validate_json_array_size(grpc_json* json, const char* key, GPR_ASSERT(count == expected_size); } -void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected) { +void validate_channel_trace_data(grpc_json* json, + size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected) { GPR_ASSERT(json); grpc_json* channel_data = get_json_child(json, "channelData"); grpc_json* num_nodes_logged_json = diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h index 6a3eac98a9..7eac114cc5 100644 --- a/test/core/util/channel_tracing_utils.h +++ b/test/core/util/channel_tracing_utils.h @@ -24,7 +24,8 @@ void validate_json_array_size(grpc_json* json, const char* key, size_t expected_size); -void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected); +void validate_channel_trace_data(grpc_json* json, + size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected); #endif /* GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H */ -- cgit v1.2.3 From ee013d25b3237b62185d1248e4ccc873a0d6be3e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 23:15:47 -0800 Subject: Fix build and sanity --- grpc.def | 2 ++ include/grpc/grpc.h | 10 +++++----- src/core/lib/channel/channel_tracer.cc | 2 ++ src/core/lib/channel/channel_tracer.h | 2 ++ src/core/lib/channel/object_registry.cc | 4 +++- src/core/lib/channel/object_registry.h | 2 ++ src/core/lib/surface/channel.cc | 2 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 ++++ src/ruby/ext/grpc/rb_grpc_imports.generated.h | 6 ++++++ test/core/surface/public_headers_must_be_c89.c | 2 ++ 10 files changed, 29 insertions(+), 7 deletions(-) (limited to 'src/core/lib/surface') diff --git a/grpc.def b/grpc.def index 2bafebbbd4..5ff3a1efe8 100644 --- a/grpc.def +++ b/grpc.def @@ -45,6 +45,8 @@ EXPORTS grpc_insecure_channel_create grpc_lame_client_channel_create grpc_channel_destroy + grpc_channel_get_trace + grpc_channel_get_uuid grpc_call_cancel grpc_call_cancel_with_status grpc_call_ref diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 2ad247abb1..e3b60a93a2 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,12 +286,12 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -// Returns the JSON formatted channel trace for this channel. If recursive -// is true, it will render all of the trace for this channel's subchannels. -GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +/** Returns the JSON formatted channel trace for this channel. If recursive + is non 0, it will render all of the trace for this channel's subchannels. */ +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, int recursive); -// Returns the channel uuid, which can be used to look up its trace at a -// later time. +/** Returns the channel uuid, which can be used to look up its trace at a + later time. */ GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); /** Error handling for grpc_call diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index b1c76408a0..6e3cd35db9 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -16,6 +16,8 @@ * */ +#include + #include "src/core/lib/channel/channel_tracer.h" #include diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index e3ab32cfcd..e2a0442a26 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -19,6 +19,8 @@ #ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H #define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H +#include + #include #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc index 108552a3c6..987c5366ca 100644 --- a/src/core/lib/channel/object_registry.cc +++ b/src/core/lib/channel/object_registry.cc @@ -16,8 +16,10 @@ * */ -#include "src/core/lib/channel/object_registry.h" +#include + #include "src/core/lib/avl/avl.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" #include diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h index 2747522cc1..446d0cb41f 100644 --- a/src/core/lib/channel/object_registry.h +++ b/src/core/lib/channel/object_registry.h @@ -19,6 +19,8 @@ #ifndef GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H #define GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H +#include + #include // TODO(ncteisen): convert this file to C++ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 18ff89d5bb..4813855de8 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -189,7 +189,7 @@ grpc_channel* grpc_channel_create_with_builder( return channel; } -char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { +char* grpc_channel_get_trace(grpc_channel* channel, int recursive) { return channel->tracer->RenderTrace(recursive); } diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index c045480ff4..1c042739a8 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -68,6 +68,8 @@ grpc_channel_get_info_type grpc_channel_get_info_import; grpc_insecure_channel_create_type grpc_insecure_channel_create_import; grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; grpc_channel_destroy_type grpc_channel_destroy_import; +grpc_channel_get_trace_type grpc_channel_get_trace_import; +grpc_channel_get_uuid_type grpc_channel_get_uuid_import; grpc_call_cancel_type grpc_call_cancel_import; grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; grpc_call_ref_type grpc_call_ref_import; @@ -304,6 +306,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); + grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace"); + grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid"); grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 4f07452c68..2c640adb87 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -179,6 +179,12 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo typedef void(*grpc_channel_destroy_type)(grpc_channel* channel); extern grpc_channel_destroy_type grpc_channel_destroy_import; #define grpc_channel_destroy grpc_channel_destroy_import +typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel, bool recursive); +extern grpc_channel_get_trace_type grpc_channel_get_trace_import; +#define grpc_channel_get_trace grpc_channel_get_trace_import +typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel); +extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import; +#define grpc_channel_get_uuid grpc_channel_get_uuid_import typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved); extern grpc_call_cancel_type grpc_call_cancel_import; #define grpc_call_cancel grpc_call_cancel_import diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index bd4dc0b60e..d858603e47 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -106,6 +106,8 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_insecure_channel_create); printf("%lx", (unsigned long) grpc_lame_client_channel_create); printf("%lx", (unsigned long) grpc_channel_destroy); + printf("%lx", (unsigned long) grpc_channel_get_trace); + printf("%lx", (unsigned long) grpc_channel_get_uuid); printf("%lx", (unsigned long) grpc_call_cancel); printf("%lx", (unsigned long) grpc_call_cancel_with_status); printf("%lx", (unsigned long) grpc_call_ref); -- cgit v1.2.3 From cd6755b13c7227dbfea2f8f8385b41eca15da8ca Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 15:16:50 -0800 Subject: Re write rendered --- include/grpc/grpc.h | 5 +- src/core/lib/channel/channel_tracer.cc | 191 ++++++++------------------------- src/core/lib/channel/channel_tracer.h | 39 ++++--- src/core/lib/surface/channel.cc | 4 +- 4 files changed, 76 insertions(+), 163 deletions(-) (limited to 'src/core/lib/surface') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index e3b60a93a2..5c6cabb380 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,9 +286,8 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -/** Returns the JSON formatted channel trace for this channel. If recursive - is non 0, it will render all of the trace for this channel's subchannels. */ -GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, int recursive); +/** Returns the JSON formatted channel trace for this channel. */ +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel); /** Returns the channel uuid, which can be used to look up its trace at a later time. */ diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 092a22fcf0..86b7a6cce9 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -123,156 +123,59 @@ char* fmt_time(gpr_timespec tm) { } // anonymous namespace -class ChannelTraceRenderer { - public: - // If recursive==true, then the entire tree of trace will be rendered. - // If not, then only the top level data will be. - ChannelTraceRenderer(ChannelTrace* tracer, bool recursive) - : current_tracer_(tracer), - recursive_(recursive), - seen_tracers_(nullptr), - size_(0), - cap_(0) {} - - // Renders the trace and returns an allocated char* with the formatted JSON - char* Run() { - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - AddSeenTracer(current_tracer_); - RecursivelyPopulateJson(json); - gpr_free(seen_tracers_); - char* json_str = grpc_json_dump_to_string(json, 0); - grpc_json_destroy(json); - return json_str; - } - - private: - // tracks that a tracer has already been rendered to avoid infinite - // recursion. - void AddSeenTracer(ChannelTrace* newly_seen) { - if (size_ >= cap_) { - cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); - seen_tracers_ = (ChannelTrace**)gpr_realloc(seen_tracers_, cap_); - } - seen_tracers_[size_++] = newly_seen; +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { + grpc_json* json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "description", + grpc_slice_to_c_string(data_), + GRPC_JSON_STRING, true); + // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure + // it is done in the layers above core. + if (error_ != GRPC_ERROR_NONE) { + json_iterator = grpc_json_create_child( + json_iterator, json, "status", gpr_strdup(grpc_error_string(error_)), + GRPC_JSON_STRING, true); } - - // Checks if a tracer has already been seen. - bool TracerAlreadySeen(ChannelTrace* tracer) { - for (size_t i = 0; i < size_; ++i) { - if (seen_tracers_[i] == tracer) return true; - } - return false; - } - - // Recursively fills up json by walking over all of the trace of - // current_tracer_. Starts at the top level, by creating the fields - // channelData, and childData. - void RecursivelyPopulateJson(grpc_json* json) { - grpc_json* channel_data = grpc_json_create_child( - nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); - grpc_json* children = nullptr; - if (recursive_) { - children = grpc_json_create_child(channel_data, json, "childData", - nullptr, GRPC_JSON_ARRAY, false); - } - PopulateChannelData(channel_data, children); - } - - // Fills up the channelData object. If children is not null, it will - // recursively populate each referenced child as it passes that event. - void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { - grpc_json* child = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "timestamp", + fmt_time(time_created_), GRPC_JSON_STRING, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "state", + grpc_connectivity_state_name(connectivity_state_), + GRPC_JSON_STRING, false); + if (referenced_tracer_ != nullptr) { char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); - child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - char* num_events_logged_str; - gpr_asprintf(&num_events_logged_str, "%" PRId64, - current_tracer_->num_events_logged_); - child = - grpc_json_create_child(child, channel_data, "numNodesLogged", - num_events_logged_str, GRPC_JSON_NUMBER, true); - child = grpc_json_create_child(child, channel_data, "startTime", - fmt_time(current_tracer_->time_created_), - GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", nullptr, - GRPC_JSON_ARRAY, false); - PopulateNodeList(child, children); + gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); + json_iterator = grpc_json_create_child(json_iterator, json, "child_ref", + uuid_str, GRPC_JSON_NUMBER, true); } +} - // Iterated over the list of TraceEvents and populates their data. - void PopulateNodeList(grpc_json* nodes, grpc_json* children) { - grpc_json* child = nullptr; - ChannelTrace::TraceEvent* it = current_tracer_->head_trace_; - while (it != nullptr) { - child = grpc_json_create_child(child, nodes, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - PopulateNode(it, child, children); - it = it->next_; - } - } - - // Fills in all the data for a single TraceEvent. If children is not null - // and the TraceEvent refers to a child Tracer object and recursive_ is true, - // then that child object will be rendered into the trace. - void PopulateNode(ChannelTrace::TraceEvent* node, grpc_json* json, - grpc_json* children) { - grpc_json* child = nullptr; - child = grpc_json_create_child(child, json, "data", - grpc_slice_to_c_string(node->data_), - GRPC_JSON_STRING, true); - if (node->error_ != GRPC_ERROR_NONE) { - child = grpc_json_create_child( - child, json, "error", gpr_strdup(grpc_error_string(node->error_)), - GRPC_JSON_STRING, true); - } - child = grpc_json_create_child(child, json, "time", - fmt_time(node->time_created_), - GRPC_JSON_STRING, true); - child = grpc_json_create_child( - child, json, "state", - grpc_connectivity_state_name(node->connectivity_state_), - GRPC_JSON_STRING, false); - if (node->referenced_tracer_ != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, - node->referenced_tracer_->channel_uuid_); - child = grpc_json_create_child(child, json, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - - // If we are recursively populating everything, and this node - // references a tracer we haven't seen yet, we render that tracer - // in full, adding it to the parent JSON's "children" field. - if (children && !TracerAlreadySeen(node->referenced_tracer_.get())) { - grpc_json* referenced_tracer = grpc_json_create_child( - nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - AddSeenTracer(node->referenced_tracer_.get()); - ChannelTrace* saved = current_tracer_; - current_tracer_ = node->referenced_tracer_.get(); - RecursivelyPopulateJson(referenced_tracer); - current_tracer_ = saved; - } - } - } - - // Tracks the current tracer we are rendering as we walk the tree of tracers. - ChannelTrace* current_tracer_; - - // If true, we will render the data of all of this tracer's children. - bool recursive_; - - // These members are used to track tracers we have already rendered. This is - // a dynamically growing array that is deallocated when the rendering is done. - ChannelTrace** seen_tracers_; - size_t size_; - size_t cap_; -}; - -char* ChannelTrace::RenderTrace(bool recursive) { +char* ChannelTrace::RenderTrace() { if (!max_list_size_) return nullptr; // tracing is disabled if max_events == 0 - ChannelTraceRenderer renderer(this, recursive); - return renderer.Run(); + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); + grpc_json* json_iterator = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "num_events_logged", + num_events_logged_str, GRPC_JSON_NUMBER, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "creation_time", + fmt_time(time_created_), GRPC_JSON_STRING, true); + grpc_json* events = grpc_json_create_child(json_iterator, json, "events", + nullptr, GRPC_JSON_ARRAY, false); + json_iterator = nullptr; + TraceEvent* it = head_trace_; + while (it != nullptr) { + json_iterator = grpc_json_create_child(json_iterator, events, nullptr, + nullptr, GRPC_JSON_OBJECT, false); + it->RenderTraceEvent(json_iterator); + it = it->next(); + } + char* json_str = grpc_json_dump_to_string(json, 0); + grpc_json_destroy(json); + return json_str; } } // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 4547a0fb0b..976e66c49e 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -29,38 +29,44 @@ namespace grpc_core { +// Object used to hold live data for a channel. This data is exposed via the +// channelz service: +// https://github.com/grpc/proposal/blob/master/A14-channelz.md class ChannelTrace : public RefCounted { public: ChannelTrace(size_t max_events); ~ChannelTrace(); - /* returns the tracer's uuid */ + // returns the tracer's uuid intptr_t GetUuid(); - /* Adds a new trace event to the tracing object */ + // Adds a new trace event to the tracing object void AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state); - /* Adds a new trace event to the tracing object. This trace event refers to a - an event on a child of the channel. For example this could log when a - particular subchannel becomes connected. - TODO(ncteisen): Once channelz is implemented, the events should reference - the channelz object, not the channel trace. */ + // Adds a new trace event to the tracing object. This trace event refers to a + // an event on a child of the channel. For example, if this channel has + // created a new subchannel, then it would record that with a TraceEvent + // referencing the new subchannel. + + // TODO(ncteisen): Once channelz is implemented, the events should reference + // the overall channelz object, not just the ChannelTrace object. void AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer); - /* Returns the tracing data rendered as a grpc json string. - The string is owned by the caller and must be freed. If recursive - is true, then the string will include the recursive trace for all - subtracing objects. */ - char* RenderTrace(bool recursive); + // Returns the tracing data rendered as a grpc json string. + // The string is owned by the caller and must be freed. + char* RenderTrace(); private: // Private class to encapsulate all the data and bookkeeping needed for a // a trace event. class TraceEvent { public: + // Constructor for a TraceEvent that references a different channel. + // TODO(ncteisen): once channelz is implemented, this should reference the + // overall channelz object, not just the ChannelTrace object TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer) @@ -72,6 +78,8 @@ class ChannelTrace : public RefCounted { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } + // Constructor for a TraceEvent that does not reverence a different + // channel. TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state) : data_(data), @@ -84,11 +92,15 @@ class ChannelTrace : public RefCounted { ~TraceEvent(); + // Renders the data inside of this TraceEvent into a json object. This is + // used by the ChannelTrace, when it is rendering itself. + void RenderTraceEvent(grpc_json* json); + + // set and get for the next_ pointer. TraceEvent* next() { return next_; } void set_next(TraceEvent* next) { next_ = next; } private: - friend class ChannelTraceRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; @@ -101,7 +113,6 @@ class ChannelTrace : public RefCounted { // Internal helper to add and link in a trace event void AddTraceEventHelper(TraceEvent* new_trace_event); - friend class ChannelTraceRenderer; gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_events_logged_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 4813855de8..1488736c49 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -189,8 +189,8 @@ grpc_channel* grpc_channel_create_with_builder( return channel; } -char* grpc_channel_get_trace(grpc_channel* channel, int recursive) { - return channel->tracer->RenderTrace(recursive); +char* grpc_channel_get_trace(grpc_channel* channel) { + return channel->tracer->RenderTrace(); } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { -- cgit v1.2.3 From 7d90d5497c2115599665728056c818efc575b4c4 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 5 Mar 2018 22:53:44 -0800 Subject: Reviewer feedback --- CMakeLists.txt | 66 +++++++++-------- Makefile | 84 ++++++++++++---------- build.yaml | 26 ++++--- src/core/lib/channel/channel_tracer.cc | 29 ++++++-- src/core/lib/channel/channel_tracer.h | 28 ++------ src/core/lib/surface/channel.cc | 5 +- test/core/channel/channel_tracer_test.cc | 25 +++---- tools/run_tests/generated/sources_and_headers.json | 36 +++++----- tools/run_tests/generated/tests.json | 48 ++++++------- 9 files changed, 192 insertions(+), 155 deletions(-) (limited to 'src/core/lib/surface') diff --git a/CMakeLists.txt b/CMakeLists.txt index c80744d827..93d3b12962 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,7 +283,6 @@ add_dependencies(buildtests_c grpc_byte_buffer_reader_test) add_dependencies(buildtests_c grpc_channel_args_test) add_dependencies(buildtests_c grpc_channel_stack_builder_test) add_dependencies(buildtests_c grpc_channel_stack_test) -add_dependencies(buildtests_c grpc_channel_tracer_test) add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_credentials_test) @@ -518,6 +517,7 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) +add_dependencies(buildtests_cxx channel_tracer_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) add_dependencies(buildtests_cxx client_channel_stress_test) @@ -6559,33 +6559,6 @@ target_link_libraries(grpc_channel_stack_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(grpc_channel_tracer_test - test/core/channel/channel_tracer_test.cc -) - - -target_include_directories(grpc_channel_tracer_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} -) - -target_link_libraries(grpc_channel_tracer_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(grpc_completion_queue_test test/core/surface/completion_queue_test.cc ) @@ -9512,6 +9485,43 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(channel_tracer_test + test/core/channel/channel_tracer_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(channel_tracer_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(channel_tracer_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(chttp2_settings_timeout_test test/core/transport/chttp2/settings_timeout_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index 02a72910ff..d5777d0e10 100644 --- a/Makefile +++ b/Makefile @@ -1006,7 +1006,6 @@ grpc_byte_buffer_reader_test: $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test grpc_channel_args_test: $(BINDIR)/$(CONFIG)/grpc_channel_args_test grpc_channel_stack_builder_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test grpc_channel_stack_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_test -grpc_channel_tracer_test: $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test grpc_completion_queue_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_test grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt @@ -1115,6 +1114,7 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test +channel_tracer_test: $(BINDIR)/$(CONFIG)/channel_tracer_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test @@ -1425,7 +1425,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_channel_args_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_test \ - $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ @@ -1584,6 +1583,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_tracer_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1732,6 +1732,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_tracer_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1918,8 +1919,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test || ( echo test grpc_channel_stack_builder_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_channel_stack_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_test || ( echo test grpc_channel_stack_test failed ; exit 1 ) - $(E) "[RUN] Testing grpc_channel_tracer_test" - $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test || ( echo test grpc_channel_tracer_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_test || ( echo test grpc_completion_queue_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_threading_test" @@ -2130,6 +2129,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_tracer_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_tracer_test || ( echo test channel_tracer_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test || ( echo test chttp2_settings_timeout_test failed ; exit 1 ) $(E) "[RUN] Testing cli_call_test" @@ -11414,38 +11415,6 @@ endif endif -GRPC_CHANNEL_TRACER_TEST_SRC = \ - test/core/channel/channel_tracer_test.cc \ - -GRPC_CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_TRACER_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) -endif -endif - - GRPC_COMPLETION_QUEUE_TEST_SRC = \ test/core/surface/completion_queue_test.cc \ @@ -15165,6 +15134,49 @@ endif endif +CHANNEL_TRACER_TEST_SRC = \ + test/core/channel/channel_tracer_test.cc \ + +CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/channel_tracer_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/channel_tracer_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/channel_tracer_test: $(PROTOBUF_DEP) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_tracer_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_channel_tracer_test: $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +endif +endif + + CHTTP2_SETTINGS_TIMEOUT_TEST_SRC = \ test/core/transport/chttp2/settings_timeout_test.cc \ diff --git a/build.yaml b/build.yaml index d03b7a113c..bdc6db8d8d 100644 --- a/build.yaml +++ b/build.yaml @@ -2432,17 +2432,6 @@ targets: - gpr_test_util - gpr uses_polling: false -- name: grpc_channel_tracer_test - build: test - language: c - src: - - test/core/channel/channel_tracer_test.cc - deps: - - grpc_test_util - - grpc - - gpr_test_util - - gpr - uses_polling: false - name: grpc_completion_queue_test build: test language: c @@ -3896,6 +3885,21 @@ targets: - grpc - gpr uses_polling: false +- name: channel_tracer_test + gtest: true + build: test + language: c++ + src: + - test/core/channel/channel_tracer_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr + uses: + - grpc++_test + uses_polling: false - name: chttp2_settings_timeout_test gtest: true build: test diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index fdb96570cd..38a5b1ee20 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,6 +40,27 @@ namespace grpc_core { +ChannelTrace::TraceEvent::TraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(std::move(referenced_tracer)) {} + +ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr) {} + ChannelTrace::TraceEvent::~TraceEvent() { GRPC_ERROR_UNREF(error_); grpc_slice_unref_internal(data_); @@ -72,7 +93,7 @@ ChannelTrace::~ChannelTrace() { gpr_mu_destroy(&tracer_mu_); } -intptr_t ChannelTrace::GetUuid() { return channel_uuid_; } +intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { ++num_events_logged_; @@ -125,7 +146,7 @@ char* fmt_time(gpr_timespec tm) { } // anonymous namespace -void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { grpc_json* json_iterator = nullptr; json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), @@ -150,7 +171,7 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { } json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", - fmt_time(time_created_), GRPC_JSON_STRING, true); + fmt_time(timestamp_), GRPC_JSON_STRING, true); json_iterator = grpc_json_create_child(json_iterator, json, "state", grpc_connectivity_state_name(connectivity_state_), @@ -163,7 +184,7 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { } } -char* ChannelTrace::RenderTrace() { +char* ChannelTrace::RenderTrace() const { if (!max_list_size_) return nullptr; // tracing is disabled if max_events == 0 grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 976e66c49e..3339be85e3 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -38,7 +38,7 @@ class ChannelTrace : public RefCounted { ~ChannelTrace(); // returns the tracer's uuid - intptr_t GetUuid(); + intptr_t GetUuid() const; // Adds a new trace event to the tracing object void AddTraceEvent(grpc_slice data, grpc_error* error, @@ -57,7 +57,7 @@ class ChannelTrace : public RefCounted { // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. - char* RenderTrace(); + char* RenderTrace() const; private: // Private class to encapsulate all the data and bookkeeping needed for a @@ -69,41 +69,27 @@ class ChannelTrace : public RefCounted { // overall channelz object, not just the ChannelTrace object TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } + RefCountedPtr referenced_tracer); // Constructor for a TraceEvent that does not reverence a different // channel. TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(nullptr) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } + grpc_connectivity_state connectivity_state); ~TraceEvent(); // Renders the data inside of this TraceEvent into a json object. This is // used by the ChannelTrace, when it is rendering itself. - void RenderTraceEvent(grpc_json* json); + void RenderTraceEvent(grpc_json* json) const; // set and get for the next_ pointer. - TraceEvent* next() { return next_; } + TraceEvent* next() const { return next_; } void set_next(TraceEvent* next) { next_ = next; } private: grpc_slice data_; grpc_error* error_; - gpr_timespec time_created_; + gpr_timespec timestamp_; grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace event refers to. diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 1488736c49..fb435b9881 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -21,6 +21,7 @@ #include "src/core/lib/surface/channel.h" #include +#include #include #include @@ -173,8 +174,8 @@ grpc_channel* grpc_channel_create_with_builder( } else if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); - // max_nodes defaults to 0 (which is off), clamped between 0 and 100. - const grpc_integer_options options = {0, 0, 100}; + // max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX + const grpc_integer_options options = {0, 0, INT_MAX}; channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 78d4dad0b1..d76daccbdb 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -22,6 +22,8 @@ #include #include +#include + #include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" @@ -30,9 +32,8 @@ #include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" -using grpc_core::ChannelTrace; -using grpc_core::MakeRefCounted; -using grpc_core::RefCountedPtr; +namespace grpc_core { +namespace testing { static void add_simple_trace_event(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), @@ -99,7 +100,7 @@ static void test_basic_channel_tracing(size_t max_nodes) { // Calls basic test with various values for max_nodes (including 0, which turns // the tracer off). -static void test_basic_channel_sizing() { +TEST(ChannelTracerTest, BasicTest) { test_basic_channel_tracing(0); test_basic_channel_tracing(1); test_basic_channel_tracing(2); @@ -152,7 +153,7 @@ static void test_complex_channel_tracing(size_t max_nodes) { } // Calls the complex test with a sweep of sizes for max_nodes. -static void test_complex_channel_sizing() { +TEST(ChannelTracerTest, ComplexTest) { test_complex_channel_tracing(0); test_complex_channel_tracing(1); test_complex_channel_tracing(2); @@ -164,7 +165,7 @@ static void test_complex_channel_sizing() { // Test a case in which the parent channel has subchannels and the subchannels // have connections. Ensures that everything lives as long as it should then // gets deleted. -static void test_nesting() { +TEST(ChannelTracerTest, TestNesting) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(10); add_simple_trace_event(tracer); @@ -195,14 +196,14 @@ static void test_nesting() { conn1.reset(nullptr); } +} // namespace testing +} // namespace grpc_core + int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); - test_basic_channel_tracing(5); - test_basic_channel_sizing(); - test_complex_channel_tracing(5); - test_complex_channel_sizing(); - test_nesting(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); grpc_shutdown(); - return 0; + return ret; } diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 94f45c82ca..e4741fc0d2 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -916,23 +916,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_channel_tracer_test", - "src": [ - "test/core/channel/channel_tracer_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -2842,6 +2825,25 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_test", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "channel_tracer_test", + "src": [ + "test/core/channel/channel_tracer_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index fdcac9318c..4d86843f13 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1223,30 +1223,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "grpc_channel_tracer_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, @@ -3361,6 +3337,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "channel_tracer_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, -- cgit v1.2.3 From 31c05ba668ee6ede5326c669277204a7f778a9ab Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 5 Mar 2018 23:06:12 -0800 Subject: reviewer feedback, rename --- CMakeLists.txt | 22 +-- Makefile | 42 ++-- build.yaml | 8 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 8 +- package.xml | 4 +- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_trace.cc | 216 +++++++++++++++++++++ src/core/lib/channel/channel_trace.h | 115 +++++++++++ src/core/lib/channel/channel_tracer.cc | 215 -------------------- src/core/lib/channel/channel_tracer.h | 115 ----------- src/core/lib/surface/channel.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/BUILD | 8 +- test/core/channel/channel_trace_test.cc | 209 ++++++++++++++++++++ test/core/channel/channel_tracer_test.cc | 209 -------------------- test/core/util/channel_tracing_utils.cc | 2 +- test/core/util/channel_tracing_utils.h | 2 - tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 10 +- tools/run_tests/generated/tests.json | 2 +- 26 files changed, 610 insertions(+), 607 deletions(-) create mode 100644 src/core/lib/channel/channel_trace.cc create mode 100644 src/core/lib/channel/channel_trace.h delete mode 100644 src/core/lib/channel/channel_tracer.cc delete mode 100644 src/core/lib/channel/channel_tracer.h create mode 100644 test/core/channel/channel_trace_test.cc delete mode 100644 test/core/channel/channel_tracer_test.cc (limited to 'src/core/lib/surface') diff --git a/CMakeLists.txt b/CMakeLists.txt index 93d3b12962..651fb6bde9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,7 +517,7 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) -add_dependencies(buildtests_cxx channel_tracer_test) +add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) add_dependencies(buildtests_cxx client_channel_stress_test) @@ -800,7 +800,7 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1144,7 +1144,7 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1475,7 +1475,7 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1767,7 +1767,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2038,7 +2038,7 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2843,7 +2843,7 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -9485,14 +9485,14 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(channel_tracer_test - test/core/channel/channel_tracer_test.cc +add_executable(channel_trace_test + test/core/channel/channel_trace_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(channel_tracer_test +target_include_directories(channel_trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${_gRPC_SSL_INCLUDE_DIR} @@ -9508,7 +9508,7 @@ target_include_directories(channel_tracer_test PRIVATE ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(channel_tracer_test +target_link_libraries(channel_trace_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util diff --git a/Makefile b/Makefile index d5777d0e10..01bad6692d 100644 --- a/Makefile +++ b/Makefile @@ -1114,7 +1114,7 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test -channel_tracer_test: $(BINDIR)/$(CONFIG)/channel_tracer_test +channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test @@ -1583,7 +1583,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_tracer_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1732,7 +1732,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_tracer_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -2129,8 +2129,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) - $(E) "[RUN] Testing channel_tracer_test" - $(Q) $(BINDIR)/$(CONFIG)/channel_tracer_test || ( echo test channel_tracer_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_trace_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test || ( echo test chttp2_settings_timeout_test failed ; exit 1 ) $(E) "[RUN] Testing cli_call_test" @@ -3040,7 +3040,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3386,7 +3386,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3718,7 +3718,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4003,7 +4003,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4254,7 +4254,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -5058,7 +5058,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -15134,15 +15134,15 @@ endif endif -CHANNEL_TRACER_TEST_SRC = \ - test/core/channel/channel_tracer_test.cc \ +CHANNEL_TRACE_TEST_SRC = \ + test/core/channel/channel_trace_test.cc \ -CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACER_TEST_SRC)))) +CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC)))) ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL. -$(BINDIR)/$(CONFIG)/channel_tracer_test: openssl_dep_error +$(BINDIR)/$(CONFIG)/channel_trace_test: openssl_dep_error else @@ -15153,26 +15153,26 @@ ifeq ($(NO_PROTOBUF),true) # You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. -$(BINDIR)/$(CONFIG)/channel_tracer_test: protobuf_dep_error +$(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/channel_tracer_test: $(PROTOBUF_DEP) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_tracer_test + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test endif endif -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a -deps_channel_tracer_test: $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) --include $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +-include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) endif endif diff --git a/build.yaml b/build.yaml index bdc6db8d8d..9ef6092e03 100644 --- a/build.yaml +++ b/build.yaml @@ -154,7 +154,7 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - - src/core/lib/channel/channel_tracer.cc + - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc @@ -312,7 +312,7 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - - src/core/lib/channel/channel_tracer.h + - src/core/lib/channel/channel_trace.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h @@ -3885,12 +3885,12 @@ targets: - grpc - gpr uses_polling: false -- name: channel_tracer_test +- name: channel_trace_test gtest: true build: test language: c++ src: - - test/core/channel/channel_tracer_test.cc + - test/core/channel/channel_trace_test.cc deps: - grpc_test_util - grpc++ diff --git a/config.m4 b/config.m4 index 5f79cbcb6a..d53c2f4589 100644 --- a/config.m4 +++ b/config.m4 @@ -84,7 +84,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ diff --git a/config.w32 b/config.w32 index 5471d5cc56..548ae73e31 100644 --- a/config.w32 +++ b/config.w32 @@ -61,7 +61,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + - "src\\core\\lib\\channel\\channel_tracer.cc " + + "src\\core\\lib\\channel\\channel_trace.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d9237752c5..4403af53c5 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -316,7 +316,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -497,7 +497,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6546fe8af2..852992e606 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -327,7 +327,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -473,7 +473,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -825,7 +825,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/grpc.gemspec b/grpc.gemspec index d33333ace9..a53cdfdfe9 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -253,7 +253,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) - s.files += %w( src/core/lib/channel/channel_tracer.h ) + s.files += %w( src/core/lib/channel/channel_trace.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) @@ -403,7 +403,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) - s.files += %w( src/core/lib/channel/channel_tracer.cc ) + s.files += %w( src/core/lib/channel/channel_trace.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) diff --git a/grpc.gyp b/grpc.gyp index 9b5ae58ee4..ca76c68077 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -225,7 +225,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -527,7 +527,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -747,7 +747,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -945,7 +945,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/package.xml b/package.xml index 1cf10540ee..a0841886a9 100644 --- a/package.xml +++ b/package.xml @@ -260,7 +260,7 @@ - + @@ -410,7 +410,7 @@ - + diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 77c0fe2c43..e8ff352be8 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -36,7 +36,7 @@ #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc new file mode 100644 index 0000000000..3217a83fba --- /dev/null +++ b/src/core/lib/channel/channel_trace.cc @@ -0,0 +1,216 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/channel/channel_trace.h" + +#include +#include +#include +#include +#include +#include + +#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/error_utils.h" + +namespace grpc_core { + +ChannelTrace::TraceEvent::TraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(std::move(referenced_tracer)) {} + +ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr) {} + +ChannelTrace::TraceEvent::~TraceEvent() { + GRPC_ERROR_UNREF(error_); + grpc_slice_unref_internal(data_); +} + +ChannelTrace::ChannelTrace(size_t max_events) + : channel_uuid_(-1), + num_events_logged_(0), + num_children_seen_(0), + list_size_(0), + max_list_size_(max_events), + head_trace_(nullptr), + tail_trace_(nullptr) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + gpr_mu_init(&tracer_mu_); + channel_uuid_ = grpc_object_registry_register_object( + this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME); +} + +ChannelTrace::~ChannelTrace() { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + TraceEvent* it = head_trace_; + while (it != nullptr) { + TraceEvent* to_free = it; + it = it->next(); + Delete(to_free); + } + gpr_mu_destroy(&tracer_mu_); +} + +intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } + +void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { + ++num_events_logged_; + // first event case + if (head_trace_ == nullptr) { + head_trace_ = tail_trace_ = new_trace_event; + } + // regular event add case + else { + tail_trace_->set_next(new_trace_event); + tail_trace_ = tail_trace_->next(); + } + ++list_size_; + // maybe garbage collect the end + if (list_size_ > max_list_size_) { + TraceEvent* to_free = head_trace_; + head_trace_ = head_trace_->next(); + Delete(to_free); + --list_size_; + } +} + +void ChannelTrace::AddTraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + ++num_children_seen_; + // create and fill up the new event + AddTraceEventHelper(New(data, error, connectivity_state, + std::move(referenced_tracer))); +} + +void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + AddTraceEventHelper(New(data, error, connectivity_state)); +} + +namespace { + +// returns an allocated string that represents tm according to RFC-3339. +char* fmt_time(gpr_timespec tm) { + char buffer[35]; + struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); + strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); + char* full_time_str; + gpr_asprintf(&full_time_str, "%s.%09dZ", buffer, tm.tv_nsec); + return full_time_str; +} + +} // anonymous namespace + +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { + grpc_json* json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "description", + grpc_slice_to_c_string(data_), + GRPC_JSON_STRING, true); + // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure + // it is done in the layers above core. + if (error_ != GRPC_ERROR_NONE) { + grpc_status_code code; + grpc_slice message; + grpc_error_get_status(error_, GRPC_MILLIS_INF_FUTURE, &code, &message, + nullptr, nullptr); + grpc_json* status = grpc_json_create_child( + json_iterator, json, "status", nullptr, GRPC_JSON_OBJECT, false); + json_iterator = grpc_json_create_child(nullptr, status, "code", + grpc_status_code_to_string(code), + GRPC_JSON_STRING, false); + grpc_json_create_child(json_iterator, status, "message", + grpc_slice_to_c_string(message), GRPC_JSON_STRING, + true); + grpc_slice_unref_internal(message); + json_iterator = status; + } + json_iterator = + grpc_json_create_child(json_iterator, json, "timestamp", + fmt_time(timestamp_), GRPC_JSON_STRING, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "state", + grpc_connectivity_state_name(connectivity_state_), + GRPC_JSON_STRING, false); + if (referenced_tracer_ != nullptr) { + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); + json_iterator = grpc_json_create_child(json_iterator, json, "child_ref", + uuid_str, GRPC_JSON_NUMBER, true); + } +} + +char* ChannelTrace::RenderTrace() const { + if (!max_list_size_) + return nullptr; // tracing is disabled if max_events == 0 + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); + grpc_json* json_iterator = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "num_events_logged", + num_events_logged_str, GRPC_JSON_NUMBER, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "creation_time", + fmt_time(time_created_), GRPC_JSON_STRING, true); + grpc_json* events = grpc_json_create_child(json_iterator, json, "events", + nullptr, GRPC_JSON_ARRAY, false); + json_iterator = nullptr; + TraceEvent* it = head_trace_; + while (it != nullptr) { + json_iterator = grpc_json_create_child(json_iterator, events, nullptr, + nullptr, GRPC_JSON_OBJECT, false); + it->RenderTraceEvent(json_iterator); + it = it->next(); + } + char* json_str = grpc_json_dump_to_string(json, 0); + grpc_json_destroy(json); + return json_str; +} + +} // namespace grpc_core diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h new file mode 100644 index 0000000000..536f51a1f6 --- /dev/null +++ b/src/core/lib/channel/channel_trace.h @@ -0,0 +1,115 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H + +#include + +#include +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/json/json.h" + +namespace grpc_core { + +// Object used to hold live data for a channel. This data is exposed via the +// channelz service: +// https://github.com/grpc/proposal/blob/master/A14-channelz.md +class ChannelTrace : public RefCounted { + public: + ChannelTrace(size_t max_events); + ~ChannelTrace(); + + // returns the tracer's uuid + intptr_t GetUuid() const; + + // Adds a new trace event to the tracing object + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); + + // Adds a new trace event to the tracing object. This trace event refers to a + // an event on a child of the channel. For example, if this channel has + // created a new subchannel, then it would record that with a TraceEvent + // referencing the new subchannel. + + // TODO(ncteisen): Once channelz is implemented, the events should reference + // the overall channelz object, not just the ChannelTrace object. + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); + + // Returns the tracing data rendered as a grpc json string. + // The string is owned by the caller and must be freed. + char* RenderTrace() const; + + private: + // Private class to encapsulate all the data and bookkeeping needed for a + // a trace event. + class TraceEvent { + public: + // Constructor for a TraceEvent that references a different channel. + // TODO(ncteisen): once channelz is implemented, this should reference the + // overall channelz object, not just the ChannelTrace object + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); + + // Constructor for a TraceEvent that does not reverence a different + // channel. + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); + + ~TraceEvent(); + + // Renders the data inside of this TraceEvent into a json object. This is + // used by the ChannelTrace, when it is rendering itself. + void RenderTraceEvent(grpc_json* json) const; + + // set and get for the next_ pointer. + TraceEvent* next() const { return next_; } + void set_next(TraceEvent* next) { next_ = next; } + + private: + grpc_slice data_; + grpc_error* error_; + gpr_timespec timestamp_; + grpc_connectivity_state connectivity_state_; + TraceEvent* next_; + // the tracer object for the (sub)channel that this trace event refers to. + RefCountedPtr referenced_tracer_; + }; // TraceEvent + + // Internal helper to add and link in a trace event + void AddTraceEventHelper(TraceEvent* new_trace_event); + + gpr_mu tracer_mu_; + intptr_t channel_uuid_; + uint64_t num_events_logged_; + uint64_t num_children_seen_; + size_t list_size_; + size_t max_list_size_; + TraceEvent* head_trace_; + TraceEvent* tail_trace_; + gpr_timespec time_created_; +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H */ diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc deleted file mode 100644 index 38a5b1ee20..0000000000 --- a/src/core/lib/channel/channel_tracer.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/channel/channel_tracer.h" - -#include -#include -#include -#include -#include -#include - -#include "src/core/ext/filters/client_channel/status_util.h" -#include "src/core/lib/channel/object_registry.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/surface/channel.h" -#include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/error_utils.h" - -namespace grpc_core { - -ChannelTrace::TraceEvent::TraceEvent( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) - : data_(data), - error_(error), - timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)) {} - -ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) - : data_(data), - error_(error), - timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), - next_(nullptr) {} - -ChannelTrace::TraceEvent::~TraceEvent() { - GRPC_ERROR_UNREF(error_); - grpc_slice_unref_internal(data_); -} - -ChannelTrace::ChannelTrace(size_t max_events) - : channel_uuid_(-1), - num_events_logged_(0), - num_children_seen_(0), - list_size_(0), - max_list_size_(max_events), - head_trace_(nullptr), - tail_trace_(nullptr) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - gpr_mu_init(&tracer_mu_); - channel_uuid_ = grpc_object_registry_register_object( - this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME); -} - -ChannelTrace::~ChannelTrace() { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - TraceEvent* it = head_trace_; - while (it != nullptr) { - TraceEvent* to_free = it; - it = it->next(); - Delete(to_free); - } - gpr_mu_destroy(&tracer_mu_); -} - -intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } - -void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { - ++num_events_logged_; - // first event case - if (head_trace_ == nullptr) { - head_trace_ = tail_trace_ = new_trace_event; - } - // regular event add case - else { - tail_trace_->set_next(new_trace_event); - tail_trace_ = tail_trace_->next(); - } - ++list_size_; - // maybe garbage collect the end - if (list_size_ > max_list_size_) { - TraceEvent* to_free = head_trace_; - head_trace_ = head_trace_->next(); - Delete(to_free); - --list_size_; - } -} - -void ChannelTrace::AddTraceEvent( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - ++num_children_seen_; - // create and fill up the new event - AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer))); -} - -void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) { - AddTraceEventHelper(New(data, error, connectivity_state)); -} - -namespace { - -// returns an allocated string that represents tm according to RFC-3339. -char* fmt_time(gpr_timespec tm) { - char buffer[35]; - struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); - strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); - char* full_time_str; - gpr_asprintf(&full_time_str, "%s.%09dZ", buffer, tm.tv_nsec); - return full_time_str; -} - -} // anonymous namespace - -void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { - grpc_json* json_iterator = nullptr; - json_iterator = grpc_json_create_child(json_iterator, json, "description", - grpc_slice_to_c_string(data_), - GRPC_JSON_STRING, true); - // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure - // it is done in the layers above core. - if (error_ != GRPC_ERROR_NONE) { - grpc_status_code code; - grpc_slice message; - grpc_error_get_status(error_, GRPC_MILLIS_INF_FUTURE, &code, &message, - nullptr, nullptr); - grpc_json* status = grpc_json_create_child( - json_iterator, json, "status", nullptr, GRPC_JSON_OBJECT, false); - json_iterator = grpc_json_create_child(nullptr, status, "code", - grpc_status_code_to_string(code), - GRPC_JSON_STRING, false); - grpc_json_create_child(json_iterator, status, "message", - grpc_slice_to_c_string(message), GRPC_JSON_STRING, - true); - grpc_slice_unref_internal(message); - json_iterator = status; - } - json_iterator = - grpc_json_create_child(json_iterator, json, "timestamp", - fmt_time(timestamp_), GRPC_JSON_STRING, true); - json_iterator = - grpc_json_create_child(json_iterator, json, "state", - grpc_connectivity_state_name(connectivity_state_), - GRPC_JSON_STRING, false); - if (referenced_tracer_ != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); - json_iterator = grpc_json_create_child(json_iterator, json, "child_ref", - uuid_str, GRPC_JSON_NUMBER, true); - } -} - -char* ChannelTrace::RenderTrace() const { - if (!max_list_size_) - return nullptr; // tracing is disabled if max_events == 0 - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - char* num_events_logged_str; - gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); - grpc_json* json_iterator = nullptr; - json_iterator = - grpc_json_create_child(json_iterator, json, "num_events_logged", - num_events_logged_str, GRPC_JSON_NUMBER, true); - json_iterator = - grpc_json_create_child(json_iterator, json, "creation_time", - fmt_time(time_created_), GRPC_JSON_STRING, true); - grpc_json* events = grpc_json_create_child(json_iterator, json, "events", - nullptr, GRPC_JSON_ARRAY, false); - json_iterator = nullptr; - TraceEvent* it = head_trace_; - while (it != nullptr) { - json_iterator = grpc_json_create_child(json_iterator, events, nullptr, - nullptr, GRPC_JSON_OBJECT, false); - it->RenderTraceEvent(json_iterator); - it = it->next(); - } - char* json_str = grpc_json_dump_to_string(json, 0); - grpc_json_destroy(json); - return json_str; -} - -} // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h deleted file mode 100644 index 3339be85e3..0000000000 --- a/src/core/lib/channel/channel_tracer.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H - -#include - -#include -#include "src/core/lib/gprpp/ref_counted.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/json/json.h" - -namespace grpc_core { - -// Object used to hold live data for a channel. This data is exposed via the -// channelz service: -// https://github.com/grpc/proposal/blob/master/A14-channelz.md -class ChannelTrace : public RefCounted { - public: - ChannelTrace(size_t max_events); - ~ChannelTrace(); - - // returns the tracer's uuid - intptr_t GetUuid() const; - - // Adds a new trace event to the tracing object - void AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); - - // Adds a new trace event to the tracing object. This trace event refers to a - // an event on a child of the channel. For example, if this channel has - // created a new subchannel, then it would record that with a TraceEvent - // referencing the new subchannel. - - // TODO(ncteisen): Once channelz is implemented, the events should reference - // the overall channelz object, not just the ChannelTrace object. - void AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); - - // Returns the tracing data rendered as a grpc json string. - // The string is owned by the caller and must be freed. - char* RenderTrace() const; - - private: - // Private class to encapsulate all the data and bookkeeping needed for a - // a trace event. - class TraceEvent { - public: - // Constructor for a TraceEvent that references a different channel. - // TODO(ncteisen): once channelz is implemented, this should reference the - // overall channelz object, not just the ChannelTrace object - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); - - // Constructor for a TraceEvent that does not reverence a different - // channel. - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); - - ~TraceEvent(); - - // Renders the data inside of this TraceEvent into a json object. This is - // used by the ChannelTrace, when it is rendering itself. - void RenderTraceEvent(grpc_json* json) const; - - // set and get for the next_ pointer. - TraceEvent* next() const { return next_; } - void set_next(TraceEvent* next) { next_ = next; } - - private: - grpc_slice data_; - grpc_error* error_; - gpr_timespec timestamp_; - grpc_connectivity_state connectivity_state_; - TraceEvent* next_; - // the tracer object for the (sub)channel that this trace event refers to. - RefCountedPtr referenced_tracer_; - }; // TraceEvent - - // Internal helper to add and link in a trace event - void AddTraceEventHelper(TraceEvent* new_trace_event); - - gpr_mu tracer_mu_; - intptr_t channel_uuid_; - uint64_t num_events_logged_; - uint64_t num_children_seen_; - size_t list_size_; - size_t max_list_size_; - TraceEvent* head_trace_; - TraceEvent* tail_trace_; - gpr_timespec time_created_; -}; - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index fb435b9881..c470f6d0d8 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -31,7 +31,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index bf8fb90c5f..3c3c1d6943 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,7 +60,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index b215aa205c..633c424eae 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -67,12 +67,16 @@ grpc_cc_test( ) grpc_cc_test( - name = "channel_tracer_test", - srcs = ["channel_tracer_test.cc"], + name = "channel_trace_test", + srcs = ["channel_trace_test.cc"], + external_deps = [ + "gtest", + ], language = "C++", deps = [ "//:gpr", "//:grpc", + "//:grpc++", "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc new file mode 100644 index 0000000000..c0cccb77ac --- /dev/null +++ b/test/core/channel/channel_trace_test.cc @@ -0,0 +1,209 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include + +#include + +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" + +#include "test/core/util/channel_tracing_utils.h" +#include "test/core/util/test_config.h" + +namespace grpc_core { +namespace testing { + +static void add_simple_trace_event(RefCountedPtr tracer) { + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY); +} + +// checks for the existence of all the required members of the tracer. +static void validate_trace(RefCountedPtr tracer, + size_t expected_num_event_logged, + size_t max_nodes) { + if (!max_nodes) return; + char* json_str = tracer->RenderTrace(); + grpc_json* json = grpc_json_parse_string(json_str); + validate_channel_trace_data(json, expected_num_event_logged, + GPR_MIN(expected_num_event_logged, max_nodes)); + grpc_json_destroy(json); + gpr_free(json_str); +} + +static void validate_trace_data_matches_uuid_lookup( + RefCountedPtr tracer) { + intptr_t uuid = tracer->GetUuid(); + if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled + char* tracer_json_str = tracer->RenderTrace(); + void* object; + grpc_object_registry_type type = + grpc_object_registry_get_object(uuid, &object); + GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + char* uuid_lookup_json_str = + static_cast(object)->RenderTrace(); + GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); + gpr_free(tracer_json_str); + gpr_free(uuid_lookup_json_str); +} + +// Tests basic ChannelTrace functionality like construction, adding trace, and +// lookups by uuid. +static void test_basic_channel_trace(size_t max_nodes) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + validate_trace_data_matches_uuid_lookup(tracer); + tracer->AddTraceEvent( + grpc_slice_from_static_string("trace three"), + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_ERROR_INT_HTTP2_ERROR, 2), + GRPC_CHANNEL_IDLE); + tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), + GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); + validate_trace(tracer, 4, max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + validate_trace(tracer, 6, max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + validate_trace(tracer, 10, max_nodes); + validate_trace_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); +} + +// Calls basic test with various values for max_nodes (including 0, which turns +// the tracer off). +TEST(ChannelTracerTest, BasicTest) { + test_basic_channel_trace(0); + test_basic_channel_trace(1); + test_basic_channel_trace(2); + test_basic_channel_trace(6); + test_basic_channel_trace(10); + test_basic_channel_trace(15); +} + +// Tests more complex functionality, like a parent channel tracking +// subchannles. This exercises the ref/unref patterns since the parent tracer +// and this function will both hold refs to the subchannel. +static void test_complex_channel_trace(size_t max_nodes) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + RefCountedPtr sc1 = MakeRefCounted(max_nodes); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_trace(tracer, 3, max_nodes); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + validate_trace(sc1, 3, max_nodes); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + validate_trace(sc1, 6, max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + validate_trace(tracer, 5, max_nodes); + validate_trace_data_matches_uuid_lookup(tracer); + RefCountedPtr sc2 = MakeRefCounted(max_nodes); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEvent( + grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); + validate_trace(tracer, 7, max_nodes); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + validate_trace_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); +} + +// Calls the complex test with a sweep of sizes for max_nodes. +TEST(ChannelTracerTest, ComplexTest) { + test_complex_channel_trace(0); + test_complex_channel_trace(1); + test_complex_channel_trace(2); + test_complex_channel_trace(6); + test_complex_channel_trace(10); + test_complex_channel_trace(15); +} + +// Test a case in which the parent channel has subchannels and the subchannels +// have connections. Ensures that everything lives as long as it should then +// gets deleted. +TEST(ChannelTracerTest, TestNesting) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(10); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + RefCountedPtr sc1 = MakeRefCounted(5); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + add_simple_trace_event(sc1); + RefCountedPtr conn1 = MakeRefCounted(5); + // nesting one level deeper. + sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + add_simple_trace_event(conn1); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + RefCountedPtr sc2 = MakeRefCounted(5); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + // this trace should not get added to the parents children since it is already + // present in the tracer. + tracer->AddTraceEvent( + grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); + add_simple_trace_event(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); + conn1.reset(nullptr); +} + +} // namespace testing +} // namespace grpc_core + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; +} diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc deleted file mode 100644 index d76daccbdb..0000000000 --- a/test/core/channel/channel_tracer_test.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#include -#include - -#include - -#include "src/core/lib/channel/channel_tracer.h" -#include "src/core/lib/channel/object_registry.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/iomgr/exec_ctx.h" - -#include "test/core/util/channel_tracing_utils.h" -#include "test/core/util/test_config.h" - -namespace grpc_core { -namespace testing { - -static void add_simple_trace_event(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY); -} - -// checks for the existence of all the required members of the tracer. -static void validate_tracer(RefCountedPtr tracer, - size_t expected_num_event_logged, - size_t max_nodes) { - if (!max_nodes) return; - char* json_str = tracer->RenderTrace(); - grpc_json* json = grpc_json_parse_string(json_str); - validate_channel_trace_data(json, expected_num_event_logged, - GPR_MIN(expected_num_event_logged, max_nodes)); - grpc_json_destroy(json); - gpr_free(json_str); -} - -static void validate_tracer_data_matches_uuid_lookup( - RefCountedPtr tracer) { - intptr_t uuid = tracer->GetUuid(); - if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled - char* tracer_json_str = tracer->RenderTrace(); - void* object; - grpc_object_registry_type type = - grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - char* uuid_lookup_json_str = - static_cast(object)->RenderTrace(); - GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); - gpr_free(tracer_json_str); - gpr_free(uuid_lookup_json_str); -} - -// Tests basic ChannelTrace functionality like construction, adding trace, and -// lookups by uuid. -static void test_basic_channel_tracing(size_t max_nodes) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_tracer_data_matches_uuid_lookup(tracer); - tracer->AddTraceEvent( - grpc_slice_from_static_string("trace three"), - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), - GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); - validate_tracer(tracer, 4, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_tracer(tracer, 6, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_tracer(tracer, 10, max_nodes); - validate_tracer_data_matches_uuid_lookup(tracer); - tracer.reset(nullptr); -} - -// Calls basic test with various values for max_nodes (including 0, which turns -// the tracer off). -TEST(ChannelTracerTest, BasicTest) { - test_basic_channel_tracing(0); - test_basic_channel_tracing(1); - test_basic_channel_tracing(2); - test_basic_channel_tracing(6); - test_basic_channel_tracing(10); - test_basic_channel_tracing(15); -} - -// Tests more complex functionality, like a parent channel tracking -// subchannles. This exercises the ref/unref patterns since the parent tracer -// and this function will both hold refs to the subchannel. -static void test_complex_channel_tracing(size_t max_nodes) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - RefCountedPtr sc1 = MakeRefCounted(max_nodes); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 3, max_nodes); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - validate_tracer(sc1, 3, max_nodes); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - validate_tracer(sc1, 6, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_tracer(tracer, 5, max_nodes); - validate_tracer_data_matches_uuid_lookup(tracer); - RefCountedPtr sc2 = MakeRefCounted(max_nodes); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - tracer->AddTraceEvent( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 7, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_tracer_data_matches_uuid_lookup(tracer); - tracer.reset(nullptr); - sc1.reset(nullptr); - sc2.reset(nullptr); -} - -// Calls the complex test with a sweep of sizes for max_nodes. -TEST(ChannelTracerTest, ComplexTest) { - test_complex_channel_tracing(0); - test_complex_channel_tracing(1); - test_complex_channel_tracing(2); - test_complex_channel_tracing(6); - test_complex_channel_tracing(10); - test_complex_channel_tracing(15); -} - -// Test a case in which the parent channel has subchannels and the subchannels -// have connections. Ensures that everything lives as long as it should then -// gets deleted. -TEST(ChannelTracerTest, TestNesting) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(10); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - RefCountedPtr sc1 = MakeRefCounted(5); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - add_simple_trace_event(sc1); - RefCountedPtr conn1 = MakeRefCounted(5); - // nesting one level deeper. - sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); - add_simple_trace_event(conn1); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - RefCountedPtr sc2 = MakeRefCounted(5); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - // this trace should not get added to the parents children since it is already - // present in the tracer. - tracer->AddTraceEvent( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); - add_simple_trace_event(tracer); - tracer.reset(nullptr); - sc1.reset(nullptr); - sc2.reset(nullptr); - conn1.reset(nullptr); -} - -} // namespace testing -} // namespace grpc_core - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - grpc_init(); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - grpc_shutdown(); - return ret; -} diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index a2449cc4bd..be37703ecc 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -20,7 +20,7 @@ #include #include -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json.h" diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h index fc04d8bae6..2038cd83aa 100644 --- a/test/core/util/channel_tracing_utils.h +++ b/test/core/util/channel_tracing_utils.h @@ -19,8 +19,6 @@ #ifndef GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H #define GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H -#include "src/core/lib/channel/channel_tracer.h" - void validate_json_array_size(grpc_json* json, const char* key, size_t expected_size); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 4a7428e2d8..72fb62d1f2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,7 +1007,7 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_tracer.h \ +src/core/lib/channel/channel_trace.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e1856bf9aa..a64ff1eaf1 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1034,8 +1034,8 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_tracer.cc \ -src/core/lib/channel/channel_tracer.h \ +src/core/lib/channel/channel_trace.cc \ +src/core/lib/channel/channel_trace.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e4741fc0d2..1854b33ce1 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2837,9 +2837,9 @@ "headers": [], "is_filegroup": false, "language": "c++", - "name": "channel_tracer_test", + "name": "channel_trace_test", "src": [ - "test/core/channel/channel_tracer_test.cc" + "test/core/channel/channel_trace_test.cc" ], "third_party": false, "type": "target" @@ -8575,7 +8575,7 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_tracer.cc", + "src/core/lib/channel/channel_trace.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -8734,7 +8734,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/channel_trace.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -8880,7 +8880,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/channel_trace.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 4d86843f13..cae60dd29a 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3352,7 +3352,7 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "channel_tracer_test", + "name": "channel_trace_test", "platforms": [ "linux", "mac", -- cgit v1.2.3 From 1cc064dbfc5fd91a6f705881427b39ca4675abe3 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 07:53:58 -0800 Subject: Reviewer feedback, s/object_registry/channel_trace_registry --- CMakeLists.txt | 12 +-- Makefile | 12 +-- build.yaml | 4 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 8 +- package.xml | 4 +- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_trace.cc | 6 +- src/core/lib/channel/channel_trace_registry.cc | 80 ++++++++++++++++ src/core/lib/channel/channel_trace_registry.h | 43 +++++++++ src/core/lib/channel/object_registry.cc | 103 --------------------- src/core/lib/channel/object_registry.h | 52 ----------- src/core/lib/surface/channel.cc | 1 - src/core/lib/surface/init.cc | 6 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/channel_trace_test.cc | 14 +-- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 6 +- 23 files changed, 171 insertions(+), 208 deletions(-) create mode 100644 src/core/lib/channel/channel_trace_registry.cc create mode 100644 src/core/lib/channel/channel_trace_registry.h delete mode 100644 src/core/lib/channel/object_registry.cc delete mode 100644 src/core/lib/channel/object_registry.h (limited to 'src/core/lib/surface') diff --git a/CMakeLists.txt b/CMakeLists.txt index 651fb6bde9..9c4d6a3070 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -801,11 +801,11 @@ add_library(grpc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1145,11 +1145,11 @@ add_library(grpc_cronet src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1476,11 +1476,11 @@ add_library(grpc_test_util src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1768,11 +1768,11 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2039,11 +2039,11 @@ add_library(grpc_unsecure src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2844,11 +2844,11 @@ add_library(grpc++_cronet src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc diff --git a/Makefile b/Makefile index 01bad6692d..ed87a6a2c4 100644 --- a/Makefile +++ b/Makefile @@ -3041,11 +3041,11 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3387,11 +3387,11 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3719,11 +3719,11 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4004,11 +4004,11 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4255,11 +4255,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5059,11 +5059,11 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ diff --git a/build.yaml b/build.yaml index 9ef6092e03..85ea6e7993 100644 --- a/build.yaml +++ b/build.yaml @@ -155,11 +155,11 @@ filegroups: - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc + - src/core/lib/channel/channel_trace_registry.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc - - src/core/lib/channel/object_registry.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -313,12 +313,12 @@ filegroups: - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_trace.h + - src/core/lib/channel/channel_trace_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - - src/core/lib/channel/object_registry.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h diff --git a/config.m4 b/config.m4 index d53c2f4589..b46eb4078b 100644 --- a/config.m4 +++ b/config.m4 @@ -85,11 +85,11 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ diff --git a/config.w32 b/config.w32 index 548ae73e31..ea90cb5424 100644 --- a/config.w32 +++ b/config.w32 @@ -62,11 +62,11 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + "src\\core\\lib\\channel\\channel_trace.cc " + + "src\\core\\lib\\channel\\channel_trace_registry.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + - "src\\core\\lib\\channel\\object_registry.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 4403af53c5..ae45fe12f3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -317,12 +317,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -498,12 +498,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 852992e606..cf26d7e73d 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -328,12 +328,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -474,11 +474,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -826,12 +826,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.gemspec b/grpc.gemspec index a53cdfdfe9..a20d8efe14 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -254,12 +254,12 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) s.files += %w( src/core/lib/channel/channel_trace.h ) + s.files += %w( src/core/lib/channel/channel_trace_registry.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) - s.files += %w( src/core/lib/channel/object_registry.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -404,11 +404,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) s.files += %w( src/core/lib/channel/channel_trace.cc ) + s.files += %w( src/core/lib/channel/channel_trace_registry.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) - s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) diff --git a/grpc.gyp b/grpc.gyp index ca76c68077..0b7b3b9daf 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -226,11 +226,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -528,11 +528,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -748,11 +748,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -946,11 +946,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', diff --git a/package.xml b/package.xml index a0841886a9..a2b59e7339 100644 --- a/package.xml +++ b/package.xml @@ -261,12 +261,12 @@ + - @@ -411,11 +411,11 @@ + - diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index e8ff352be8..4802110e5a 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -37,8 +37,8 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 3217a83fba..226ab0292d 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -28,7 +28,7 @@ #include #include "src/core/ext/filters/client_channel/status_util.h" -#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" @@ -76,8 +76,7 @@ ChannelTrace::ChannelTrace(size_t max_events) tail_trace_(nullptr) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 gpr_mu_init(&tracer_mu_); - channel_uuid_ = grpc_object_registry_register_object( - this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + channel_uuid_ = grpc_channel_trace_registry_register_channel_trace(this); time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME); } @@ -90,6 +89,7 @@ ChannelTrace::~ChannelTrace() { it = it->next(); Delete(to_free); } + grpc_channel_trace_registry_unregister_channel_trace(channel_uuid_); gpr_mu_destroy(&tracer_mu_); } diff --git a/src/core/lib/channel/channel_trace_registry.cc b/src/core/lib/channel/channel_trace_registry.cc new file mode 100644 index 0000000000..6c82431467 --- /dev/null +++ b/src/core/lib/channel/channel_trace_registry.cc @@ -0,0 +1,80 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/avl/avl.h" +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/gpr/useful.h" + +#include +#include + +// file global lock and avl. +static gpr_mu g_mu; +static grpc_avl g_avl; +static gpr_atm g_uuid = 0; + +// avl vtable for uuid (intptr_t) -> ChannelTrace +// this table is only looking, it does not own anything. +static void destroy_intptr(void* not_used, void* user_data) {} +static void* copy_intptr(void* key, void* user_data) { return key; } +static long compare_intptr(void* key1, void* key2, void* user_data) { + return GPR_ICMP(key1, key2); +} + +static void destroy_channel_trace(void* trace, void* user_data) {} +static void* copy_channel_trace(void* trace, void* user_data) { return trace; } +static const grpc_avl_vtable avl_vtable = { + destroy_intptr, copy_intptr, compare_intptr, destroy_channel_trace, + copy_channel_trace}; + +void grpc_channel_trace_registry_init() { + gpr_mu_init(&g_mu); + g_avl = grpc_avl_create(&avl_vtable); +} + +void grpc_channel_trace_registry_shutdown() { + grpc_avl_unref(g_avl, nullptr); + gpr_mu_destroy(&g_mu); +} + +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace) { + intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); + gpr_mu_lock(&g_mu); + g_avl = grpc_avl_add(g_avl, (void*)prior, channel_trace, nullptr); + gpr_mu_unlock(&g_mu); + return prior; +} + +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid) { + gpr_mu_lock(&g_mu); + g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr); + gpr_mu_unlock(&g_mu); +} + +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid) { + gpr_mu_lock(&g_mu); + grpc_core::ChannelTrace* ret = static_cast( + grpc_avl_get(g_avl, (void*)uuid, nullptr)); + gpr_mu_unlock(&g_mu); + return ret; +} diff --git a/src/core/lib/channel/channel_trace_registry.h b/src/core/lib/channel/channel_trace_registry.h new file mode 100644 index 0000000000..391ecba7de --- /dev/null +++ b/src/core/lib/channel/channel_trace_registry.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H + +#include + +#include "src/core/lib/channel/channel_trace.h" + +#include + +// TODO(ncteisen): convert this file to C++ + +void grpc_channel_trace_registry_init(); +void grpc_channel_trace_registry_shutdown(); + +// globally registers a ChannelTrace. Returns its unique uuid +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace); +// globally unregisters the ChannelTrace that is associated to uuid. +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid); +// if object with uuid has previously been registered, returns the ChannelTrace +// associated with that uuid. Else returns nullptr. +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid); + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H */ diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc deleted file mode 100644 index 987c5366ca..0000000000 --- a/src/core/lib/channel/object_registry.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/avl/avl.h" -#include "src/core/lib/channel/object_registry.h" -#include "src/core/lib/gpr/useful.h" - -#include -#include - -// file global lock and avl. -static gpr_mu g_mu; -static grpc_avl g_avl; -static gpr_atm g_uuid = 0; - -typedef struct { - void* object; - grpc_object_registry_type type; -} object_tracker; - -// avl vtable for uuid (intptr_t) -> object_tracker -// this table is only looking, it does not own anything. -static void destroy_intptr(void* not_used, void* user_data) {} -static void* copy_intptr(void* key, void* user_data) { return key; } -static long compare_intptr(void* key1, void* key2, void* user_data) { - return GPR_ICMP(key1, key2); -} - -static void destroy_tracker(void* tracker, void* user_data) { - gpr_free((object_tracker*)tracker); -} - -static void* copy_tracker(void* value, void* user_data) { - object_tracker* old = static_cast(value); - object_tracker* new_obj = - static_cast(gpr_malloc(sizeof(object_tracker))); - new_obj->object = old->object; - new_obj->type = old->type; - return new_obj; -} -static const grpc_avl_vtable avl_vtable = { - destroy_intptr, copy_intptr, compare_intptr, destroy_tracker, copy_tracker}; - -void grpc_object_registry_init() { - gpr_mu_init(&g_mu); - g_avl = grpc_avl_create(&avl_vtable); -} - -void grpc_object_registry_shutdown() { - grpc_avl_unref(g_avl, nullptr); - gpr_mu_destroy(&g_mu); -} - -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type) { - object_tracker* tracker = - static_cast(gpr_malloc(sizeof(object_tracker))); - tracker->object = object; - tracker->type = type; - intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); - gpr_mu_lock(&g_mu); - g_avl = grpc_avl_add(g_avl, (void*)prior, tracker, nullptr); - gpr_mu_unlock(&g_mu); - return prior; -} - -void grpc_object_registry_unregister_object(intptr_t uuid) { - gpr_mu_lock(&g_mu); - g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr); - gpr_mu_unlock(&g_mu); -} - -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object) { - GPR_ASSERT(object); - gpr_mu_lock(&g_mu); - object_tracker* tracker = - static_cast(grpc_avl_get(g_avl, (void*)uuid, nullptr)); - gpr_mu_unlock(&g_mu); - if (tracker == nullptr) { - *object = nullptr; - return GRPC_OBJECT_REGISTRY_UNKNOWN; - } - *object = tracker->object; - return tracker->type; -} diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h deleted file mode 100644 index 446d0cb41f..0000000000 --- a/src/core/lib/channel/object_registry.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H -#define GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H - -#include - -#include - -// TODO(ncteisen): convert this file to C++ - -// Different types that may be stored in the general object registry. For now, -// the only use case is channel tracers, but the design has been left general. -typedef enum { - // Used to hold uuid -> ChannelTracer mappings to allow for the trace data - // to be looked up by uuid, rather then have to walk the entire tree of - // trace. - GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, - // Usually represents an error has occurred in the object lookup. - GRPC_OBJECT_REGISTRY_UNKNOWN, -} grpc_object_registry_type; - -void grpc_object_registry_init(); -void grpc_object_registry_shutdown(); - -// globally registers the object. Returns its unique uuid -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type); -// globally unregisters the object that is associated to uuid. -void grpc_object_registry_unregister_object(intptr_t uuid); -// if object with uuid has previously been registered, stores it in *object. -// if not, returns GRPC_OBJECT_REGISTRY_UNKNOWN and sets *object unchanged. -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object); - -#endif /* GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index c470f6d0d8..dca583abbe 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,7 +32,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 2d4b3b55d4..bd436d6857 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,9 +27,9 @@ #include #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/fork.h" @@ -129,7 +129,7 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); - grpc_object_registry_init(); + grpc_channel_trace_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -178,7 +178,7 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); - grpc_object_registry_shutdown(); + grpc_channel_trace_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 3c3c1d6943..bc9b5a3c73 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -61,11 +61,11 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index c0cccb77ac..dcc3a347bf 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -25,7 +25,7 @@ #include #include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -43,8 +43,7 @@ static void add_simple_trace_event(RefCountedPtr tracer) { // checks for the existence of all the required members of the tracer. static void validate_trace(RefCountedPtr tracer, - size_t expected_num_event_logged, - size_t max_nodes) { + size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); @@ -59,12 +58,9 @@ static void validate_trace_data_matches_uuid_lookup( intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(); - void* object; - grpc_object_registry_type type = - grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - char* uuid_lookup_json_str = - static_cast(object)->RenderTrace(); + ChannelTrace* uuid_lookup = + grpc_channel_trace_registry_get_channel_trace(uuid); + char* uuid_lookup_json_str = uuid_lookup->RenderTrace(); GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 72fb62d1f2..cae5cc5fa1 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1008,12 +1008,12 @@ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index a64ff1eaf1..78805a0ad1 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1036,6 +1036,8 @@ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.cc \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1045,8 +1047,6 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/object_registry.cc \ -src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 1854b33ce1..90ef05546f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8576,11 +8576,11 @@ "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_trace.cc", + "src/core/lib/channel/channel_trace_registry.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", - "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -8735,12 +8735,12 @@ "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -8881,12 +8881,12 @@ "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", -- cgit v1.2.3 From 568a95e0b45f31918bc5518ff847a5a456156765 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 23:31:47 -0800 Subject: Make test work --- src/core/lib/channel/channel_trace.cc | 67 ++++++------------------ src/core/lib/channel/channel_trace.h | 20 ++----- src/core/lib/surface/channel.cc | 3 +- test/core/channel/channel_trace_test.cc | 25 +++++---- test/cpp/client/channel_trace_proto_json_test.cc | 31 ++++++----- 5 files changed, 55 insertions(+), 91 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 558c852c01..bbbf59cdf9 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -41,31 +41,22 @@ namespace grpc_core { ChannelTrace::TraceEvent::TraceEvent( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer, ReferencedType type) + grpc_slice data, RefCountedPtr referenced_tracer, + ReferencedType type) : data_(data), - error_(error), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), next_(nullptr), referenced_tracer_(std::move(referenced_tracer)), referenced_type_(type) {} -ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) +ChannelTrace::TraceEvent::TraceEvent(grpc_slice data) : data_(data), - error_(error), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), next_(nullptr) {} -ChannelTrace::TraceEvent::~TraceEvent() { - GRPC_ERROR_UNREF(error_); - grpc_slice_unref_internal(data_); -} +ChannelTrace::TraceEvent::~TraceEvent() { grpc_slice_unref_internal(data_); } ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), @@ -117,30 +108,24 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } void ChannelTrace::AddTraceEventReferencingChannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { + grpc_slice data, RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event - AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer), Channel)); + AddTraceEventHelper( + New(data, std::move(referenced_tracer), Channel)); } void ChannelTrace::AddTraceEventReferencingSubchannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { + grpc_slice data, RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event - AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer), - Subchannel)); + AddTraceEventHelper( + New(data, std::move(referenced_tracer), Subchannel)); } -void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) { +void ChannelTrace::AddTraceEvent(grpc_slice data) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - AddTraceEventHelper(New(data, error, connectivity_state)); + AddTraceEventHelper(New(data)); } namespace { @@ -162,40 +147,20 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); - if (error_ != GRPC_ERROR_NONE) { - grpc_status_code code; - grpc_slice message; - grpc_error_get_status(error_, GRPC_MILLIS_INF_FUTURE, &code, &message, - nullptr, nullptr); - grpc_json* status = grpc_json_create_child( - json_iterator, json, "status", nullptr, GRPC_JSON_OBJECT, false); - json_iterator = grpc_json_create_child(nullptr, status, "code", - grpc_status_code_to_string(code), - GRPC_JSON_STRING, false); - grpc_json_create_child(json_iterator, status, "message", - grpc_slice_to_c_string(message), GRPC_JSON_STRING, - true); - grpc_slice_unref_internal(message); - json_iterator = status; - } json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", fmt_time(timestamp_), GRPC_JSON_STRING, true); - json_iterator = - grpc_json_create_child(json_iterator, json, "state", - grpc_connectivity_state_name(connectivity_state_), - GRPC_JSON_STRING, false); if (referenced_tracer_ != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); grpc_json* child_ref = grpc_json_create_child( json_iterator, json, - (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", - nullptr, GRPC_JSON_OBJECT, false); + (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", nullptr, + GRPC_JSON_OBJECT, false); json_iterator = grpc_json_create_child( nullptr, child_ref, - (referenced_type_ == Channel) ? "channelId" : "subchannelId", - uuid_str, GRPC_JSON_STRING, true); + (referenced_type_ == Channel) ? "channelId" : "subchannelId", uuid_str, + GRPC_JSON_STRING, true); json_iterator = child_ref; } } diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 86270138d8..0c46ede600 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -41,8 +41,7 @@ class ChannelTrace : public RefCounted { intptr_t GetUuid() const; // Adds a new trace event to the tracing object - void AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + void AddTraceEvent(grpc_slice data); // Adds a new trace event to the tracing object. This trace event refers to a // an event on a child of the channel. For example, if this channel has @@ -52,13 +51,9 @@ class ChannelTrace : public RefCounted { // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. void AddTraceEventReferencingChannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + grpc_slice data, RefCountedPtr referenced_tracer); void AddTraceEventReferencingSubchannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + grpc_slice data, RefCountedPtr referenced_tracer); // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. @@ -73,15 +68,12 @@ class ChannelTrace : public RefCounted { // Constructor for a TraceEvent that references a different channel. // TODO(ncteisen): once channelz is implemented, this should reference the // overall channelz object, not just the ChannelTrace object - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer, + TraceEvent(grpc_slice data, RefCountedPtr referenced_tracer, ReferencedType type); // Constructor for a TraceEvent that does not reverence a different // channel. - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + TraceEvent(grpc_slice data); ~TraceEvent(); @@ -95,9 +87,7 @@ class ChannelTrace : public RefCounted { private: grpc_slice data_; - grpc_error* error_; gpr_timespec timestamp_; - grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace event refers to. RefCountedPtr referenced_tracer_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index dca583abbe..463e6121d0 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -184,8 +184,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); channel->tracer->AddTraceEvent( - grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE); + grpc_slice_from_static_string("Channel created")); return channel; } diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index beb823eacf..c85fb1cdba 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -142,8 +142,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); AddSimpleTrace(sc1); @@ -158,8 +159,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateChannelTrace(tracer, 5, GetParam()); ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("LB channel two created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc2); tracer->AddTraceEventReferencingSubchannel( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); @@ -185,19 +187,22 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. - sc1->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + sc1->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEventReferencingChannel( diff --git a/test/cpp/client/channel_trace_proto_json_test.cc b/test/cpp/client/channel_trace_proto_json_test.cc index 98cf676236..9fbd7b1bf3 100644 --- a/test/cpp/client/channel_trace_proto_json_test.cc +++ b/test/cpp/client/channel_trace_proto_json_test.cc @@ -38,9 +38,7 @@ using grpc_core::RefCountedPtr; namespace { void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY); + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); } } // namespace @@ -51,28 +49,35 @@ TEST(ChannelTraceTest, ProtoJsonTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(10); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel one created"), sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); RefCountedPtr sc2 = MakeRefCounted(10); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("LB channel two created"), sc2); tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one inactive"), sc1); std::string tracer_json_str = tracer->RenderTrace(); - gpr_log(GPR_ERROR, "%s", tracer_json_str.c_str()); grpc::channelz::ChannelTrace channel_trace; google::protobuf::util::JsonParseOptions options; - options.ignore_unknown_fields = true; + // If the following line is failing, then uncomment the last line of the + // comment, and uncomment the lines that print the two strings. You can + // then compare the output, and determine what fields are missing. + // + // options.ignore_unknown_fields = true; ASSERT_EQ(google::protobuf::util::JsonStringToMessage( tracer_json_str, &channel_trace, options), google::protobuf::util::Status::OK); std::string proto_json_str; - ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, &proto_json_str), google::protobuf::util::Status::OK); - gpr_log(GPR_ERROR, "%s", proto_json_str.c_str()); + ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, + &proto_json_str), + google::protobuf::util::Status::OK); + // uncomment these to compare the the json strings. + // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str()); + // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); + ASSERT_EQ(tracer_json_str, proto_json_str); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); -- cgit v1.2.3 From 09703ea30089464820dd56a07711f81a2d1e0f3c Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 00:34:37 -0800 Subject: Add severity --- src/core/lib/channel/channel_trace.cc | 38 +++++++++++++++++------------ src/core/lib/channel/channel_trace.h | 22 +++++++++++++---- src/core/lib/surface/channel.cc | 1 + src/proto/grpc/channelz/channelz.proto | 2 +- test/core/channel/channel_trace_test.cc | 16 +++++++++--- test/cpp/util/channel_trace_proto_helper.cc | 5 ++-- 6 files changed, 58 insertions(+), 26 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index bbbf59cdf9..e0f495284f 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -41,17 +41,19 @@ namespace grpc_core { ChannelTrace::TraceEvent::TraceEvent( - grpc_slice data, RefCountedPtr referenced_tracer, - ReferencedType type) - : data_(data), + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, ReferencedType type) + : severity_(severity), + data_(data), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), next_(nullptr), referenced_tracer_(std::move(referenced_tracer)), referenced_type_(type) {} -ChannelTrace::TraceEvent::TraceEvent(grpc_slice data) - : data_(data), +ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data) + : severity_(severity), + data_(data), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), next_(nullptr) {} @@ -107,25 +109,27 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } } -void ChannelTrace::AddTraceEventReferencingChannel( - grpc_slice data, RefCountedPtr referenced_tracer) { +void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - // create and fill up the new event - AddTraceEventHelper( - New(data, std::move(referenced_tracer), Channel)); + AddTraceEventHelper(New(severity, data)); } -void ChannelTrace::AddTraceEventReferencingSubchannel( - grpc_slice data, RefCountedPtr referenced_tracer) { +void ChannelTrace::AddTraceEventReferencingChannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event AddTraceEventHelper( - New(data, std::move(referenced_tracer), Subchannel)); + New(severity, data, std::move(referenced_tracer), Channel)); } -void ChannelTrace::AddTraceEvent(grpc_slice data) { +void ChannelTrace::AddTraceEventReferencingSubchannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - AddTraceEventHelper(New(data)); + // create and fill up the new event + AddTraceEventHelper(New( + severity, data, std::move(referenced_tracer), Subchannel)); } namespace { @@ -147,6 +151,10 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); + char* trace_level_str; + gpr_asprintf(&trace_level_str, "%d", static_cast(severity_)); + json_iterator = grpc_json_create_child( + json_iterator, json, "severity", trace_level_str, GRPC_JSON_NUMBER, true); json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", fmt_time(timestamp_), GRPC_JSON_STRING, true); diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 0c46ede600..7243096617 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -40,8 +40,15 @@ class ChannelTrace : public RefCounted { // returns the tracer's uuid intptr_t GetUuid() const; + enum Severity { + Unset = 0, // never to be used + Info, // we start at 1 to avoid using proto default values + Warning, + Error + }; + // Adds a new trace event to the tracing object - void AddTraceEvent(grpc_slice data); + void AddTraceEvent(Severity severity, grpc_slice data); // Adds a new trace event to the tracing object. This trace event refers to a // an event on a child of the channel. For example, if this channel has @@ -51,15 +58,18 @@ class ChannelTrace : public RefCounted { // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. void AddTraceEventReferencingChannel( - grpc_slice data, RefCountedPtr referenced_tracer); + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); void AddTraceEventReferencingSubchannel( - grpc_slice data, RefCountedPtr referenced_tracer); + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. char* RenderTrace() const; private: + // Types of objects that can be references by trace events. enum ReferencedType { Channel, Subchannel }; // Private class to encapsulate all the data and bookkeeping needed for a // a trace event. @@ -68,12 +78,13 @@ class ChannelTrace : public RefCounted { // Constructor for a TraceEvent that references a different channel. // TODO(ncteisen): once channelz is implemented, this should reference the // overall channelz object, not just the ChannelTrace object - TraceEvent(grpc_slice data, RefCountedPtr referenced_tracer, + TraceEvent(Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, ReferencedType type); // Constructor for a TraceEvent that does not reverence a different // channel. - TraceEvent(grpc_slice data); + TraceEvent(Severity severity, grpc_slice data); ~TraceEvent(); @@ -86,6 +97,7 @@ class ChannelTrace : public RefCounted { void set_next(TraceEvent* next) { next_ = next; } private: + Severity severity_; grpc_slice data_; gpr_timespec timestamp_; TraceEvent* next_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 463e6121d0..cecc15b2df 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -184,6 +184,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); channel->tracer->AddTraceEvent( + grpc_core::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Channel created")); return channel; } diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index 532ec7978f..851f301536 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -98,7 +98,7 @@ message ChannelTraceEvent { // the severity of the trace event. Options are INFO, WARNING, and ERROR, // which are represented by the values 1, 2, and 3, respectively. Any other // value will be treated as ERROR. - int32 trace_level = 2; + int32 severity = 2; // When this event occurred. google.protobuf.Timestamp timestamp = 3; // ref of referenced channel or subchannel. diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 0c858005ca..471ebd6b58 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -73,7 +73,8 @@ void ValidateChannelTraceData(grpc_json* json, } void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("simple trace")); } // checks for the existence of all the required members of the tracer. @@ -113,8 +114,10 @@ TEST_P(ChannelTracerTest, BasicTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); ValidateTraceDataMatchedUuidLookup(tracer); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace three")); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace four")); + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("trace three")); + tracer->AddTraceEvent(ChannelTrace::Severity::Error, + grpc_slice_from_static_string("trace four error")); ValidateChannelTrace(tracer, 4, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); @@ -138,6 +141,7 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel one created"), sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); @@ -154,8 +158,10 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("LB channel two created"), sc2); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Warning, grpc_slice_from_static_string("subchannel one inactive"), sc1); ValidateChannelTrace(tracer, 7, GetParam()); AddSimpleTrace(tracer); @@ -180,21 +186,25 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel one created"), sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. sc1->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("connection one created"), conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel two created"), sc2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Warning, grpc_slice_from_static_string("subchannel one inactive"), sc1); AddSimpleTrace(tracer); tracer.reset(nullptr); diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc index be00dd1424..fbc9f1501c 100644 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include "src/proto/grpc/channelz/channelz.pb.h" @@ -32,14 +33,14 @@ namespace testing { void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) { std::string tracer_json_str(tracer_json_c_str); grpc::channelz::ChannelTrace channel_trace; - google::protobuf::util::JsonParseOptions options; + google::protobuf::util::JsonParseOptions parse_options; // If the following line is failing, then uncomment the last line of the // comment, and uncomment the lines that print the two strings. You can // then compare the output, and determine what fields are missing. // // options.ignore_unknown_fields = true; ASSERT_EQ(google::protobuf::util::JsonStringToMessage( - tracer_json_str, &channel_trace, options), + tracer_json_str, &channel_trace, parse_options), google::protobuf::util::Status::OK); std::string proto_json_str; ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, -- cgit v1.2.3 From 3d8b32d8b3d7e85d0588064994efa6763d6fec02 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 9 Mar 2018 13:25:40 -0800 Subject: Convert byte_stream API to C++. --- BUILD | 1 + CMakeLists.txt | 65 +++-- Makefile | 84 +++--- build.yaml | 23 +- .../ext/filters/client_channel/client_channel.cc | 38 +-- .../ext/filters/http/client/http_client_filter.cc | 48 ++-- .../message_compress/message_compress_filter.cc | 41 ++- .../ext/filters/http/server/http_server_filter.cc | 17 +- .../filters/message_size/message_size_filter.cc | 10 +- .../workaround_cronet_compression_filter.cc | 4 +- .../transport/chttp2/transport/chttp2_transport.cc | 293 +++++++++------------ .../ext/transport/chttp2/transport/frame_data.cc | 32 +-- .../ext/transport/chttp2/transport/frame_data.h | 9 +- src/core/ext/transport/chttp2/transport/internal.h | 77 ++++-- .../transport/cronet/transport/cronet_transport.cc | 41 ++- src/core/ext/transport/inproc/inproc_transport.cc | 39 ++- src/core/lib/surface/call.cc | 60 ++--- src/core/lib/transport/byte_stream.cc | 197 ++++++-------- src/core/lib/transport/byte_stream.h | 182 +++++++------ src/core/lib/transport/transport.cc | 2 +- src/core/lib/transport/transport.h | 11 +- src/core/lib/transport/transport_op_string.cc | 13 +- src/cpp/common/channel_filter.h | 14 +- test/core/transport/BUILD | 3 + test/core/transport/byte_stream_test.cc | 194 +++++++------- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 39 +-- tools/run_tests/generated/sources_and_headers.json | 34 +-- tools/run_tests/generated/tests.json | 48 ++-- 28 files changed, 797 insertions(+), 822 deletions(-) (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 9c99f95fcd..bfda84e0f4 100644 --- a/BUILD +++ b/BUILD @@ -939,6 +939,7 @@ grpc_cc_library( "grpc_codegen", "grpc_trace", "inlined_vector", + "orphanable", "ref_counted", "ref_counted_ptr", ], diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dfbdcb85a..e0724d10aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,6 @@ add_dependencies(buildtests_c avl_test) add_dependencies(buildtests_c bad_server_response_test) add_dependencies(buildtests_c bin_decoder_test) add_dependencies(buildtests_c bin_encoder_test) -add_dependencies(buildtests_c byte_stream_test) add_dependencies(buildtests_c channel_create_test) add_dependencies(buildtests_c chttp2_hpack_encoder_test) add_dependencies(buildtests_c chttp2_stream_map_test) @@ -530,6 +529,7 @@ endif() if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx bm_pollset) endif() +add_dependencies(buildtests_cxx byte_stream_test) add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) add_dependencies(buildtests_cxx check_gcp_environment_linux_test) @@ -5436,33 +5436,6 @@ target_link_libraries(bin_encoder_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(byte_stream_test - test/core/transport/byte_stream_test.cc -) - - -target_include_directories(byte_stream_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} -) - -target_link_libraries(byte_stream_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(channel_create_test test/core/surface/channel_create_test.cc ) @@ -9984,6 +9957,42 @@ endif() endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(byte_stream_test + test/core/transport/byte_stream_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(byte_stream_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(byte_stream_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(channel_arguments_test test/cpp/common/channel_arguments_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index a298fafd6b..160762b62f 100644 --- a/Makefile +++ b/Makefile @@ -961,7 +961,6 @@ avl_test: $(BINDIR)/$(CONFIG)/avl_test bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test -byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test check_epollexclusive: $(BINDIR)/$(CONFIG)/check_epollexclusive chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test @@ -1127,6 +1126,7 @@ bm_fullstack_trickle: $(BINDIR)/$(CONFIG)/bm_fullstack_trickle bm_fullstack_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset +byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test check_gcp_environment_linux_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test @@ -1399,7 +1399,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/bad_server_response_test \ $(BINDIR)/$(CONFIG)/bin_decoder_test \ $(BINDIR)/$(CONFIG)/bin_encoder_test \ - $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_create_test \ $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \ $(BINDIR)/$(CONFIG)/chttp2_stream_map_test \ @@ -1613,6 +1612,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_metadata \ $(BINDIR)/$(CONFIG)/bm_pollset \ + $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ @@ -1779,6 +1779,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_fullstack_unary_ping_pong \ $(BINDIR)/$(CONFIG)/bm_metadata \ $(BINDIR)/$(CONFIG)/bm_pollset \ + $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ @@ -1885,8 +1886,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/bin_decoder_test || ( echo test bin_decoder_test failed ; exit 1 ) $(E) "[RUN] Testing bin_encoder_test" $(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 ) - $(E) "[RUN] Testing byte_stream_test" - $(Q) $(BINDIR)/$(CONFIG)/byte_stream_test || ( echo test byte_stream_test failed ; exit 1 ) $(E) "[RUN] Testing channel_create_test" $(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_hpack_encoder_test" @@ -2203,6 +2202,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/bm_metadata || ( echo test bm_metadata failed ; exit 1 ) $(E) "[RUN] Testing bm_pollset" $(Q) $(BINDIR)/$(CONFIG)/bm_pollset || ( echo test bm_pollset failed ; exit 1 ) + $(E) "[RUN] Testing byte_stream_test" + $(Q) $(BINDIR)/$(CONFIG)/byte_stream_test || ( echo test byte_stream_test failed ; exit 1 ) $(E) "[RUN] Testing channel_arguments_test" $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" @@ -10128,38 +10129,6 @@ endif endif -BYTE_STREAM_TEST_SRC = \ - test/core/transport/byte_stream_test.cc \ - -BYTE_STREAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BYTE_STREAM_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/byte_stream_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/byte_stream_test: $(BYTE_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(BYTE_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/byte_stream_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/transport/byte_stream_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_byte_stream_test: $(BYTE_STREAM_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(BYTE_STREAM_TEST_OBJS:.o=.dep) -endif -endif - - CHANNEL_CREATE_TEST_SRC = \ test/core/surface/channel_create_test.cc \ @@ -15830,6 +15799,49 @@ endif endif +BYTE_STREAM_TEST_SRC = \ + test/core/transport/byte_stream_test.cc \ + +BYTE_STREAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BYTE_STREAM_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/byte_stream_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/byte_stream_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/byte_stream_test: $(PROTOBUF_DEP) $(BYTE_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BYTE_STREAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/byte_stream_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/transport/byte_stream_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_byte_stream_test: $(BYTE_STREAM_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BYTE_STREAM_TEST_OBJS:.o=.dep) +endif +endif + + CHANNEL_ARGUMENTS_TEST_SRC = \ test/cpp/common/channel_arguments_test.cc \ diff --git a/build.yaml b/build.yaml index e2bb8bfa9f..6afd48ca72 100644 --- a/build.yaml +++ b/build.yaml @@ -1986,17 +1986,6 @@ targets: - grpc_test_util - grpc uses_polling: false -- name: byte_stream_test - build: test - language: c - src: - - test/core/transport/byte_stream_test.cc - deps: - - grpc_test_util - - grpc - - gpr_test_util - - gpr - uses_polling: false - name: channel_create_test build: test language: c @@ -4071,6 +4060,18 @@ targets: - mac - linux - posix +- name: byte_stream_test + gtest: true + build: test + language: c++ + src: + - test/core/transport/byte_stream_test.cc + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr + uses_polling: false - name: channel_arguments_test gtest: true build: test diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 90b93fbe23..bbc5160bec 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -798,7 +798,8 @@ typedef struct { grpc_linked_mdelem* send_initial_metadata_storage; grpc_metadata_batch send_initial_metadata; // For send_message. - grpc_caching_byte_stream send_message; + grpc_core::ManualConstructor + send_message; // For send_trailing_metadata. grpc_linked_mdelem* send_trailing_metadata_storage; grpc_metadata_batch send_trailing_metadata; @@ -808,7 +809,7 @@ typedef struct { bool trailing_metadata_available; // For intercepting recv_message. grpc_closure recv_message_ready; - grpc_byte_stream* recv_message; + grpc_core::OrphanablePtr recv_message; // For intercepting recv_trailing_metadata. grpc_metadata_batch recv_trailing_metadata; grpc_transport_stream_stats collect_stats; @@ -914,12 +915,12 @@ typedef struct client_channel_call_data { gpr_atm* peer_string; // send_message // When we get a send_message op, we replace the original byte stream - // with a grpc_caching_byte_stream that caches the slices to a - // local buffer for use in retries. + // with a CachingByteStream that caches the slices to a local buffer for + // use in retries. // Note: We inline the cache for the first 3 send_message ops and use // dynamic allocation after that. This number was essentially picked // at random; it could be changed in the future to tune performance. - grpc_core::InlinedVector send_messages; + grpc_core::InlinedVector send_messages; // send_trailing_metadata bool seen_send_trailing_metadata; grpc_linked_mdelem* send_trailing_metadata_storage; @@ -964,10 +965,11 @@ static void maybe_cache_send_ops_for_batch(call_data* calld, } // Set up cache for send_message ops. if (batch->send_message) { - grpc_byte_stream_cache* cache = (grpc_byte_stream_cache*)gpr_arena_alloc( - calld->arena, sizeof(grpc_byte_stream_cache)); - grpc_byte_stream_cache_init(cache, - batch->payload->send_message.send_message); + grpc_core::ByteStreamCache* cache = + static_cast( + gpr_arena_alloc(calld->arena, sizeof(grpc_core::ByteStreamCache))); + new (cache) grpc_core::ByteStreamCache( + std::move(batch->payload->send_message.send_message)); calld->send_messages.push_back(cache); } // Save metadata batch for send_trailing_metadata ops. @@ -1002,7 +1004,7 @@ static void free_cached_send_op_data_after_commit( "]", chand, calld, i); } - grpc_byte_stream_cache_destroy(calld->send_messages[i]); + calld->send_messages[i]->Destroy(); } if (retry_state->completed_send_trailing_metadata) { grpc_metadata_batch_destroy(&calld->send_trailing_metadata); @@ -1026,8 +1028,8 @@ static void free_cached_send_op_data_for_completed_batch( "]", chand, calld, retry_state->completed_send_message_count - 1); } - grpc_byte_stream_cache_destroy( - calld->send_messages[retry_state->completed_send_message_count - 1]); + calld->send_messages[retry_state->completed_send_message_count - 1] + ->Destroy(); } if (batch_data->batch.send_trailing_metadata) { grpc_metadata_batch_destroy(&calld->send_trailing_metadata); @@ -1079,7 +1081,7 @@ static void pending_batches_add(grpc_call_element* elem, if (batch->send_message) { calld->pending_send_message = true; calld->bytes_buffered_for_retry += - batch->payload->send_message.send_message->length; + batch->payload->send_message.send_message->length(); } if (batch->send_trailing_metadata) { calld->pending_send_trailing_metadata = true; @@ -1680,7 +1682,7 @@ static void invoke_recv_message_callback(void* arg, grpc_error* error) { GPR_ASSERT(pending != nullptr); // Return payload. *pending->batch->payload->recv_message.recv_message = - batch_data->recv_message; + std::move(batch_data->recv_message); // Update bookkeeping. // Note: Need to do this before invoking the callback, since invoking // the callback will result in yielding the call combiner. @@ -2124,13 +2126,13 @@ static void add_retriable_send_message_op( "chand=%p calld=%p: starting calld->send_messages[%" PRIuPTR "]", chand, calld, retry_state->started_send_message_count); } - grpc_byte_stream_cache* cache = + grpc_core::ByteStreamCache* cache = calld->send_messages[retry_state->started_send_message_count]; ++retry_state->started_send_message_count; - grpc_caching_byte_stream_init(&batch_data->send_message, cache); + batch_data->send_message.Init(cache); batch_data->batch.send_message = true; - batch_data->batch.payload->send_message.send_message = - &batch_data->send_message.base; + batch_data->batch.payload->send_message.send_message.reset( + batch_data->send_message.get()); } // Adds retriable send_trailing_metadata op to batch_data. diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 58aefd17c7..ae94ce47b9 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -20,9 +20,11 @@ #include #include #include +#include #include #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/percent_encoding.h" @@ -58,8 +60,9 @@ struct call_data { // State for handling send_message ops. grpc_transport_stream_op_batch* send_message_batch; size_t send_message_bytes_read; - grpc_byte_stream_cache send_message_cache; - grpc_caching_byte_stream send_message_caching_stream; + grpc_core::ManualConstructor send_message_cache; + grpc_core::ManualConstructor + send_message_caching_stream; grpc_closure on_send_message_next_done; grpc_closure* original_send_message_on_complete; grpc_closure send_message_on_complete; @@ -166,7 +169,7 @@ static void recv_trailing_metadata_on_complete(void* user_data, static void send_message_on_complete(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); call_data* calld = static_cast(elem->call_data); - grpc_byte_stream_cache_destroy(&calld->send_message_cache); + calld->send_message_cache.Destroy(); GRPC_CLOSURE_RUN(calld->original_send_message_on_complete, GRPC_ERROR_REF(error)); } @@ -175,8 +178,7 @@ static void send_message_on_complete(void* arg, grpc_error* error) { // calld->send_message_bytes_read. static grpc_error* pull_slice_from_send_message(call_data* calld) { grpc_slice incoming_slice; - grpc_error* error = grpc_byte_stream_pull( - &calld->send_message_caching_stream.base, &incoming_slice); + grpc_error* error = calld->send_message_caching_stream->Pull(&incoming_slice); if (error == GRPC_ERROR_NONE) { calld->send_message_bytes_read += GRPC_SLICE_LENGTH(incoming_slice); grpc_slice_unref_internal(incoming_slice); @@ -186,24 +188,23 @@ static grpc_error* pull_slice_from_send_message(call_data* calld) { // Reads as many slices as possible from the send_message byte stream. // Upon successful return, if calld->send_message_bytes_read == -// calld->send_message_caching_stream.base.length, then we have completed +// calld->send_message_caching_stream->length(), then we have completed // reading from the byte stream; otherwise, an async read has been dispatched // and on_send_message_next_done() will be invoked when it is complete. static grpc_error* read_all_available_send_message_data(call_data* calld) { - while (grpc_byte_stream_next(&calld->send_message_caching_stream.base, - ~static_cast(0), - &calld->on_send_message_next_done)) { + while (calld->send_message_caching_stream->Next( + SIZE_MAX, &calld->on_send_message_next_done)) { grpc_error* error = pull_slice_from_send_message(calld); if (error != GRPC_ERROR_NONE) return error; if (calld->send_message_bytes_read == - calld->send_message_caching_stream.base.length) { + calld->send_message_caching_stream->length()) { break; } } return GRPC_ERROR_NONE; } -// Async callback for grpc_byte_stream_next(). +// Async callback for ByteStream::Next(). static void on_send_message_next_done(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); call_data* calld = static_cast(elem->call_data); @@ -222,7 +223,7 @@ static void on_send_message_next_done(void* arg, grpc_error* error) { // here, then we know that all of the data was not available // synchronously, so we were not able to do a cached call. Instead, // we just reset the byte stream and then send down the batch as-is. - grpc_caching_byte_stream_reset(&calld->send_message_caching_stream); + calld->send_message_caching_stream->Reset(); grpc_call_next_op(elem, calld->send_message_batch); } @@ -253,7 +254,7 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, size_t estimated_len = GRPC_SLICE_LENGTH(path_slice); estimated_len++; /* for the '?' */ estimated_len += grpc_base64_estimate_encoded_size( - batch->payload->send_message.send_message->length, true /* url_safe */, + batch->payload->send_message.send_message->length(), true /* url_safe */, false /* multi_line */); grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len); /* memcopy individual pieces into this slice */ @@ -265,9 +266,9 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, write_ptr += GRPC_SLICE_LENGTH(path_slice); *write_ptr++ = '?'; char* payload_bytes = - slice_buffer_to_string(&calld->send_message_cache.cache_buffer); + slice_buffer_to_string(calld->send_message_cache->cache_buffer()); grpc_base64_encode_core(write_ptr, payload_bytes, - batch->payload->send_message.send_message->length, + batch->payload->send_message.send_message->length(), true /* url_safe */, false /* multi_line */); gpr_free(payload_bytes); /* remove trailing unused memory and add trailing 0 to terminate string */ @@ -326,15 +327,14 @@ static void hc_start_transport_stream_op_batch( if (batch->send_message && (batch->payload->send_initial_metadata.send_initial_metadata_flags & GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) && - batch->payload->send_message.send_message->length < + batch->payload->send_message.send_message->length() < channeld->max_payload_size_for_get) { calld->send_message_bytes_read = 0; - grpc_byte_stream_cache_init(&calld->send_message_cache, - batch->payload->send_message.send_message); - grpc_caching_byte_stream_init(&calld->send_message_caching_stream, - &calld->send_message_cache); - batch->payload->send_message.send_message = - &calld->send_message_caching_stream.base; + calld->send_message_cache.Init( + std::move(batch->payload->send_message.send_message)); + calld->send_message_caching_stream.Init(calld->send_message_cache.get()); + batch->payload->send_message.send_message.reset( + calld->send_message_caching_stream.get()); calld->original_send_message_on_complete = batch->on_complete; batch->on_complete = &calld->send_message_on_complete; calld->send_message_batch = batch; @@ -342,12 +342,12 @@ static void hc_start_transport_stream_op_batch( if (error != GRPC_ERROR_NONE) goto done; // If all the data has been read, then we can use GET. if (calld->send_message_bytes_read == - calld->send_message_caching_stream.base.length) { + calld->send_message_caching_stream->length()) { method = GRPC_MDELEM_METHOD_GET; error = update_path_for_get(elem, batch); if (error != GRPC_ERROR_NONE) goto done; batch->send_message = false; - grpc_byte_stream_destroy(&calld->send_message_caching_stream.base); + calld->send_message_caching_stream->Orphan(); } else { // Not all data is available. The batch will be sent down // asynchronously in on_send_message_next_done(). diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index efe0085c5b..e7d9949386 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -32,6 +32,7 @@ #include "src/core/lib/compression/compression_internal.h" #include "src/core/lib/compression/message_compress.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" @@ -62,7 +63,8 @@ struct call_data { grpc_closure start_send_message_batch_in_call_combiner; grpc_transport_stream_op_batch* send_message_batch; grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ - grpc_slice_buffer_stream replacement_stream; + grpc_core::ManualConstructor + replacement_stream; grpc_closure* original_send_message_on_complete; grpc_closure send_message_on_complete; grpc_closure on_send_message_next_done; @@ -220,7 +222,7 @@ static void finish_send_message(grpc_call_element* elem) { grpc_slice_buffer tmp; grpc_slice_buffer_init(&tmp); uint32_t send_flags = - calld->send_message_batch->payload->send_message.send_message->flags; + calld->send_message_batch->payload->send_message.send_message->flags(); bool did_compress = grpc_msg_compress(calld->message_compression_algorithm, &calld->slices, &tmp); if (did_compress) { @@ -253,12 +255,9 @@ static void finish_send_message(grpc_call_element* elem) { grpc_slice_buffer_destroy_internal(&tmp); // Swap out the original byte stream with our new one and send the // batch down. - grpc_byte_stream_destroy( - calld->send_message_batch->payload->send_message.send_message); - grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, - send_flags); - calld->send_message_batch->payload->send_message.send_message = - &calld->replacement_stream.base; + calld->replacement_stream.Init(&calld->slices, send_flags); + calld->send_message_batch->payload->send_message.send_message.reset( + calld->replacement_stream.get()); calld->original_send_message_on_complete = calld->send_message_batch->on_complete; calld->send_message_batch->on_complete = &calld->send_message_on_complete; @@ -278,9 +277,9 @@ static void fail_send_message_batch_in_call_combiner(void* arg, // Pulls a slice from the send_message byte stream and adds it to calld->slices. static grpc_error* pull_slice_from_send_message(call_data* calld) { grpc_slice incoming_slice; - grpc_error* error = grpc_byte_stream_pull( - calld->send_message_batch->payload->send_message.send_message, - &incoming_slice); + grpc_error* error = + calld->send_message_batch->payload->send_message.send_message->Pull( + &incoming_slice); if (error == GRPC_ERROR_NONE) { grpc_slice_buffer_add(&calld->slices, incoming_slice); } @@ -289,12 +288,11 @@ static grpc_error* pull_slice_from_send_message(call_data* calld) { // Reads as many slices as possible from the send_message byte stream. // If all data has been read, invokes finish_send_message(). Otherwise, -// an async call to grpc_byte_stream_next() has been started, which will +// an async call to ByteStream::Next() has been started, which will // eventually result in calling on_send_message_next_done(). static void continue_reading_send_message(grpc_call_element* elem) { call_data* calld = static_cast(elem->call_data); - while (grpc_byte_stream_next( - calld->send_message_batch->payload->send_message.send_message, + while (calld->send_message_batch->payload->send_message.send_message->Next( ~static_cast(0), &calld->on_send_message_next_done)) { grpc_error* error = pull_slice_from_send_message(calld); if (error != GRPC_ERROR_NONE) { @@ -303,15 +301,15 @@ static void continue_reading_send_message(grpc_call_element* elem) { GRPC_ERROR_UNREF(error); return; } - if (calld->slices.length == - calld->send_message_batch->payload->send_message.send_message->length) { + if (calld->slices.length == calld->send_message_batch->payload->send_message + .send_message->length()) { finish_send_message(elem); break; } } } -// Async callback for grpc_byte_stream_next(). +// Async callback for ByteStream::Next(). static void on_send_message_next_done(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast(arg); call_data* calld = static_cast(elem->call_data); @@ -328,7 +326,7 @@ static void on_send_message_next_done(void* arg, grpc_error* error) { return; } if (calld->slices.length == - calld->send_message_batch->payload->send_message.send_message->length) { + calld->send_message_batch->payload->send_message.send_message->length()) { finish_send_message(elem); } else { continue_reading_send_message(elem); @@ -340,7 +338,8 @@ static void start_send_message_batch(void* arg, grpc_error* unused) { call_data* calld = static_cast(elem->call_data); if (skip_compression( elem, - calld->send_message_batch->payload->send_message.send_message->flags, + calld->send_message_batch->payload->send_message.send_message + ->flags(), calld->send_initial_metadata_state == HAS_COMPRESSION_ALGORITHM)) { send_message_batch_continue(elem); } else { @@ -365,9 +364,7 @@ static void compress_start_transport_stream_op_batch( grpc_schedule_on_exec_ctx), GRPC_ERROR_REF(calld->cancel_error), "failing send_message op"); } else { - grpc_byte_stream_shutdown( - - calld->send_message_batch->payload->send_message.send_message, + calld->send_message_batch->payload->send_message.send_message->Shutdown( GRPC_ERROR_REF(calld->cancel_error)); } } diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 57ec8dce34..c202015875 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -23,6 +23,7 @@ #include #include #include +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/percent_encoding.h" @@ -53,8 +54,8 @@ struct call_data { */ grpc_closure* recv_message_ready; grpc_closure* on_complete; - grpc_byte_stream** pp_recv_message; - grpc_slice_buffer_stream read_stream; + grpc_core::OrphanablePtr* pp_recv_message; + grpc_core::ManualConstructor read_stream; /** Receive closures are chained: we inject this closure as the on_done_recv up-call on transport_op, and remember to call our on_done_recv member @@ -232,7 +233,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem, grpc_base64_decode_with_len( reinterpret_cast GRPC_SLICE_START_PTR(query_slice), GRPC_SLICE_LENGTH(query_slice), k_url_safe)); - grpc_slice_buffer_stream_init(&calld->read_stream, &read_slice_buffer, 0); + calld->read_stream.Init(&read_slice_buffer, 0); grpc_slice_buffer_destroy_internal(&read_slice_buffer); calld->seen_path_with_query = true; grpc_slice_unref_internal(query_slice); @@ -281,10 +282,10 @@ static void hs_on_complete(void* user_data, grpc_error* err) { call_data* calld = static_cast(elem->call_data); /* Call recv_message_ready if we got the payload via the path field */ if (calld->seen_path_with_query && calld->recv_message_ready != nullptr) { - *calld->pp_recv_message = - calld->payload_bin_delivered - ? nullptr - : reinterpret_cast(&calld->read_stream); + calld->pp_recv_message->reset( + calld->payload_bin_delivered ? nullptr + : reinterpret_cast( + calld->read_stream.get())); // Re-enter call combiner for recv_message_ready, since the surface // code will release the call combiner for each callback it receives. GRPC_CALL_COMBINER_START(calld->call_combiner, calld->recv_message_ready, @@ -405,7 +406,7 @@ static void destroy_call_elem(grpc_call_element* elem, grpc_closure* ignored) { call_data* calld = static_cast(elem->call_data); if (calld->seen_path_with_query && !calld->payload_bin_delivered) { - grpc_byte_stream_destroy(&calld->read_stream.base); + calld->read_stream->Orphan(); } } diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index b1b14dde02..c7fc3f2e62 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -100,7 +100,7 @@ struct call_data { // call our next_recv_message_ready member after handling it. grpc_closure recv_message_ready; // Used by recv_message_ready. - grpc_byte_stream** recv_message; + grpc_core::OrphanablePtr* recv_message; // Original recv_message_ready callback, invoked after our own. grpc_closure* next_recv_message_ready; }; @@ -121,12 +121,12 @@ static void recv_message_ready(void* user_data, grpc_error* error) { grpc_call_element* elem = static_cast(user_data); call_data* calld = static_cast(elem->call_data); if (*calld->recv_message != nullptr && calld->limits.max_recv_size >= 0 && - (*calld->recv_message)->length > + (*calld->recv_message)->length() > static_cast(calld->limits.max_recv_size)) { char* message_string; gpr_asprintf(&message_string, "Received message larger than max (%u vs. %d)", - (*calld->recv_message)->length, calld->limits.max_recv_size); + (*calld->recv_message)->length(), calld->limits.max_recv_size); grpc_error* new_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED); @@ -150,11 +150,11 @@ static void start_transport_stream_op_batch( call_data* calld = static_cast(elem->call_data); // Check max send message size. if (op->send_message && calld->limits.max_send_size >= 0 && - op->payload->send_message.send_message->length > + op->payload->send_message.send_message->length() > static_cast(calld->limits.max_send_size)) { char* message_string; gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", - op->payload->send_message.send_message->length, + op->payload->send_message.send_message->length(), calld->limits.max_send_size); grpc_transport_stream_op_batch_finish_with_failure( op, diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc index bed1004c57..c7070d4d9b 100644 --- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc @@ -93,7 +93,9 @@ static void start_transport_stream_op_batch( /* Send message happens after client's user-agent (initial metadata) is * received, so workaround_active must be set already */ if (calld->workaround_active) { - op->payload->send_message.send_message->flags |= GRPC_WRITE_NO_COMPRESS; + op->payload->send_message.send_message->set_flags( + op->payload->send_message.send_message->flags() | + GRPC_WRITE_NO_COMPRESS); } } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 56aaada912..a4d616d778 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -39,6 +39,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/timer.h" @@ -117,12 +118,6 @@ static void connectivity_state_set(grpc_chttp2_transport* t, grpc_connectivity_state state, grpc_error* error, const char* reason); -static void incoming_byte_stream_destroy_locked(void* byte_stream, - grpc_error* error_ignored); -static void incoming_byte_stream_publish_error( - grpc_chttp2_incoming_byte_stream* bs, grpc_error* error); -static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs); - static void benign_reclaimer_locked(void* t, grpc_error* error); static void destructive_reclaimer_locked(void* t, grpc_error* error); @@ -662,8 +657,8 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs, s->t = t; s->refcount = refcount; /* We reserve one 'active stream' that's dropped when the stream is - read-closed. The others are for incoming_byte_streams that are actively - reading */ + read-closed. The others are for Chttp2IncomingByteStreams that are + actively reading */ GRPC_CHTTP2_STREAM_REF(s, "chttp2"); grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[0], arena); @@ -1256,8 +1251,7 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t, abort(); /* TODO(ctiller): what cleanup here? */ return; /* early out */ } - if (s->fetched_send_message_length == s->fetching_send_message->length) { - grpc_byte_stream_destroy(s->fetching_send_message); + if (s->fetched_send_message_length == s->fetching_send_message->length()) { int64_t notify_offset = s->next_message_end_offset; if (notify_offset <= s->flow_controlled_bytes_written) { grpc_chttp2_complete_closure_step( @@ -1274,20 +1268,19 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t, cb->closure = s->fetching_send_message_finished; s->fetching_send_message_finished = nullptr; grpc_chttp2_write_cb** list = - s->fetching_send_message->flags & GRPC_WRITE_THROUGH + s->fetching_send_message->flags() & GRPC_WRITE_THROUGH ? &s->on_write_finished_cbs : &s->on_flow_controlled_cbs; cb->next = *list; *list = cb; } - s->fetching_send_message = nullptr; + s->fetching_send_message.reset(); return; /* early out */ - } else if (grpc_byte_stream_next(s->fetching_send_message, UINT32_MAX, - &s->complete_fetch_locked)) { - grpc_error* error = - grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice); + } else if (s->fetching_send_message->Next(UINT32_MAX, + &s->complete_fetch_locked)) { + grpc_error* error = s->fetching_send_message->Pull(&s->fetching_slice); if (error != GRPC_ERROR_NONE) { - grpc_byte_stream_destroy(s->fetching_send_message); + s->fetching_send_message.reset(); grpc_chttp2_cancel_stream(t, s, error); } else { add_fetched_slice_locked(t, s); @@ -1300,14 +1293,14 @@ static void complete_fetch_locked(void* gs, grpc_error* error) { grpc_chttp2_stream* s = static_cast(gs); grpc_chttp2_transport* t = s->t; if (error == GRPC_ERROR_NONE) { - error = grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice); + error = s->fetching_send_message->Pull(&s->fetching_slice); if (error == GRPC_ERROR_NONE) { add_fetched_slice_locked(t, s); continue_fetching_send_locked(t, s); } } if (error != GRPC_ERROR_NONE) { - grpc_byte_stream_destroy(s->fetching_send_message); + s->fetching_send_message.reset(); grpc_chttp2_cancel_stream(t, s, error); } } @@ -1439,7 +1432,7 @@ static void perform_stream_op_locked(void* stream_op, GPR_ASSERT(s->id != 0); grpc_chttp2_mark_stream_writable(t, s); if (!(op->send_message && - (op->payload->send_message.send_message->flags & + (op->payload->send_message.send_message->flags() & GRPC_WRITE_BUFFER_HINT))) { grpc_chttp2_initiate_write( t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA); @@ -1466,7 +1459,7 @@ static void perform_stream_op_locked(void* stream_op, if (op->send_message) { GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE(); GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE( - op->payload->send_message.send_message->length); + op->payload->send_message.send_message->length()); on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE; s->fetching_send_message_finished = add_closure_barrier(op->on_complete); if (s->write_closed) { @@ -1475,7 +1468,7 @@ static void perform_stream_op_locked(void* stream_op, // streaming call might send another message before getting a // recv_message failure, breaking out of its loop, and then // starting recv_trailing_metadata. - grpc_byte_stream_destroy(op->payload->send_message.send_message); + op->payload->send_message.send_message.reset(); grpc_chttp2_complete_closure_step( t, s, &s->fetching_send_message_finished, t->is_client && s->received_trailing_metadata @@ -1488,14 +1481,15 @@ static void perform_stream_op_locked(void* stream_op, GPR_ASSERT(s->fetching_send_message == nullptr); uint8_t* frame_hdr = grpc_slice_buffer_tiny_add( &s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES); - uint32_t flags = op_payload->send_message.send_message->flags; + uint32_t flags = op_payload->send_message.send_message->flags(); frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0; - size_t len = op_payload->send_message.send_message->length; + size_t len = op_payload->send_message.send_message->length(); frame_hdr[1] = static_cast(len >> 24); frame_hdr[2] = static_cast(len >> 16); frame_hdr[3] = static_cast(len >> 8); frame_hdr[4] = static_cast(len); - s->fetching_send_message = op_payload->send_message.send_message; + s->fetching_send_message = + std::move(op_payload->send_message.send_message); s->fetched_send_message_length = 0; s->next_message_end_offset = s->flow_controlled_bytes_written + @@ -1947,12 +1941,12 @@ static void remove_stream(grpc_chttp2_transport* t, uint32_t id, } if (s->pending_byte_stream) { if (s->on_next != nullptr) { - grpc_chttp2_incoming_byte_stream* bs = s->data_parser.parsing_frame; + grpc_core::Chttp2IncomingByteStream* bs = s->data_parser.parsing_frame; if (error == GRPC_ERROR_NONE) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); } - incoming_byte_stream_publish_error(bs, error); - incoming_byte_stream_unref(bs); + bs->PublishError(error); + bs->Unref(); s->data_parser.parsing_frame = nullptr; } else { GRPC_ERROR_UNREF(s->byte_stream_error); @@ -2096,10 +2090,7 @@ void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t, GRPC_ERROR_REF(error), "send_trailing_metadata_finished"); - if (s->fetching_send_message != nullptr) { - grpc_byte_stream_destroy(s->fetching_send_message); - s->fetching_send_message = nullptr; - } + s->fetching_send_message.reset(); grpc_chttp2_complete_closure_step(t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error), "fetching_send_message_finished"); @@ -2715,7 +2706,6 @@ static void set_pollset_set(grpc_transport* gt, grpc_stream* gs, static void reset_byte_stream(void* arg, grpc_error* error) { grpc_chttp2_stream* s = static_cast(arg); - s->pending_byte_stream = false; if (error == GRPC_ERROR_NONE) { grpc_chttp2_maybe_complete_recv_message(s->t, s); @@ -2731,22 +2721,56 @@ static void reset_byte_stream(void* arg, grpc_error* error) { } } -static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs) { - if (gpr_unref(&bs->refs)) { - gpr_free(bs); +namespace grpc_core { + +Chttp2IncomingByteStream::Chttp2IncomingByteStream( + grpc_chttp2_transport* transport, grpc_chttp2_stream* stream, + uint32_t frame_size, uint32_t flags) + : ByteStream(frame_size, flags), + transport_(transport), + stream_(stream), + remaining_bytes_(frame_size) { + gpr_ref_init(&refs_, 2); + GRPC_ERROR_UNREF(stream->byte_stream_error); + stream->byte_stream_error = GRPC_ERROR_NONE; +} + +void Chttp2IncomingByteStream::OrphanLocked(void* arg, + grpc_error* error_ignored) { + Chttp2IncomingByteStream* bs = static_cast(arg); + grpc_chttp2_stream* s = bs->stream_; + grpc_chttp2_transport* t = s->t; + bs->Unref(); + s->pending_byte_stream = false; + grpc_chttp2_maybe_complete_recv_message(t, s); + grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); +} + +void Chttp2IncomingByteStream::Orphan() { + GPR_TIMER_SCOPE("incoming_byte_stream_destroy", 0); + GRPC_CLOSURE_SCHED( + GRPC_CLOSURE_INIT(&destroy_action_, + &Chttp2IncomingByteStream::OrphanLocked, this, + grpc_combiner_scheduler(transport_->combiner)), + GRPC_ERROR_NONE); +} + +void Chttp2IncomingByteStream::Unref() { + if (gpr_unref(&refs_)) { + Delete(this); } } -static void incoming_byte_stream_next_locked(void* argp, - grpc_error* error_ignored) { - grpc_chttp2_incoming_byte_stream* bs = - static_cast(argp); - grpc_chttp2_transport* t = bs->transport; - grpc_chttp2_stream* s = bs->stream; +void Chttp2IncomingByteStream::Ref() { gpr_ref(&refs_); } +void Chttp2IncomingByteStream::NextLocked(void* arg, + grpc_error* error_ignored) { + Chttp2IncomingByteStream* bs = static_cast(arg); + grpc_chttp2_transport* t = bs->transport_; + grpc_chttp2_stream* s = bs->stream_; size_t cur_length = s->frame_storage.length; if (!s->read_closed) { - s->flow_control->IncomingByteStreamUpdate(bs->next_action.max_size_hint, + s->flow_control->IncomingByteStreamUpdate(bs->next_action_.max_size_hint, cur_length); grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s); } @@ -2755,22 +2779,22 @@ static void incoming_byte_stream_next_locked(void* argp, grpc_slice_buffer_swap(&s->frame_storage, &s->unprocessed_incoming_frames_buffer); s->unprocessed_incoming_frames_decompressed = false; - GRPC_CLOSURE_SCHED(bs->next_action.on_complete, GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(bs->next_action_.on_complete, GRPC_ERROR_NONE); } else if (s->byte_stream_error != GRPC_ERROR_NONE) { - GRPC_CLOSURE_SCHED(bs->next_action.on_complete, + GRPC_CLOSURE_SCHED(bs->next_action_.on_complete, GRPC_ERROR_REF(s->byte_stream_error)); if (s->data_parser.parsing_frame != nullptr) { - incoming_byte_stream_unref(s->data_parser.parsing_frame); + s->data_parser.parsing_frame->Unref(); s->data_parser.parsing_frame = nullptr; } } else if (s->read_closed) { - if (bs->remaining_bytes != 0) { + if (bs->remaining_bytes_ != 0) { s->byte_stream_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); - GRPC_CLOSURE_SCHED(bs->next_action.on_complete, + GRPC_CLOSURE_SCHED(bs->next_action_.on_complete, GRPC_ERROR_REF(s->byte_stream_error)); if (s->data_parser.parsing_frame != nullptr) { - incoming_byte_stream_unref(s->data_parser.parsing_frame); + s->data_parser.parsing_frame->Unref(); s->data_parser.parsing_frame = nullptr; } } else { @@ -2778,122 +2802,94 @@ static void incoming_byte_stream_next_locked(void* argp, GPR_ASSERT(false); } } else { - s->on_next = bs->next_action.on_complete; + s->on_next = bs->next_action_.on_complete; } - incoming_byte_stream_unref(bs); + bs->Unref(); } -static bool incoming_byte_stream_next(grpc_byte_stream* byte_stream, - size_t max_size_hint, - grpc_closure* on_complete) { +bool Chttp2IncomingByteStream::Next(size_t max_size_hint, + grpc_closure* on_complete) { GPR_TIMER_SCOPE("incoming_byte_stream_next", 0); - grpc_chttp2_incoming_byte_stream* bs = - reinterpret_cast(byte_stream); - grpc_chttp2_stream* s = bs->stream; - if (s->unprocessed_incoming_frames_buffer.length > 0) { + if (stream_->unprocessed_incoming_frames_buffer.length > 0) { return true; } else { - gpr_ref(&bs->refs); - bs->next_action.max_size_hint = max_size_hint; - bs->next_action.on_complete = on_complete; + Ref(); + next_action_.max_size_hint = max_size_hint; + next_action_.on_complete = on_complete; GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&bs->next_action.closure, - incoming_byte_stream_next_locked, bs, - grpc_combiner_scheduler(bs->transport->combiner)), + GRPC_CLOSURE_INIT(&next_action_.closure, + &Chttp2IncomingByteStream::NextLocked, this, + grpc_combiner_scheduler(transport_->combiner)), GRPC_ERROR_NONE); return false; } } -static grpc_error* incoming_byte_stream_pull(grpc_byte_stream* byte_stream, - grpc_slice* slice) { +grpc_error* Chttp2IncomingByteStream::Pull(grpc_slice* slice) { GPR_TIMER_SCOPE("incoming_byte_stream_pull", 0); - grpc_chttp2_incoming_byte_stream* bs = - reinterpret_cast(byte_stream); - grpc_chttp2_stream* s = bs->stream; grpc_error* error; - - if (s->unprocessed_incoming_frames_buffer.length > 0) { - if (!s->unprocessed_incoming_frames_decompressed) { + if (stream_->unprocessed_incoming_frames_buffer.length > 0) { + if (!stream_->unprocessed_incoming_frames_decompressed) { bool end_of_context; - if (!s->stream_decompression_ctx) { - s->stream_decompression_ctx = grpc_stream_compression_context_create( - s->stream_decompression_method); + if (!stream_->stream_decompression_ctx) { + stream_->stream_decompression_ctx = + grpc_stream_compression_context_create( + stream_->stream_decompression_method); } - if (!grpc_stream_decompress(s->stream_decompression_ctx, - &s->unprocessed_incoming_frames_buffer, - &s->decompressed_data_buffer, nullptr, + if (!grpc_stream_decompress(stream_->stream_decompression_ctx, + &stream_->unprocessed_incoming_frames_buffer, + &stream_->decompressed_data_buffer, nullptr, MAX_SIZE_T, &end_of_context)) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream decompression error."); return error; } - GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0); - grpc_slice_buffer_swap(&s->unprocessed_incoming_frames_buffer, - &s->decompressed_data_buffer); - s->unprocessed_incoming_frames_decompressed = true; + GPR_ASSERT(stream_->unprocessed_incoming_frames_buffer.length == 0); + grpc_slice_buffer_swap(&stream_->unprocessed_incoming_frames_buffer, + &stream_->decompressed_data_buffer); + stream_->unprocessed_incoming_frames_decompressed = true; if (end_of_context) { - grpc_stream_compression_context_destroy(s->stream_decompression_ctx); - s->stream_decompression_ctx = nullptr; + grpc_stream_compression_context_destroy( + stream_->stream_decompression_ctx); + stream_->stream_decompression_ctx = nullptr; } - if (s->unprocessed_incoming_frames_buffer.length == 0) { + if (stream_->unprocessed_incoming_frames_buffer.length == 0) { *slice = grpc_empty_slice(); } } error = grpc_deframe_unprocessed_incoming_frames( - &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, slice, - nullptr); + &stream_->data_parser, stream_, + &stream_->unprocessed_incoming_frames_buffer, slice, nullptr); if (error != GRPC_ERROR_NONE) { return error; } } else { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); - GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error)); return error; } return GRPC_ERROR_NONE; } -static void incoming_byte_stream_destroy_locked(void* byte_stream, - grpc_error* error_ignored); - -static void incoming_byte_stream_destroy(grpc_byte_stream* byte_stream) { - GPR_TIMER_SCOPE("incoming_byte_stream_destroy", 0); - grpc_chttp2_incoming_byte_stream* bs = - reinterpret_cast(byte_stream); - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_INIT(&bs->destroy_action, - incoming_byte_stream_destroy_locked, bs, - grpc_combiner_scheduler(bs->transport->combiner)), - GRPC_ERROR_NONE); -} - -static void incoming_byte_stream_publish_error( - grpc_chttp2_incoming_byte_stream* bs, grpc_error* error) { - grpc_chttp2_stream* s = bs->stream; - +void Chttp2IncomingByteStream::PublishError(grpc_error* error) { GPR_ASSERT(error != GRPC_ERROR_NONE); - GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_REF(error)); - s->on_next = nullptr; - GRPC_ERROR_UNREF(s->byte_stream_error); - s->byte_stream_error = GRPC_ERROR_REF(error); - grpc_chttp2_cancel_stream(bs->transport, bs->stream, GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(stream_->on_next, GRPC_ERROR_REF(error)); + stream_->on_next = nullptr; + GRPC_ERROR_UNREF(stream_->byte_stream_error); + stream_->byte_stream_error = GRPC_ERROR_REF(error); + grpc_chttp2_cancel_stream(transport_, stream_, GRPC_ERROR_REF(error)); } -grpc_error* grpc_chttp2_incoming_byte_stream_push( - grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice, - grpc_slice* slice_out) { - grpc_chttp2_stream* s = bs->stream; - - if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) { +grpc_error* Chttp2IncomingByteStream::Push(grpc_slice slice, + grpc_slice* slice_out) { + if (remaining_bytes_ < GRPC_SLICE_LENGTH(slice)) { grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream"); - - GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error)); grpc_slice_unref_internal(slice); return error; } else { - bs->remaining_bytes -= static_cast GRPC_SLICE_LENGTH(slice); + remaining_bytes_ -= static_cast GRPC_SLICE_LENGTH(slice); if (slice_out != nullptr) { *slice_out = slice; } @@ -2901,66 +2897,25 @@ grpc_error* grpc_chttp2_incoming_byte_stream_push( } } -grpc_error* grpc_chttp2_incoming_byte_stream_finished( - grpc_chttp2_incoming_byte_stream* bs, grpc_error* error, - bool reset_on_error) { - grpc_chttp2_stream* s = bs->stream; - +grpc_error* Chttp2IncomingByteStream::Finished(grpc_error* error, + bool reset_on_error) { if (error == GRPC_ERROR_NONE) { - if (bs->remaining_bytes != 0) { + if (remaining_bytes_ != 0) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message"); } } if (error != GRPC_ERROR_NONE && reset_on_error) { - GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error)); + GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error)); } - incoming_byte_stream_unref(bs); + Unref(); return error; } -static void incoming_byte_stream_shutdown(grpc_byte_stream* byte_stream, - grpc_error* error) { - grpc_chttp2_incoming_byte_stream* bs = - reinterpret_cast(byte_stream); - GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished( - bs, error, true /* reset_on_error */)); +void Chttp2IncomingByteStream::Shutdown(grpc_error* error) { + GRPC_ERROR_UNREF(Finished(error, true /* reset_on_error */)); } -static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = { - incoming_byte_stream_next, incoming_byte_stream_pull, - incoming_byte_stream_shutdown, incoming_byte_stream_destroy}; - -static void incoming_byte_stream_destroy_locked(void* byte_stream, - grpc_error* error_ignored) { - grpc_chttp2_incoming_byte_stream* bs = - static_cast(byte_stream); - grpc_chttp2_stream* s = bs->stream; - grpc_chttp2_transport* t = s->t; - - GPR_ASSERT(bs->base.vtable == &grpc_chttp2_incoming_byte_stream_vtable); - incoming_byte_stream_unref(bs); - s->pending_byte_stream = false; - grpc_chttp2_maybe_complete_recv_message(t, s); - grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); -} - -grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create( - grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size, - uint32_t flags) { - grpc_chttp2_incoming_byte_stream* incoming_byte_stream = - static_cast( - gpr_malloc(sizeof(*incoming_byte_stream))); - incoming_byte_stream->base.length = frame_size; - incoming_byte_stream->remaining_bytes = frame_size; - incoming_byte_stream->base.flags = flags; - incoming_byte_stream->base.vtable = &grpc_chttp2_incoming_byte_stream_vtable; - gpr_ref_init(&incoming_byte_stream->refs, 2); - incoming_byte_stream->transport = t; - incoming_byte_stream->stream = s; - GRPC_ERROR_UNREF(s->byte_stream_error); - s->byte_stream_error = GRPC_ERROR_NONE; - return incoming_byte_stream; -} +} // namespace grpc_core /******************************************************************************* * RESOURCE QUOTAS diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index 0d37a494a2..f8f06f6789 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -27,6 +27,7 @@ #include #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/transport/transport.h" @@ -39,8 +40,7 @@ grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser) { void grpc_chttp2_data_parser_destroy(grpc_chttp2_data_parser* parser) { if (parser->parsing_frame != nullptr) { - GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished( - parser->parsing_frame, + GRPC_ERROR_UNREF(parser->parsing_frame->Finished( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Parser destroyed"), false)); } GRPC_ERROR_UNREF(parser->error); @@ -100,7 +100,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf, grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_chttp2_data_parser* p, grpc_chttp2_stream* s, grpc_slice_buffer* slices, grpc_slice* slice_out, - grpc_byte_stream** stream_out) { + grpc_core::OrphanablePtr* stream_out) { grpc_error* error = GRPC_ERROR_NONE; grpc_chttp2_transport* t = s->t; @@ -197,12 +197,11 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( if (p->is_frame_compressed) { message_flags |= GRPC_WRITE_INTERNAL_COMPRESS; } - p->parsing_frame = grpc_chttp2_incoming_byte_stream_create( + p->parsing_frame = grpc_core::New( t, s, p->frame_size, message_flags); - *stream_out = &p->parsing_frame->base; - if (p->parsing_frame->remaining_bytes == 0) { - GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished( - p->parsing_frame, GRPC_ERROR_NONE, true)); + stream_out->reset(p->parsing_frame); + if (p->parsing_frame->remaining_bytes() == 0) { + GRPC_ERROR_UNREF(p->parsing_frame->Finished(GRPC_ERROR_NONE, true)); p->parsing_frame = nullptr; p->state = GRPC_CHTTP2_DATA_FH_0; } @@ -226,8 +225,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( if (remaining == p->frame_size) { s->stats.incoming.data_bytes += remaining; if (GRPC_ERROR_NONE != - (error = grpc_chttp2_incoming_byte_stream_push( - p->parsing_frame, + (error = p->parsing_frame->Push( grpc_slice_sub(slice, static_cast(cur - beg), static_cast(end - beg)), slice_out))) { @@ -235,8 +233,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( return error; } if (GRPC_ERROR_NONE != - (error = grpc_chttp2_incoming_byte_stream_finished( - p->parsing_frame, GRPC_ERROR_NONE, true))) { + (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { grpc_slice_unref_internal(slice); return error; } @@ -247,8 +244,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( } else if (remaining < p->frame_size) { s->stats.incoming.data_bytes += remaining; if (GRPC_ERROR_NONE != - (error = grpc_chttp2_incoming_byte_stream_push( - p->parsing_frame, + (error = p->parsing_frame->Push( grpc_slice_sub(slice, static_cast(cur - beg), static_cast(end - beg)), slice_out))) { @@ -261,18 +257,16 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( GPR_ASSERT(remaining > p->frame_size); s->stats.incoming.data_bytes += p->frame_size; if (GRPC_ERROR_NONE != - (grpc_chttp2_incoming_byte_stream_push( - p->parsing_frame, + p->parsing_frame->Push( grpc_slice_sub( slice, static_cast(cur - beg), static_cast(cur + p->frame_size - beg)), - slice_out))) { + slice_out)) { grpc_slice_unref_internal(slice); return error; } if (GRPC_ERROR_NONE != - (error = grpc_chttp2_incoming_byte_stream_finished( - p->parsing_frame, GRPC_ERROR_NONE, true))) { + (error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) { grpc_slice_unref_internal(slice); return error; } diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index 3efbbf9f76..4b0f873644 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -40,8 +40,9 @@ typedef enum { GRPC_CHTTP2_DATA_ERROR } grpc_chttp2_stream_state; -typedef struct grpc_chttp2_incoming_byte_stream - grpc_chttp2_incoming_byte_stream; +namespace grpc_core { +class Chttp2IncomingByteStream; +} // namespace grpc_core typedef struct { grpc_chttp2_stream_state state; @@ -50,7 +51,7 @@ typedef struct { grpc_error* error; bool is_frame_compressed; - grpc_chttp2_incoming_byte_stream* parsing_frame; + grpc_core::Chttp2IncomingByteStream* parsing_frame; } grpc_chttp2_data_parser; /* initialize per-stream state for data frame parsing */ @@ -79,6 +80,6 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf, grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_chttp2_data_parser* p, grpc_chttp2_stream* s, grpc_slice_buffer* slices, grpc_slice* slice_out, - grpc_byte_stream** stream_out); + grpc_core::OrphanablePtr* stream_out); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index b9431cd311..6d11e5aa31 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -203,18 +203,58 @@ typedef struct grpc_chttp2_write_cb { struct grpc_chttp2_write_cb* next; } grpc_chttp2_write_cb; -/* forward declared in frame_data.h */ -struct grpc_chttp2_incoming_byte_stream { - grpc_byte_stream base; - gpr_refcount refs; +namespace grpc_core { + +class Chttp2IncomingByteStream : public ByteStream { + public: + Chttp2IncomingByteStream(grpc_chttp2_transport* transport, + grpc_chttp2_stream* stream, uint32_t frame_size, + uint32_t flags); + + void Orphan() override; + + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; + grpc_error* Pull(grpc_slice* slice) override; + void Shutdown(grpc_error* error) override; + + // TODO(roth): When I converted this class to C++, I wanted to make it + // inherit from RefCounted or InternallyRefCounted instead of continuing + // to use its own custom ref-counting code. However, that would require + // using multiple inheritence, which sucks in general. And to make matters + // worse, it causes problems with our New<> and Delete<> wrappers. + // Specifically, unless RefCounted is first in the list of parent classes, + // it will see a different value of the address of the object than the one + // we actually allocated, in which case gpr_free() will be called on a + // different address than the one we got from gpr_malloc(), thus causing a + // crash. Given the fragility of depending on that, as well as a desire to + // avoid multiple inheritence in general, I've decided to leave this + // alone for now. We can revisit this once we're able to link against + // libc++, at which point we can eliminate New<> and Delete<> and + // switch to std::shared_ptr<>. + void Ref(); + void Unref(); + + void PublishError(grpc_error* error); + + grpc_error* Push(grpc_slice slice, grpc_slice* slice_out); - grpc_chttp2_transport* transport; /* immutable */ - grpc_chttp2_stream* stream; /* immutable */ + grpc_error* Finished(grpc_error* error, bool reset_on_error); + + uint32_t remaining_bytes() const { return remaining_bytes_; } + + private: + static void NextLocked(void* arg, grpc_error* error_ignored); + static void OrphanLocked(void* arg, grpc_error* error_ignored); + + grpc_chttp2_transport* transport_; // Immutable. + grpc_chttp2_stream* stream_; // Immutable. + + gpr_refcount refs_; /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == * true */ - uint32_t remaining_bytes; + uint32_t remaining_bytes_; /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == @@ -223,11 +263,12 @@ struct grpc_chttp2_incoming_byte_stream { grpc_closure closure; size_t max_size_hint; grpc_closure* on_complete; - } next_action; - grpc_closure destroy_action; - grpc_closure finished_action; + } next_action_; + grpc_closure destroy_action_; }; +} // namespace grpc_core + typedef enum { GRPC_CHTTP2_KEEPALIVE_STATE_WAITING, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING, @@ -456,7 +497,7 @@ struct grpc_chttp2_stream { grpc_metadata_batch* send_trailing_metadata; grpc_closure* send_trailing_metadata_finished; - grpc_byte_stream* fetching_send_message; + grpc_core::OrphanablePtr fetching_send_message; uint32_t fetched_send_message_length; grpc_slice fetching_slice; int64_t next_message_end_offset; @@ -468,7 +509,7 @@ struct grpc_chttp2_stream { grpc_metadata_batch* recv_initial_metadata; grpc_closure* recv_initial_metadata_ready; bool* trailing_metadata_available; - grpc_byte_stream** recv_message; + grpc_core::OrphanablePtr* recv_message; grpc_closure* recv_message_ready; grpc_metadata_batch* recv_trailing_metadata; grpc_closure* recv_trailing_metadata_finished; @@ -719,18 +760,6 @@ void grpc_chttp2_unref_transport(grpc_chttp2_transport* t); void grpc_chttp2_ref_transport(grpc_chttp2_transport* t); #endif -grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create( - grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size, - uint32_t flags); -grpc_error* grpc_chttp2_incoming_byte_stream_push( - grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice, - grpc_slice* slice_out); -grpc_error* grpc_chttp2_incoming_byte_stream_finished( - grpc_chttp2_incoming_byte_stream* bs, grpc_error* error, - bool reset_on_error); -void grpc_chttp2_incoming_byte_stream_notify( - grpc_chttp2_incoming_byte_stream* bs, grpc_error* error); - void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id); /** Add a new ping strike to ping_recv_state.ping_strikes. If diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index ff1c1aad62..8e3ea05706 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -31,6 +31,7 @@ #include "src/core/ext/transport/cronet/transport/cronet_transport.h" #include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" @@ -122,7 +123,7 @@ struct read_state { bool read_stream_closed; /* vars for holding data destined for the application */ - struct grpc_slice_buffer_stream sbs; + grpc_core::ManualConstructor sbs; grpc_slice_buffer read_slice_buffer; /* vars for trailing metadata */ @@ -1041,16 +1042,14 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { grpc_slice_buffer write_slice_buffer; grpc_slice slice; grpc_slice_buffer_init(&write_slice_buffer); - if (1 != grpc_byte_stream_next( - stream_op->payload->send_message.send_message, - stream_op->payload->send_message.send_message->length, + if (1 != stream_op->payload->send_message.send_message->Next( + stream_op->payload->send_message.send_message->length(), nullptr)) { /* Should never reach here */ GPR_ASSERT(false); } if (GRPC_ERROR_NONE != - grpc_byte_stream_pull(stream_op->payload->send_message.send_message, - &slice)) { + stream_op->payload->send_message.send_message->Pull(&slice)) { /* Should never reach here */ GPR_ASSERT(false); } @@ -1062,9 +1061,10 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { } if (write_slice_buffer.count > 0) { size_t write_buffer_size; - create_grpc_frame(&write_slice_buffer, &stream_state->ws.write_buffer, - &write_buffer_size, - stream_op->payload->send_message.send_message->flags); + create_grpc_frame( + &write_slice_buffer, &stream_state->ws.write_buffer, + &write_buffer_size, + stream_op->payload->send_message.send_message->flags()); CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, %p)", s->cbs, stream_state->ws.write_buffer); stream_state->state_callback_received[OP_SEND_MESSAGE] = false; @@ -1089,6 +1089,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { } stream_state->state_op_done[OP_SEND_MESSAGE] = true; oas->state.state_op_done[OP_SEND_MESSAGE] = true; + stream_op->payload->send_message.send_message.reset(); } else if (stream_op->send_trailing_metadata && op_can_be_run(stream_op, s, &oas->state, OP_SEND_TRAILING_METADATA)) { @@ -1195,14 +1196,13 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { grpc_slice_buffer_destroy_internal( &stream_state->rs.read_slice_buffer); grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer); - grpc_slice_buffer_stream_init(&stream_state->rs.sbs, - &stream_state->rs.read_slice_buffer, 0); + uint32_t flags = 0; if (stream_state->rs.compressed) { - stream_state->rs.sbs.base.flags |= GRPC_WRITE_INTERNAL_COMPRESS; + flags |= GRPC_WRITE_INTERNAL_COMPRESS; } - *(reinterpret_cast( - stream_op->payload->recv_message.recv_message)) = - reinterpret_cast(&stream_state->rs.sbs); + stream_state->rs.sbs.Init(&stream_state->rs.read_slice_buffer, flags); + stream_op->payload->recv_message.recv_message->reset( + stream_state->rs.sbs.get()); GRPC_CLOSURE_SCHED( stream_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); @@ -1252,14 +1252,13 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer); grpc_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); - grpc_slice_buffer_stream_init(&stream_state->rs.sbs, - &stream_state->rs.read_slice_buffer, 0); + uint32_t flags = 0; if (stream_state->rs.compressed) { - stream_state->rs.sbs.base.flags = GRPC_WRITE_INTERNAL_COMPRESS; + flags = GRPC_WRITE_INTERNAL_COMPRESS; } - *(reinterpret_cast( - stream_op->payload->recv_message.recv_message)) = - reinterpret_cast(&stream_state->rs.sbs); + stream_state->rs.sbs.Init(&stream_state->rs.read_slice_buffer, flags); + stream_op->payload->recv_message.recv_message->reset( + stream_state->rs.sbs.get()); GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 5f898bbf25..67a380077b 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -25,6 +25,7 @@ #include #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/channel.h" @@ -99,7 +100,7 @@ typedef struct inproc_stream { grpc_transport_stream_op_batch* recv_trailing_md_op; grpc_slice_buffer recv_message; - grpc_slice_buffer_stream recv_stream; + grpc_core::ManualConstructor recv_stream; bool recv_inited; bool initial_md_sent; @@ -482,8 +483,7 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) { s->recv_message_op = nullptr; } if (s->send_message_op) { - grpc_byte_stream_destroy( - s->send_message_op->payload->send_message.send_message); + s->send_message_op->payload->send_message.send_message.reset(); complete_if_batch_end_locked( s, error, s->send_message_op, "fail_helper scheduling send-message-on-complete"); @@ -521,7 +521,7 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) { static void message_transfer_locked(inproc_stream* sender, inproc_stream* receiver) { size_t remaining = - sender->send_message_op->payload->send_message.send_message->length; + sender->send_message_op->payload->send_message.send_message->length(); if (receiver->recv_inited) { grpc_slice_buffer_destroy_internal(&receiver->recv_message); } @@ -530,12 +530,12 @@ static void message_transfer_locked(inproc_stream* sender, do { grpc_slice message_slice; grpc_closure unused; - GPR_ASSERT(grpc_byte_stream_next( - sender->send_message_op->payload->send_message.send_message, SIZE_MAX, - &unused)); - grpc_error* error = grpc_byte_stream_pull( - sender->send_message_op->payload->send_message.send_message, - &message_slice); + GPR_ASSERT( + sender->send_message_op->payload->send_message.send_message->Next( + SIZE_MAX, &unused)); + grpc_error* error = + sender->send_message_op->payload->send_message.send_message->Pull( + &message_slice); if (error != GRPC_ERROR_NONE) { cancel_stream_locked(sender, GRPC_ERROR_REF(error)); break; @@ -544,13 +544,11 @@ static void message_transfer_locked(inproc_stream* sender, remaining -= GRPC_SLICE_LENGTH(message_slice); grpc_slice_buffer_add(&receiver->recv_message, message_slice); } while (remaining > 0); - grpc_byte_stream_destroy( - sender->send_message_op->payload->send_message.send_message); + sender->send_message_op->payload->send_message.send_message.reset(); - grpc_slice_buffer_stream_init(&receiver->recv_stream, &receiver->recv_message, - 0); - *receiver->recv_message_op->payload->recv_message.recv_message = - &receiver->recv_stream.base; + receiver->recv_stream.Init(&receiver->recv_message, 0); + receiver->recv_message_op->payload->recv_message.recv_message->reset( + receiver->recv_stream.get()); INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready", receiver); GRPC_CLOSURE_SCHED( @@ -606,8 +604,7 @@ static void op_state_machine(void* arg, grpc_error* error) { (s->trailing_md_sent || other->recv_trailing_md_op)) { // A server send will never be matched if the client is waiting // for trailing metadata already - grpc_byte_stream_destroy( - s->send_message_op->payload->send_message.send_message); + s->send_message_op->payload->send_message.send_message.reset(); complete_if_batch_end_locked( s, GRPC_ERROR_NONE, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); @@ -744,8 +741,7 @@ static void op_state_machine(void* arg, grpc_error* error) { if ((s->trailing_md_sent || s->t->is_client) && s->send_message_op) { // Nothing further will try to receive from this stream, so finish off // any outstanding send_message op - grpc_byte_stream_destroy( - s->send_message_op->payload->send_message.send_message); + s->send_message_op->payload->send_message.send_message.reset(); complete_if_batch_end_locked( s, new_err, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); @@ -803,8 +799,7 @@ static void op_state_machine(void* arg, grpc_error* error) { s->send_message_op) { // Nothing further will try to receive from this stream, so finish off // any outstanding send_message op - grpc_byte_stream_destroy( - s->send_message_op->payload->send_message.send_message); + s->send_message_op->payload->send_message.send_message.reset(); complete_if_batch_end_locked( s, new_err, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index c4844da318..adb6ee5a06 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -37,6 +37,7 @@ #include "src/core/lib/gpr/arena.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" @@ -221,9 +222,9 @@ struct grpc_call { int send_extra_metadata_count; grpc_millis send_deadline; - grpc_slice_buffer_stream sending_stream; + grpc_core::ManualConstructor sending_stream; - grpc_byte_stream* receiving_stream; + grpc_core::OrphanablePtr receiving_stream; grpc_byte_buffer** receiving_buffer; grpc_slice receiving_slice; grpc_closure receiving_slice_ready; @@ -522,9 +523,7 @@ static void destroy_call(void* call, grpc_error* error) { grpc_metadata_batch_destroy( &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]); } - if (c->receiving_stream != nullptr) { - grpc_byte_stream_destroy(c->receiving_stream); - } + c->receiving_stream.reset(); parent_call* pc = get_parent_call(c); if (pc != nullptr) { gpr_mu_destroy(&pc->child_list_mu); @@ -1281,25 +1280,21 @@ static void continue_receiving_slices(batch_control* bctl) { grpc_error* error; grpc_call* call = bctl->call; for (;;) { - size_t remaining = call->receiving_stream->length - + size_t remaining = call->receiving_stream->length() - (*call->receiving_buffer)->data.raw.slice_buffer.length; if (remaining == 0) { call->receiving_message = 0; - grpc_byte_stream_destroy(call->receiving_stream); - call->receiving_stream = nullptr; + call->receiving_stream.reset(); finish_batch_step(bctl); return; } - if (grpc_byte_stream_next(call->receiving_stream, remaining, - &call->receiving_slice_ready)) { - error = - grpc_byte_stream_pull(call->receiving_stream, &call->receiving_slice); + if (call->receiving_stream->Next(remaining, &call->receiving_slice_ready)) { + error = call->receiving_stream->Pull(&call->receiving_slice); if (error == GRPC_ERROR_NONE) { grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, call->receiving_slice); } else { - grpc_byte_stream_destroy(call->receiving_stream); - call->receiving_stream = nullptr; + call->receiving_stream.reset(); grpc_byte_buffer_destroy(*call->receiving_buffer); *call->receiving_buffer = nullptr; call->receiving_message = 0; @@ -1315,19 +1310,17 @@ static void continue_receiving_slices(batch_control* bctl) { static void receiving_slice_ready(void* bctlp, grpc_error* error) { batch_control* bctl = static_cast(bctlp); grpc_call* call = bctl->call; - grpc_byte_stream* bs = call->receiving_stream; bool release_error = false; if (error == GRPC_ERROR_NONE) { grpc_slice slice; - error = grpc_byte_stream_pull(bs, &slice); + error = call->receiving_stream->Pull(&slice); if (error == GRPC_ERROR_NONE) { grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, slice); continue_receiving_slices(bctl); } else { - /* Error returned by grpc_byte_stream_pull needs to be released manually - */ + /* Error returned by ByteStream::Pull() needs to be released manually */ release_error = true; } } @@ -1336,8 +1329,7 @@ static void receiving_slice_ready(void* bctlp, grpc_error* error) { if (grpc_trace_operation_failures.enabled()) { GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error)); } - grpc_byte_stream_destroy(call->receiving_stream); - call->receiving_stream = nullptr; + call->receiving_stream.reset(); grpc_byte_buffer_destroy(*call->receiving_buffer); *call->receiving_buffer = nullptr; call->receiving_message = 0; @@ -1355,8 +1347,8 @@ static void process_data_after_md(batch_control* bctl) { call->receiving_message = 0; finish_batch_step(bctl); } else { - call->test_only_last_message_flags = call->receiving_stream->flags; - if ((call->receiving_stream->flags & GRPC_WRITE_INTERNAL_COMPRESS) && + call->test_only_last_message_flags = call->receiving_stream->flags(); + if ((call->receiving_stream->flags() & GRPC_WRITE_INTERNAL_COMPRESS) && (call->incoming_message_compression_algorithm > GRPC_MESSAGE_COMPRESS_NONE)) { grpc_compression_algorithm algo; @@ -1379,10 +1371,7 @@ static void receiving_stream_ready(void* bctlp, grpc_error* error) { batch_control* bctl = static_cast(bctlp); grpc_call* call = bctl->call; if (error != GRPC_ERROR_NONE) { - if (call->receiving_stream != nullptr) { - grpc_byte_stream_destroy(call->receiving_stream); - call->receiving_stream = nullptr; - } + call->receiving_stream.reset(); add_batch_error(bctl, GRPC_ERROR_REF(error), true); cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error)); } @@ -1676,21 +1665,20 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; goto done_with_error; } - stream_op->send_message = true; - call->sending_message = true; - grpc_slice_buffer_stream_init( - &call->sending_stream, - &op->data.send_message.send_message->data.raw.slice_buffer, - op->flags); + uint32_t flags = op->flags; /* If the outgoing buffer is already compressed, mark it as so in the flags. These will be picked up by the compression filter and further (wasteful) attempts at compression skipped. */ if (op->data.send_message.send_message->data.raw.compression > GRPC_COMPRESS_NONE) { - call->sending_stream.base.flags |= GRPC_WRITE_INTERNAL_COMPRESS; + flags |= GRPC_WRITE_INTERNAL_COMPRESS; } - stream_op_payload->send_message.send_message = - &call->sending_stream.base; + stream_op->send_message = true; + call->sending_message = true; + call->sending_stream.Init( + &op->data.send_message.send_message->data.raw.slice_buffer, flags); + stream_op_payload->send_message.send_message.reset( + call->sending_stream.get()); break; } case GRPC_OP_SEND_CLOSE_FROM_CLIENT: { @@ -1909,7 +1897,7 @@ done_with_error: } if (stream_op->send_message) { call->sending_message = false; - grpc_byte_stream_destroy(&call->sending_stream.base); + call->sending_stream->Orphan(); } if (stream_op->send_trailing_metadata) { call->sent_final_op = false; diff --git a/src/core/lib/transport/byte_stream.cc b/src/core/lib/transport/byte_stream.cc index e1751f8010..1aaf40fb99 100644 --- a/src/core/lib/transport/byte_stream.cc +++ b/src/core/lib/transport/byte_stream.cc @@ -25,160 +25,123 @@ #include +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/slice/slice_internal.h" -bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint, - grpc_closure* on_complete) { - return byte_stream->vtable->next(byte_stream, max_size_hint, on_complete); -} +namespace grpc_core { -grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream, - grpc_slice* slice) { - return byte_stream->vtable->pull(byte_stream, slice); -} +// +// SliceBufferByteStream +// -void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream, - grpc_error* error) { - byte_stream->vtable->shutdown(byte_stream, error); +SliceBufferByteStream::SliceBufferByteStream(grpc_slice_buffer* slice_buffer, + uint32_t flags) + : ByteStream(static_cast(slice_buffer->length), flags) { + GPR_ASSERT(slice_buffer->length <= UINT32_MAX); + grpc_slice_buffer_init(&backing_buffer_); + grpc_slice_buffer_swap(slice_buffer, &backing_buffer_); } -void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream) { - byte_stream->vtable->destroy(byte_stream); -} +SliceBufferByteStream::~SliceBufferByteStream() {} -// grpc_slice_buffer_stream +void SliceBufferByteStream::Orphan() { + grpc_slice_buffer_destroy(&backing_buffer_); + GRPC_ERROR_UNREF(shutdown_error_); + // Note: We do not actually delete the object here, since + // SliceBufferByteStream is usually allocated as part of a larger + // object and has an OrphanablePtr of itself passed down through the + // filter stack. +} -static bool slice_buffer_stream_next(grpc_byte_stream* byte_stream, - size_t max_size_hint, - grpc_closure* on_complete) { - grpc_slice_buffer_stream* stream = - reinterpret_cast(byte_stream); - GPR_ASSERT(stream->cursor < stream->backing_buffer.count); +bool SliceBufferByteStream::Next(size_t max_size_hint, + grpc_closure* on_complete) { + GPR_ASSERT(cursor_ < backing_buffer_.count); return true; } -static grpc_error* slice_buffer_stream_pull(grpc_byte_stream* byte_stream, - grpc_slice* slice) { - grpc_slice_buffer_stream* stream = - reinterpret_cast(byte_stream); - if (stream->shutdown_error != GRPC_ERROR_NONE) { - return GRPC_ERROR_REF(stream->shutdown_error); +grpc_error* SliceBufferByteStream::Pull(grpc_slice* slice) { + if (shutdown_error_ != GRPC_ERROR_NONE) { + return GRPC_ERROR_REF(shutdown_error_); } - GPR_ASSERT(stream->cursor < stream->backing_buffer.count); - *slice = - grpc_slice_ref_internal(stream->backing_buffer.slices[stream->cursor]); - stream->cursor++; + GPR_ASSERT(cursor_ < backing_buffer_.count); + *slice = grpc_slice_ref_internal(backing_buffer_.slices[cursor_]); + ++cursor_; return GRPC_ERROR_NONE; } -static void slice_buffer_stream_shutdown(grpc_byte_stream* byte_stream, - grpc_error* error) { - grpc_slice_buffer_stream* stream = - reinterpret_cast(byte_stream); - GRPC_ERROR_UNREF(stream->shutdown_error); - stream->shutdown_error = error; +void SliceBufferByteStream::Shutdown(grpc_error* error) { + GRPC_ERROR_UNREF(shutdown_error_); + shutdown_error_ = error; } -static void slice_buffer_stream_destroy(grpc_byte_stream* byte_stream) { - grpc_slice_buffer_stream* stream = - reinterpret_cast(byte_stream); - grpc_slice_buffer_destroy(&stream->backing_buffer); - GRPC_ERROR_UNREF(stream->shutdown_error); +// +// ByteStreamCache +// + +ByteStreamCache::ByteStreamCache(OrphanablePtr underlying_stream) + : underlying_stream_(std::move(underlying_stream)) { + grpc_slice_buffer_init(&cache_buffer_); } -static const grpc_byte_stream_vtable slice_buffer_stream_vtable = { - slice_buffer_stream_next, slice_buffer_stream_pull, - slice_buffer_stream_shutdown, slice_buffer_stream_destroy}; +ByteStreamCache::~ByteStreamCache() { + if (underlying_stream_ != nullptr) Destroy(); +} -void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream* stream, - grpc_slice_buffer* slice_buffer, - uint32_t flags) { - GPR_ASSERT(slice_buffer->length <= UINT32_MAX); - stream->base.length = static_cast(slice_buffer->length); - stream->base.flags = flags; - stream->base.vtable = &slice_buffer_stream_vtable; - grpc_slice_buffer_init(&stream->backing_buffer); - grpc_slice_buffer_swap(slice_buffer, &stream->backing_buffer); - stream->cursor = 0; - stream->shutdown_error = GRPC_ERROR_NONE; +void ByteStreamCache::Destroy() { + underlying_stream_.reset(); + grpc_slice_buffer_destroy_internal(&cache_buffer_); } -// grpc_caching_byte_stream +// +// ByteStreamCache::CachingByteStream +// -void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache, - grpc_byte_stream* underlying_stream) { - cache->underlying_stream = underlying_stream; - grpc_slice_buffer_init(&cache->cache_buffer); -} +ByteStreamCache::CachingByteStream::CachingByteStream(ByteStreamCache* cache) + : ByteStream(cache->underlying_stream_->length(), + cache->underlying_stream_->flags()), + cache_(cache) {} -void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache) { - grpc_byte_stream_destroy(cache->underlying_stream); - grpc_slice_buffer_destroy_internal(&cache->cache_buffer); +ByteStreamCache::CachingByteStream::~CachingByteStream() {} + +void ByteStreamCache::CachingByteStream::Orphan() { + GRPC_ERROR_UNREF(shutdown_error_); + // Note: We do not actually delete the object here, since + // CachingByteStream is usually allocated as part of a larger + // object and has an OrphanablePtr of itself passed down through the + // filter stack. } -static bool caching_byte_stream_next(grpc_byte_stream* byte_stream, - size_t max_size_hint, - grpc_closure* on_complete) { - grpc_caching_byte_stream* stream = - reinterpret_cast(byte_stream); - if (stream->shutdown_error != GRPC_ERROR_NONE) return true; - if (stream->cursor < stream->cache->cache_buffer.count) return true; - return grpc_byte_stream_next(stream->cache->underlying_stream, max_size_hint, - on_complete); +bool ByteStreamCache::CachingByteStream::Next(size_t max_size_hint, + grpc_closure* on_complete) { + if (shutdown_error_ != GRPC_ERROR_NONE) return true; + if (cursor_ < cache_->cache_buffer_.count) return true; + return cache_->underlying_stream_->Next(max_size_hint, on_complete); } -static grpc_error* caching_byte_stream_pull(grpc_byte_stream* byte_stream, - grpc_slice* slice) { - grpc_caching_byte_stream* stream = - reinterpret_cast(byte_stream); - if (stream->shutdown_error != GRPC_ERROR_NONE) { - return GRPC_ERROR_REF(stream->shutdown_error); +grpc_error* ByteStreamCache::CachingByteStream::Pull(grpc_slice* slice) { + if (shutdown_error_ != GRPC_ERROR_NONE) { + return GRPC_ERROR_REF(shutdown_error_); } - if (stream->cursor < stream->cache->cache_buffer.count) { - *slice = grpc_slice_ref_internal( - stream->cache->cache_buffer.slices[stream->cursor]); - ++stream->cursor; + if (cursor_ < cache_->cache_buffer_.count) { + *slice = grpc_slice_ref_internal(cache_->cache_buffer_.slices[cursor_]); + ++cursor_; return GRPC_ERROR_NONE; } - grpc_error* error = - grpc_byte_stream_pull(stream->cache->underlying_stream, slice); + grpc_error* error = cache_->underlying_stream_->Pull(slice); if (error == GRPC_ERROR_NONE) { - ++stream->cursor; - grpc_slice_buffer_add(&stream->cache->cache_buffer, + ++cursor_; + grpc_slice_buffer_add(&cache_->cache_buffer_, grpc_slice_ref_internal(*slice)); } return error; } -static void caching_byte_stream_shutdown(grpc_byte_stream* byte_stream, - grpc_error* error) { - grpc_caching_byte_stream* stream = - reinterpret_cast(byte_stream); - GRPC_ERROR_UNREF(stream->shutdown_error); - stream->shutdown_error = GRPC_ERROR_REF(error); - grpc_byte_stream_shutdown(stream->cache->underlying_stream, error); +void ByteStreamCache::CachingByteStream::Shutdown(grpc_error* error) { + GRPC_ERROR_UNREF(shutdown_error_); + shutdown_error_ = GRPC_ERROR_REF(error); + cache_->underlying_stream_->Shutdown(error); } -static void caching_byte_stream_destroy(grpc_byte_stream* byte_stream) { - grpc_caching_byte_stream* stream = - reinterpret_cast(byte_stream); - GRPC_ERROR_UNREF(stream->shutdown_error); -} +void ByteStreamCache::CachingByteStream::Reset() { cursor_ = 0; } -static const grpc_byte_stream_vtable caching_byte_stream_vtable = { - caching_byte_stream_next, caching_byte_stream_pull, - caching_byte_stream_shutdown, caching_byte_stream_destroy}; - -void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream, - grpc_byte_stream_cache* cache) { - memset(stream, 0, sizeof(*stream)); - stream->base.length = cache->underlying_stream->length; - stream->base.flags = cache->underlying_stream->flags; - stream->base.vtable = &caching_byte_stream_vtable; - stream->cache = cache; - stream->shutdown_error = GRPC_ERROR_NONE; -} - -void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream) { - stream->cursor = 0; -} +} // namespace grpc_core diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index 4d3c3c131b..f8243ac40d 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -22,6 +22,8 @@ #include #include +#include "src/core/lib/gprpp/abstract.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/exec_ctx.h" /** Internal bit flag for grpc_begin_message's \a flags signaling the use of @@ -30,71 +32,82 @@ /** Mask of all valid internal flags. */ #define GRPC_WRITE_INTERNAL_USED_MASK (GRPC_WRITE_INTERNAL_COMPRESS) -typedef struct grpc_byte_stream grpc_byte_stream; - -typedef struct { - bool (*next)(grpc_byte_stream* byte_stream, size_t max_size_hint, - grpc_closure* on_complete); - grpc_error* (*pull)(grpc_byte_stream* byte_stream, grpc_slice* slice); - void (*shutdown)(grpc_byte_stream* byte_stream, grpc_error* error); - void (*destroy)(grpc_byte_stream* byte_stream); -} grpc_byte_stream_vtable; - -struct grpc_byte_stream { - uint32_t length; - uint32_t flags; - const grpc_byte_stream_vtable* vtable; +namespace grpc_core { + +class ByteStream : public Orphanable { + public: + virtual ~ByteStream() {} + + // Returns true if the bytes are available immediately (in which case + // on_complete will not be called), or false if the bytes will be available + // asynchronously (in which case on_complete will be called when they + // are available). + // + // max_size_hint can be set as a hint as to the maximum number + // of bytes that would be acceptable to read. + virtual bool Next(size_t max_size_hint, + grpc_closure* on_complete) GRPC_ABSTRACT; + + // Returns the next slice in the byte stream when it is available, as + // indicated by Next(). + // + // Once a slice is returned into *slice, it is owned by the caller. + virtual grpc_error* Pull(grpc_slice* slice) GRPC_ABSTRACT; + + // Shuts down the byte stream. + // + // If there is a pending call to on_complete from Next(), it will be + // invoked with the error passed to Shutdown(). + // + // The next call to Pull() (if any) will return the error passed to + // Shutdown(). + virtual void Shutdown(grpc_error* error) GRPC_ABSTRACT; + + uint32_t length() const { return length_; } + uint32_t flags() const { return flags_; } + + void set_flags(uint32_t flags) { flags_ = flags; } + + GRPC_ABSTRACT_BASE_CLASS + + protected: + ByteStream(uint32_t length, uint32_t flags) + : length_(length), flags_(flags) {} + + private: + const uint32_t length_; + uint32_t flags_; }; -// Returns true if the bytes are available immediately (in which case -// on_complete will not be called), false if the bytes will be available -// asynchronously. // -// max_size_hint can be set as a hint as to the maximum number -// of bytes that would be acceptable to read. -bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint, - grpc_closure* on_complete); - -// Returns the next slice in the byte stream when it is ready (indicated by -// either grpc_byte_stream_next returning true or on_complete passed to -// grpc_byte_stream_next is called). +// SliceBufferByteStream // -// Once a slice is returned into *slice, it is owned by the caller. -grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream, - grpc_slice* slice); - -// Shuts down the byte stream. +// A ByteStream that wraps a slice buffer. // -// If there is a pending call to on_complete from grpc_byte_stream_next(), -// it will be invoked with the error passed to grpc_byte_stream_shutdown(). -// -// The next call to grpc_byte_stream_pull() (if any) will return the error -// passed to grpc_byte_stream_shutdown(). -void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream, - grpc_error* error); -void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream); +class SliceBufferByteStream : public ByteStream { + public: + // Removes all slices in slice_buffer, leaving it empty. + SliceBufferByteStream(grpc_slice_buffer* slice_buffer, uint32_t flags); + + ~SliceBufferByteStream(); + + void Orphan() override; + + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; + grpc_error* Pull(grpc_slice* slice) override; + void Shutdown(grpc_error* error) override; + + private: + grpc_slice_buffer backing_buffer_; + size_t cursor_ = 0; + grpc_error* shutdown_error_ = GRPC_ERROR_NONE; +}; -// grpc_slice_buffer_stream // -// A grpc_byte_stream that wraps a slice buffer. The stream takes -// ownership of the slices in the buffer, and on destruction will -// reset the contents of the buffer. - -typedef struct grpc_slice_buffer_stream { - grpc_byte_stream base; - grpc_slice_buffer backing_buffer; - size_t cursor; - grpc_error* shutdown_error; -} grpc_slice_buffer_stream; - -void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream* stream, - grpc_slice_buffer* slice_buffer, - uint32_t flags); - -// grpc_caching_byte_stream +// CachingByteStream // -// A grpc_byte_stream that that wraps an underlying byte stream but caches +// A ByteStream that that wraps an underlying byte stream but caches // the resulting slices in a slice buffer. If an initial attempt fails // without fully draining the underlying stream, a new caching stream // can be created from the same underlying cache, in which case it will @@ -102,32 +115,47 @@ void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream* stream, // underlying stream. // // NOTE: No synchronization is done, so it is not safe to have multiple -// grpc_caching_byte_streams simultaneously drawing from the same underlying -// grpc_byte_stream_cache at the same time. +// CachingByteStreams simultaneously drawing from the same underlying +// ByteStreamCache at the same time. +// + +class ByteStreamCache { + public: + class CachingByteStream : public ByteStream { + public: + explicit CachingByteStream(ByteStreamCache* cache); + + ~CachingByteStream(); + + void Orphan() override; -typedef struct { - grpc_byte_stream* underlying_stream; - grpc_slice_buffer cache_buffer; -} grpc_byte_stream_cache; + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; + grpc_error* Pull(grpc_slice* slice) override; + void Shutdown(grpc_error* error) override; -// Takes ownership of underlying_stream. -void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache, - grpc_byte_stream* underlying_stream); + // Resets the byte stream to the start of the underlying stream. + void Reset(); -// Must not be called while still in use by a grpc_caching_byte_stream. -void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache); + private: + ByteStreamCache* cache_; + size_t cursor_ = 0; + grpc_error* shutdown_error_ = GRPC_ERROR_NONE; + }; -typedef struct { - grpc_byte_stream base; - grpc_byte_stream_cache* cache; - size_t cursor; - grpc_error* shutdown_error; -} grpc_caching_byte_stream; + explicit ByteStreamCache(OrphanablePtr underlying_stream); -void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream, - grpc_byte_stream_cache* cache); + ~ByteStreamCache(); + + // Must not be destroyed while still in use by a CachingByteStream. + void Destroy(); + + grpc_slice_buffer* cache_buffer() { return &cache_buffer_; } + + private: + OrphanablePtr underlying_stream_; + grpc_slice_buffer cache_buffer_; +}; -// Resets the byte stream to the start of the underlying stream. -void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream); +} // namespace grpc_core #endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index c90d16fc32..6b41e4b37e 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -209,7 +209,7 @@ void grpc_transport_stream_op_batch_finish_with_failure( grpc_transport_stream_op_batch* batch, grpc_error* error, grpc_call_combiner* call_combiner) { if (batch->send_message) { - grpc_byte_stream_destroy(batch->payload->send_message.send_message); + batch->payload->send_message.send_message.reset(); } if (batch->recv_message) { GRPC_CALL_COMBINER_START( diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 37e50344c4..10e9df0f7c 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -184,11 +184,10 @@ struct grpc_transport_stream_op_batch_payload { struct { // The transport (or a filter that decides to return a failure before - // the op gets down to the transport) is responsible for calling - // grpc_byte_stream_destroy() on this. + // the op gets down to the transport) takes ownership. // The batch's on_complete will not be called until after the byte - // stream is destroyed. - grpc_byte_stream* send_message; + // stream is orphaned. + grpc_core::OrphanablePtr send_message; } send_message; struct { @@ -216,10 +215,8 @@ struct grpc_transport_stream_op_batch_payload { struct { // Will be set by the transport to point to the byte stream // containing a received message. - // The caller is responsible for calling grpc_byte_stream_destroy() - // on this byte stream. // Will be NULL if trailing metadata is received instead of a message. - grpc_byte_stream** recv_message; + grpc_core::OrphanablePtr* recv_message; /** Should be enqueued when one message is ready to be processed. */ grpc_closure* recv_message_ready; } recv_message; diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index 6898da17ed..99af7c1931 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -75,9 +75,16 @@ char* grpc_transport_stream_op_batch_string( if (op->send_message) { gpr_strvec_add(&b, gpr_strdup(" ")); - gpr_asprintf(&tmp, "SEND_MESSAGE:flags=0x%08x:len=%d", - op->payload->send_message.send_message->flags, - op->payload->send_message.send_message->length); + if (op->payload->send_message.send_message != nullptr) { + gpr_asprintf(&tmp, "SEND_MESSAGE:flags=0x%08x:len=%d", + op->payload->send_message.send_message->flags(), + op->payload->send_message.send_message->length()); + } else { + // This can happen when we check a batch after the transport has + // processed and cleared the send_message op. + tmp = + gpr_strdup("SEND_MESSAGE(flag and length unknown, already orphaned)"); + } gpr_strvec_add(&b, tmp); } diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h index 60eefcb0d1..bd0ec969b4 100644 --- a/src/cpp/common/channel_filter.h +++ b/src/cpp/common/channel_filter.h @@ -182,20 +182,22 @@ class TransportStreamOpBatch { op_->payload->recv_initial_metadata.recv_initial_metadata_ready = closure; } - grpc_byte_stream* send_message() const { - return op_->send_message ? op_->payload->send_message.send_message + grpc_core::OrphanablePtr* send_message() const { + return op_->send_message ? &op_->payload->send_message.send_message : nullptr; } - void set_send_message(grpc_byte_stream* send_message) { + void set_send_message( + grpc_core::OrphanablePtr send_message) { op_->send_message = true; - op_->payload->send_message.send_message = send_message; + op_->payload->send_message.send_message = std::move(send_message); } - grpc_byte_stream** recv_message() const { + grpc_core::OrphanablePtr* recv_message() const { return op_->recv_message ? op_->payload->recv_message.recv_message : nullptr; } - void set_recv_message(grpc_byte_stream** recv_message) { + void set_recv_message( + grpc_core::OrphanablePtr* recv_message) { op_->recv_message = true; op_->payload->recv_message.recv_message = recv_message; } diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD index 2c2d05b9ae..84fb3a1421 100644 --- a/test/core/transport/BUILD +++ b/test/core/transport/BUILD @@ -43,6 +43,9 @@ grpc_cc_test( "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], + external_deps = [ + "gtest", + ], ) grpc_cc_test( diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index 6947d50976..80692ec2da 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -27,16 +27,18 @@ #include "test/core/util/test_config.h" +#include + +namespace grpc_core { +namespace { + // -// grpc_slice_buffer_stream tests +// SliceBufferByteStream tests // -static void not_called_closure(void* arg, grpc_error* error) { - GPR_ASSERT(false); -} +void NotCalledClosure(void* arg, grpc_error* error) { GPR_ASSERT(false); } -static void test_slice_buffer_stream_basic(void) { - gpr_log(GPR_DEBUG, "test_slice_buffer_stream_basic"); +TEST(SliceBufferByteStream, Basic) { grpc_core::ExecCtx exec_ctx; // Create and populate slice buffer. grpc_slice_buffer buffer; @@ -49,28 +51,26 @@ static void test_slice_buffer_stream_basic(void) { grpc_slice_buffer_add(&buffer, input[i]); } // Create byte stream. - grpc_slice_buffer_stream stream; - grpc_slice_buffer_stream_init(&stream, &buffer, 0); - GPR_ASSERT(stream.base.length == 6); + SliceBufferByteStream stream(&buffer, 0); + grpc_slice_buffer_destroy_internal(&buffer); + EXPECT_EQ(6U, stream.length()); grpc_closure closure; - GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr, + GRPC_CLOSURE_INIT(&closure, NotCalledClosure, nullptr, grpc_schedule_on_exec_ctx); - // Read each slice. Note that next() always returns synchronously. + // Read each slice. Note that Next() always returns synchronously. for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); grpc_slice output; - grpc_error* error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[i], output)); + grpc_error* error = stream.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(output); } // Clean up. - grpc_byte_stream_destroy(&stream.base); - grpc_slice_buffer_destroy_internal(&buffer); + stream.Orphan(); } -static void test_slice_buffer_stream_shutdown(void) { - gpr_log(GPR_DEBUG, "test_slice_buffer_stream_shutdown"); +TEST(SliceBufferByteStream, Shutdown) { grpc_core::ExecCtx exec_ctx; // Create and populate slice buffer. grpc_slice_buffer buffer; @@ -83,40 +83,38 @@ static void test_slice_buffer_stream_shutdown(void) { grpc_slice_buffer_add(&buffer, input[i]); } // Create byte stream. - grpc_slice_buffer_stream stream; - grpc_slice_buffer_stream_init(&stream, &buffer, 0); - GPR_ASSERT(stream.base.length == 6); + SliceBufferByteStream stream(&buffer, 0); + grpc_slice_buffer_destroy_internal(&buffer); + EXPECT_EQ(6U, stream.length()); grpc_closure closure; - GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr, + GRPC_CLOSURE_INIT(&closure, NotCalledClosure, nullptr, grpc_schedule_on_exec_ctx); // Read the first slice. - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); grpc_slice output; - grpc_error* error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[0], output)); + grpc_error* error = stream.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(output); // Now shutdown. grpc_error* shutdown_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown error"); - grpc_byte_stream_shutdown(&stream.base, GRPC_ERROR_REF(shutdown_error)); + stream.Shutdown(GRPC_ERROR_REF(shutdown_error)); // After shutdown, the next pull() should return the error. - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); - error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == shutdown_error); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); + error = stream.Pull(&output); + EXPECT_TRUE(error == shutdown_error); GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(shutdown_error); // Clean up. - grpc_byte_stream_destroy(&stream.base); - grpc_slice_buffer_destroy_internal(&buffer); + stream.Orphan(); } // -// grpc_caching_byte_stream tests +// CachingByteStream tests // -static void test_caching_byte_stream_basic(void) { - gpr_log(GPR_DEBUG, "test_caching_byte_stream_basic"); +TEST(CachingByteStream, Basic) { grpc_core::ExecCtx exec_ctx; // Create and populate slice buffer byte stream. grpc_slice_buffer buffer; @@ -128,34 +126,30 @@ static void test_caching_byte_stream_basic(void) { for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { grpc_slice_buffer_add(&buffer, input[i]); } - grpc_slice_buffer_stream underlying_stream; - grpc_slice_buffer_stream_init(&underlying_stream, &buffer, 0); + SliceBufferByteStream underlying_stream(&buffer, 0); + grpc_slice_buffer_destroy_internal(&buffer); // Create cache and caching stream. - grpc_byte_stream_cache cache; - grpc_byte_stream_cache_init(&cache, &underlying_stream.base); - grpc_caching_byte_stream stream; - grpc_caching_byte_stream_init(&stream, &cache); + ByteStreamCache cache((OrphanablePtr(&underlying_stream))); + ByteStreamCache::CachingByteStream stream(&cache); grpc_closure closure; - GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr, + GRPC_CLOSURE_INIT(&closure, NotCalledClosure, nullptr, grpc_schedule_on_exec_ctx); // Read each slice. Note that next() always returns synchronously, // because the underlying byte stream always does. for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); grpc_slice output; - grpc_error* error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[i], output)); + grpc_error* error = stream.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(output); } // Clean up. - grpc_byte_stream_destroy(&stream.base); - grpc_byte_stream_cache_destroy(&cache); - grpc_slice_buffer_destroy_internal(&buffer); + stream.Orphan(); + cache.Destroy(); } -static void test_caching_byte_stream_reset(void) { - gpr_log(GPR_DEBUG, "test_caching_byte_stream_reset"); +TEST(CachingByteStream, Reset) { grpc_core::ExecCtx exec_ctx; // Create and populate slice buffer byte stream. grpc_slice_buffer buffer; @@ -167,41 +161,37 @@ static void test_caching_byte_stream_reset(void) { for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { grpc_slice_buffer_add(&buffer, input[i]); } - grpc_slice_buffer_stream underlying_stream; - grpc_slice_buffer_stream_init(&underlying_stream, &buffer, 0); + SliceBufferByteStream underlying_stream(&buffer, 0); + grpc_slice_buffer_destroy_internal(&buffer); // Create cache and caching stream. - grpc_byte_stream_cache cache; - grpc_byte_stream_cache_init(&cache, &underlying_stream.base); - grpc_caching_byte_stream stream; - grpc_caching_byte_stream_init(&stream, &cache); + ByteStreamCache cache((OrphanablePtr(&underlying_stream))); + ByteStreamCache::CachingByteStream stream(&cache); grpc_closure closure; - GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr, + GRPC_CLOSURE_INIT(&closure, NotCalledClosure, nullptr, grpc_schedule_on_exec_ctx); // Read one slice. - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); grpc_slice output; - grpc_error* error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[0], output)); + grpc_error* error = stream.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(output); // Reset the caching stream. The reads should start over from the // first slice. - grpc_caching_byte_stream_reset(&stream); + stream.Reset(); for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { - GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure)); - error = grpc_byte_stream_pull(&stream.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[i], output)); + ASSERT_TRUE(stream.Next(~(size_t)0, &closure)); + error = stream.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(output); } // Clean up. - grpc_byte_stream_destroy(&stream.base); - grpc_byte_stream_cache_destroy(&cache); - grpc_slice_buffer_destroy_internal(&buffer); + stream.Orphan(); + cache.Destroy(); } -static void test_caching_byte_stream_shared_cache(void) { - gpr_log(GPR_DEBUG, "test_caching_byte_stream_shared_cache"); +TEST(CachingByteStream, SharedCache) { grpc_core::ExecCtx exec_ctx; // Create and populate slice buffer byte stream. grpc_slice_buffer buffer; @@ -213,54 +203,50 @@ static void test_caching_byte_stream_shared_cache(void) { for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { grpc_slice_buffer_add(&buffer, input[i]); } - grpc_slice_buffer_stream underlying_stream; - grpc_slice_buffer_stream_init(&underlying_stream, &buffer, 0); + SliceBufferByteStream underlying_stream(&buffer, 0); + grpc_slice_buffer_destroy_internal(&buffer); // Create cache and two caching streams. - grpc_byte_stream_cache cache; - grpc_byte_stream_cache_init(&cache, &underlying_stream.base); - grpc_caching_byte_stream stream1; - grpc_caching_byte_stream_init(&stream1, &cache); - grpc_caching_byte_stream stream2; - grpc_caching_byte_stream_init(&stream2, &cache); + ByteStreamCache cache((OrphanablePtr(&underlying_stream))); + ByteStreamCache::CachingByteStream stream1(&cache); + ByteStreamCache::CachingByteStream stream2(&cache); grpc_closure closure; - GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr, + GRPC_CLOSURE_INIT(&closure, NotCalledClosure, nullptr, grpc_schedule_on_exec_ctx); // Read one slice from stream1. - GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure)); + EXPECT_TRUE(stream1.Next(~(size_t)0, &closure)); grpc_slice output; - grpc_error* error = grpc_byte_stream_pull(&stream1.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[0], output)); + grpc_error* error = stream1.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[0], output)); grpc_slice_unref_internal(output); // Read all slices from stream2. for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) { - GPR_ASSERT(grpc_byte_stream_next(&stream2.base, ~(size_t)0, &closure)); - error = grpc_byte_stream_pull(&stream2.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[i], output)); + EXPECT_TRUE(stream2.Next(~(size_t)0, &closure)); + error = stream2.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[i], output)); grpc_slice_unref_internal(output); } // Now read the second slice from stream1. - GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure)); - error = grpc_byte_stream_pull(&stream1.base, &output); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(grpc_slice_eq(input[1], output)); + EXPECT_TRUE(stream1.Next(~(size_t)0, &closure)); + error = stream1.Pull(&output); + EXPECT_TRUE(error == GRPC_ERROR_NONE); + EXPECT_TRUE(grpc_slice_eq(input[1], output)); grpc_slice_unref_internal(output); // Clean up. - grpc_byte_stream_destroy(&stream1.base); - grpc_byte_stream_destroy(&stream2.base); - grpc_byte_stream_cache_destroy(&cache); - grpc_slice_buffer_destroy_internal(&buffer); + stream1.Orphan(); + stream2.Orphan(); + cache.Destroy(); } +} // namespace +} // namespace grpc_core + int main(int argc, char** argv) { grpc_init(); grpc_test_init(argc, argv); - test_slice_buffer_stream_basic(); - test_slice_buffer_stream_shutdown(); - test_caching_byte_stream_basic(); - test_caching_byte_stream_reset(); - test_caching_byte_stream_shared_cache(); + ::testing::InitGoogleTest(&argc, argv); + int retval = RUN_ALL_TESTS(); grpc_shutdown(); - return 0; + return retval; } diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index fcb1677d09..75e1e92d19 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -398,13 +398,13 @@ static void BM_TransportStreamSend(benchmark::State& state) { memset(&op, 0, sizeof(op)); op.payload = &op_payload; }; - grpc_slice_buffer_stream send_stream; - grpc_slice_buffer send_buffer; - grpc_slice_buffer_init(&send_buffer); - grpc_slice_buffer_add(&send_buffer, gpr_slice_malloc(state.range(0))); - memset(GRPC_SLICE_START_PTR(send_buffer.slices[0]), 0, - GRPC_SLICE_LENGTH(send_buffer.slices[0])); - + // Create the send_message payload slice. + // Note: We use grpc_slice_malloc_large() instead of grpc_slice_malloc() + // to force the slice to be refcounted, so that it remains alive when it + // is unreffed after each send_message op. + grpc_slice send_slice = grpc_slice_malloc_large(state.range(0)); + memset(GRPC_SLICE_START_PTR(send_slice), 0, GRPC_SLICE_LENGTH(send_slice)); + grpc_core::ManualConstructor send_stream; grpc_metadata_batch b; grpc_metadata_batch_init(&b); b.deadline = GRPC_MILLIS_INF_FUTURE; @@ -424,14 +424,18 @@ static void BM_TransportStreamSend(benchmark::State& state) { gpr_event_set(bm_done, (void*)1); return; } + grpc_slice_buffer send_buffer; + grpc_slice_buffer_init(&send_buffer); + grpc_slice_buffer_add(&send_buffer, grpc_slice_ref(send_slice)); + send_stream.Init(&send_buffer, 0); + grpc_slice_buffer_destroy(&send_buffer); // force outgoing window to be yuge s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow(); f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow(); - grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0); reset_op(); op.on_complete = c.get(); op.send_message = true; - op.payload->send_message.send_message = &send_stream.base; + op.payload->send_message.send_message.reset(send_stream.get()); s->Op(&op); }); @@ -454,7 +458,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { s.reset(); track_counters.Finish(state); grpc_metadata_batch_destroy(&b); - grpc_slice_buffer_destroy(&send_buffer); + grpc_slice_unref(send_slice); } BENCHMARK(BM_TransportStreamSend)->Range(0, 128 * 1024 * 1024); @@ -524,7 +528,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { grpc_transport_stream_op_batch_payload op_payload; memset(&op_payload, 0, sizeof(op_payload)); grpc_transport_stream_op_batch op; - grpc_byte_stream* recv_stream; + grpc_core::OrphanablePtr recv_stream; grpc_slice incoming_data = CreateIncomingDataSlice(state.range(0), 16384); auto reset_op = [&]() { @@ -579,21 +583,20 @@ static void BM_TransportStreamRecv(benchmark::State& state) { drain = MakeClosure([&](grpc_error* error) { do { - if (received == recv_stream->length) { - grpc_byte_stream_destroy(recv_stream); + if (received == recv_stream->length()) { + recv_stream.reset(); GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE); return; } - } while (grpc_byte_stream_next(recv_stream, recv_stream->length - received, - drain_continue.get()) && - GRPC_ERROR_NONE == - grpc_byte_stream_pull(recv_stream, &recv_slice) && + } while (recv_stream->Next(recv_stream->length() - received, + drain_continue.get()) && + GRPC_ERROR_NONE == recv_stream->Pull(&recv_slice) && (received += GRPC_SLICE_LENGTH(recv_slice), grpc_slice_unref_internal(recv_slice), true)); }); drain_continue = MakeClosure([&](grpc_error* error) { - grpc_byte_stream_pull(recv_stream, &recv_slice); + recv_stream->Pull(&recv_slice); received += GRPC_SLICE_LENGTH(recv_slice); grpc_slice_unref_internal(recv_slice); GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE); diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f5a9eb828e..fb1a4fe0f0 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -146,23 +146,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "byte_stream_test", - "src": [ - "test/core/transport/byte_stream_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -3002,6 +2985,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "byte_stream_test", + "src": [ + "test/core/transport/byte_stream_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 1406c4ac7e..1e320fc15d 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -195,30 +195,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "byte_stream_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, @@ -3601,6 +3577,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "byte_stream_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, -- cgit v1.2.3 From c7c0d69d8b411f1c5102bfd186aa2f6992c2e59c Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Sat, 10 Mar 2018 17:27:15 -0800 Subject: Secure channels: use the right authority --- BUILD | 18 +-- CMakeLists.txt | 34 +---- Makefile | 42 +------ build.yaml | 13 +- config.m4 | 1 + config.w32 | 1 + gRPC-C++.podspec | 2 + gRPC-Core.podspec | 3 + grpc.gemspec | 2 + grpc.gyp | 4 + package.xml | 2 + .../client_channel/client_channel_plugin.cc | 4 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 11 +- .../chttp2/client/insecure/channel_create.cc | 36 +++++- .../chttp2/client/secure/secure_channel_create.cc | 25 +++- src/core/lib/channel/client_authority_filter.cc | 117 ++++++++++++++++++ src/core/lib/channel/client_authority_filter.h | 34 +++++ .../security/credentials/ssl/ssl_credentials.cc | 2 +- .../security_connector/security_connector.cc | 10 +- src/core/lib/surface/channel.cc | 80 ++++++------ src/core/lib/surface/init.cc | 8 ++ src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/channel/minimal_stack_is_minimal_test.cc | 26 ++-- test/core/end2end/tests/default_host.cc | 9 +- test/core/surface/BUILD | 12 -- test/core/surface/invalid_channel_args_test.cc | 137 --------------------- tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 2 + tools/run_tests/generated/sources_and_headers.json | 20 +-- tools/run_tests/generated/tests.json | 24 ---- 30 files changed, 331 insertions(+), 350 deletions(-) create mode 100644 src/core/lib/channel/client_authority_filter.cc create mode 100644 src/core/lib/channel/client_authority_filter.h delete mode 100644 test/core/surface/invalid_channel_args_test.cc (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 9c99f95fcd..49f45f8218 100644 --- a/BUILD +++ b/BUILD @@ -676,6 +676,7 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/client_authority_filter.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -811,6 +812,7 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -1313,6 +1315,7 @@ grpc_cc_library( srcs = [ "src/core/lib/http/httpcli_security_connector.cc", "src/core/lib/security/context/security_context.cc", + "src/core/lib/security/credentials/alts/alts_credentials.cc", "src/core/lib/security/credentials/composite/composite_credentials.cc", "src/core/lib/security/credentials/credentials.cc", "src/core/lib/security/credentials/credentials_metadata.cc", @@ -1326,7 +1329,6 @@ grpc_cc_library( "src/core/lib/security/credentials/oauth2/oauth2_credentials.cc", "src/core/lib/security/credentials/plugin/plugin_credentials.cc", "src/core/lib/security/credentials/ssl/ssl_credentials.cc", - "src/core/lib/security/credentials/alts/alts_credentials.cc", "src/core/lib/security/security_connector/alts_security_connector.cc", "src/core/lib/security/security_connector/security_connector.cc", "src/core/lib/security/transport/client_auth_filter.cc", @@ -1340,6 +1342,7 @@ grpc_cc_library( ], hdrs = [ "src/core/lib/security/context/security_context.h", + "src/core/lib/security/credentials/alts/alts_credentials.h", "src/core/lib/security/credentials/composite/composite_credentials.h", "src/core/lib/security/credentials/credentials.h", "src/core/lib/security/credentials/fake/fake_credentials.h", @@ -1351,7 +1354,6 @@ grpc_cc_library( "src/core/lib/security/credentials/oauth2/oauth2_credentials.h", "src/core/lib/security/credentials/plugin/plugin_credentials.h", "src/core/lib/security/credentials/ssl/ssl_credentials.h", - "src/core/lib/security/credentials/alts/alts_credentials.h", "src/core/lib/security/security_connector/alts_security_connector.h", "src/core/lib/security/security_connector/security_connector.h", "src/core/lib/security/transport/auth_filters.h", @@ -1614,8 +1616,8 @@ grpc_cc_library( "src/core/tsi/alts/frame_protector/frame_handler.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h", - "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h", + "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h", "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h", "src/core/tsi/transport_security_grpc.h", @@ -1675,31 +1677,31 @@ grpc_cc_library( ], language = "c++", deps = [ - "alts_proto", - "gpr", - "grpc_base", + "alts_proto", + "gpr", + "grpc_base", ], ) grpc_cc_library( name = "tsi", srcs = [ - "src/core/tsi/alts_transport_security.cc", "src/core/tsi/alts/handshaker/alts_handshaker_client.cc", "src/core/tsi/alts/handshaker/alts_tsi_event.cc", "src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc", "src/core/tsi/alts/handshaker/alts_tsi_utils.cc", + "src/core/tsi/alts_transport_security.cc", "src/core/tsi/fake_transport_security.cc", "src/core/tsi/ssl_transport_security.cc", "src/core/tsi/transport_security_grpc.cc", ], hdrs = [ - "src/core/tsi/alts_transport_security.h", "src/core/tsi/alts/handshaker/alts_handshaker_client.h", "src/core/tsi/alts/handshaker/alts_tsi_event.h", "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h", "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h", "src/core/tsi/alts/handshaker/alts_tsi_utils.h", + "src/core/tsi/alts_transport_security.h", "src/core/tsi/fake_transport_security.h", "src/core/tsi/ssl_transport_security.h", "src/core/tsi/ssl_types.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dfbdcb85a..d3e84c7751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,7 +289,6 @@ add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_credentials_test) add_dependencies(buildtests_c grpc_fetch_oauth2) -add_dependencies(buildtests_c grpc_invalid_channel_args_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c grpc_json_token_test) endif() @@ -856,6 +855,7 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1231,6 +1231,7 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1597,6 +1598,7 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1886,6 +1888,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2155,6 +2158,7 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2958,6 +2962,7 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -6811,33 +6816,6 @@ target_link_libraries(grpc_fetch_oauth2 gpr ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(grpc_invalid_channel_args_test - test/core/surface/invalid_channel_args_test.cc -) - - -target_include_directories(grpc_invalid_channel_args_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} -) - -target_link_libraries(grpc_invalid_channel_args_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr_test_util - gpr -) - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) diff --git a/Makefile b/Makefile index a298fafd6b..02e1215459 100644 --- a/Makefile +++ b/Makefile @@ -1013,7 +1013,6 @@ grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_ grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt grpc_credentials_test: $(BINDIR)/$(CONFIG)/grpc_credentials_test grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 -grpc_invalid_channel_args_test: $(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test grpc_json_token_test: $(BINDIR)/$(CONFIG)/grpc_json_token_test grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test grpc_print_google_default_creds_token: $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token @@ -1448,7 +1447,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ - $(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test \ $(BINDIR)/$(CONFIG)/grpc_json_token_test \ $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test \ $(BINDIR)/$(CONFIG)/grpc_security_connector_test \ @@ -1977,8 +1975,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test || ( echo test grpc_completion_queue_threading_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_credentials_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_credentials_test || ( echo test grpc_credentials_test failed ; exit 1 ) - $(E) "[RUN] Testing grpc_invalid_channel_args_test" - $(Q) $(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test || ( echo test grpc_invalid_channel_args_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_json_token_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_json_token_test || ( echo test grpc_json_token_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_jwt_verifier_test" @@ -3164,6 +3160,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3541,6 +3538,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3908,6 +3906,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4190,6 +4189,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4439,6 +4439,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -5241,6 +5242,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -11798,38 +11800,6 @@ endif endif -GRPC_INVALID_CHANNEL_ARGS_TEST_SRC = \ - test/core/surface/invalid_channel_args_test.cc \ - -GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_INVALID_CHANNEL_ARGS_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test: $(GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_invalid_channel_args_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/surface/invalid_channel_args_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_grpc_invalid_channel_args_test: $(GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GRPC_INVALID_CHANNEL_ARGS_TEST_OBJS:.o=.dep) -endif -endif - - GRPC_JSON_TOKEN_TEST_SRC = \ test/core/security/json_token_test.cc \ diff --git a/build.yaml b/build.yaml index e2bb8bfa9f..eab2897706 100644 --- a/build.yaml +++ b/build.yaml @@ -232,6 +232,7 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc + - src/core/lib/channel/client_authority_filter.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc @@ -388,6 +389,7 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h + - src/core/lib/channel/client_authority_filter.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h @@ -2576,17 +2578,6 @@ targets: - grpc - gpr_test_util - gpr -- name: grpc_invalid_channel_args_test - build: test - language: c - src: - - test/core/surface/invalid_channel_args_test.cc - deps: - - grpc_test_util - - grpc - - gpr_test_util - - gpr - uses_polling: false - name: grpc_json_token_test build: test language: c diff --git a/config.m4 b/config.m4 index 7270051b0b..3b061e565e 100644 --- a/config.m4 +++ b/config.m4 @@ -84,6 +84,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ diff --git a/config.w32 b/config.w32 index d73acc1118..1b89419c57 100644 --- a/config.w32 +++ b/config.w32 @@ -61,6 +61,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + + "src\\core\\lib\\channel\\client_authority_filter.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 65a5dc66b4..6334ac433d 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -343,6 +343,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -522,6 +523,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 7f61719cb1..5827b397ff 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -354,6 +354,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -498,6 +499,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -908,6 +910,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/grpc.gemspec b/grpc.gemspec index 89a3812376..06520c1f95 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -284,6 +284,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) + s.files += %w( src/core/lib/channel/client_authority_filter.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) @@ -428,6 +429,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) + s.files += %w( src/core/lib/channel/client_authority_filter.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) diff --git a/grpc.gyp b/grpc.gyp index 0b60efe978..a398e4f460 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -236,6 +236,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -568,6 +569,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -785,6 +787,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -981,6 +984,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/package.xml b/package.xml index fc7ba68e8b..0abcb89738 100644 --- a/package.xml +++ b/package.xml @@ -291,6 +291,7 @@ + @@ -435,6 +436,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index 3c3a97532f..ed3ebd2696 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -39,6 +39,8 @@ static bool append_filter(grpc_channel_stack_builder* builder, void* arg) { builder, static_cast(arg), nullptr, nullptr); } +// Only used for direct channels, as they don't create subchannels, which is +// where default authority is handled for regular channels. static bool set_default_host_if_unset(grpc_channel_stack_builder* builder, void* unused) { const grpc_channel_args* args = @@ -69,7 +71,7 @@ void grpc_client_channel_init(void) { grpc_proxy_mapper_registry_init(); grpc_register_http_proxy_mapper(); grpc_subchannel_index_init(); - grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN, + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MIN, set_default_host_if_unset, nullptr); grpc_channel_init_register_stage( GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index cb39e4224e..49918e11b7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -504,9 +504,7 @@ GrpcLb::BalancerCallState::BalancerCallState( // the polling entities from client_channel. GPR_ASSERT(grpclb_policy()->server_name_ != nullptr); GPR_ASSERT(grpclb_policy()->server_name_[0] != '\0'); - grpc_slice host = - grpc_slice_from_copied_string(grpclb_policy()->server_name_); - grpc_millis deadline = + const grpc_millis deadline = grpclb_policy()->lb_call_timeout_ms_ == 0 ? GRPC_MILLIS_INF_FUTURE : ExecCtx::Get()->Now() + grpclb_policy()->lb_call_timeout_ms_; @@ -514,8 +512,7 @@ GrpcLb::BalancerCallState::BalancerCallState( grpclb_policy()->lb_channel_, nullptr, GRPC_PROPAGATE_DEFAULTS, grpclb_policy_->interested_parties(), GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD, - &host, deadline, nullptr); - grpc_slice_unref_internal(host); + nullptr, deadline, nullptr); // Init the LB call request payload. grpc_grpclb_request* request = grpc_grpclb_request_create(grpclb_policy()->server_name_); @@ -982,6 +979,10 @@ grpc_channel_args* BuildBalancerChannelArgs( // with the one from the grpclb policy, used to propagate updates to // the LB channel. GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, + // The LB channel should use the authority indicated by the target + // authority table (see \a grpc_lb_policy_grpclb_modify_lb_channel_args), + // as opposed to the authority from the parent channel. + GRPC_ARG_DEFAULT_AUTHORITY, }; // Channel args to add. const grpc_arg args_to_add[] = { diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index 60800365b8..8424cc5bc6 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -38,11 +38,41 @@ static void client_channel_factory_ref( static void client_channel_factory_unref( grpc_client_channel_factory* cc_factory) {} +static grpc_channel_args* add_default_authority_if_not_present( + const grpc_channel_args* args) { + const bool has_default_authority = + grpc_channel_args_find(args, GRPC_ARG_DEFAULT_AUTHORITY) != nullptr; + grpc_arg new_args[1]; + size_t num_new_args = 0; + grpc_core::UniquePtr default_authority; + if (!has_default_authority) { + const grpc_arg* server_uri_arg = + grpc_channel_args_find(args, GRPC_ARG_SERVER_URI); + const char* server_uri_str = grpc_channel_arg_get_string(server_uri_arg); + GPR_ASSERT(server_uri_str != nullptr); + default_authority = + grpc_core::ResolverRegistry::GetDefaultAuthority(server_uri_str); + GPR_ASSERT(default_authority != nullptr); + new_args[num_new_args++] = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), default_authority.get()); + } + return grpc_channel_args_copy_and_add(args, new_args, num_new_args); +} + static grpc_subchannel* client_channel_factory_create_subchannel( grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) { + grpc_subchannel_args* final_sc_args = + static_cast(gpr_malloc(sizeof(*final_sc_args))); + memcpy(final_sc_args, args, sizeof(*args)); + final_sc_args->args = add_default_authority_if_not_present(args->args); + grpc_connector* connector = grpc_chttp2_connector_create(); - grpc_subchannel* s = grpc_subchannel_create(connector, args); + grpc_subchannel* s = grpc_subchannel_create(connector, final_sc_args); grpc_connector_unref(connector); + + grpc_channel_args_destroy( + const_cast(final_sc_args->args)); + gpr_free(final_sc_args); return s; } @@ -56,8 +86,8 @@ static grpc_channel* client_channel_factory_create_channel( // Add channel arg containing the server URI. grpc_core::UniquePtr canonical_target = grpc_core::ResolverRegistry::AddDefaultPrefixIfNeeded(target); - grpc_arg arg = grpc_channel_arg_string_create((char*)GRPC_ARG_SERVER_URI, - canonical_target.get()); + grpc_arg arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_SERVER_URI), canonical_target.get()); const char* to_remove[] = {GRPC_ARG_SERVER_URI}; grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index a82009ff69..5ce73a95d7 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -71,9 +71,6 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args( grpc_uri* server_uri = grpc_uri_parse(server_uri_str, true /* supress errors */); GPR_ASSERT(server_uri != nullptr); - const char* server_uri_path; - server_uri_path = - server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path; const grpc_core::TargetAuthorityTable* target_authority_table = grpc_core::FindTargetAuthorityTableInArgs(args->args); grpc_core::UniquePtr authority; @@ -98,33 +95,49 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args( // authority table was present or because the target was not present // in the table), fall back to using the original server URI. if (authority == nullptr) { - authority.reset(gpr_strdup(server_uri_path)); + authority = + grpc_core::ResolverRegistry::GetDefaultAuthority(server_uri_str); } + grpc_arg args_to_add[2]; + size_t num_args_to_add = 0; + if (grpc_channel_args_find(args->args, GRPC_ARG_DEFAULT_AUTHORITY) == + nullptr) { + // If the channel args don't already contain GRPC_ARG_DEFAULT_AUTHORITY, add + // the arg, setting it to the value just obtained. + args_to_add[num_args_to_add++] = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), authority.get()); + } + grpc_channel_args* args_with_authority = + grpc_channel_args_copy_and_add(args->args, args_to_add, num_args_to_add); grpc_uri_destroy(server_uri); grpc_channel_security_connector* subchannel_security_connector = nullptr; // Create the security connector using the credentials and target name. grpc_channel_args* new_args_from_connector = nullptr; const grpc_security_status security_status = grpc_channel_credentials_create_security_connector( - channel_credentials, authority.get(), args->args, + channel_credentials, authority.get(), args_with_authority, &subchannel_security_connector, &new_args_from_connector); if (security_status != GRPC_SECURITY_OK) { gpr_log(GPR_ERROR, "Failed to create secure subchannel for secure name '%s'", authority.get()); + grpc_channel_args_destroy(args_with_authority); return nullptr; } grpc_arg new_security_connector_arg = grpc_security_connector_to_arg(&subchannel_security_connector->base); grpc_channel_args* new_args = grpc_channel_args_copy_and_add( - new_args_from_connector != nullptr ? new_args_from_connector : args->args, + new_args_from_connector != nullptr ? new_args_from_connector + : args_with_authority, &new_security_connector_arg, 1); + GRPC_SECURITY_CONNECTOR_UNREF(&subchannel_security_connector->base, "lb_channel_create"); if (new_args_from_connector != nullptr) { grpc_channel_args_destroy(new_args_from_connector); } + grpc_channel_args_destroy(args_with_authority); grpc_subchannel_args* final_sc_args = static_cast(gpr_malloc(sizeof(*final_sc_args))); memcpy(final_sc_args, args, sizeof(*args)); diff --git a/src/core/lib/channel/client_authority_filter.cc b/src/core/lib/channel/client_authority_filter.cc new file mode 100644 index 0000000000..57c5d29a93 --- /dev/null +++ b/src/core/lib/channel/client_authority_filter.cc @@ -0,0 +1,117 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include + +#include +#include +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/client_authority_filter.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/surface/call.h" +#include "src/core/lib/surface/channel_init.h" +#include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/transport/static_metadata.h" + +namespace { + +struct call_data { + grpc_linked_mdelem authority_storage; + grpc_call_combiner* call_combiner; +}; + +struct channel_data { + grpc_slice default_authority; +}; + +void authority_start_transport_stream_op_batch( + grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { + channel_data* chand = static_cast(elem->channel_data); + call_data* calld = static_cast(elem->call_data); + // Handle send_initial_metadata. + auto* initial_metadata = + batch->payload->send_initial_metadata.send_initial_metadata; + // If the initial metadata doesn't already contain :authority, add it. + if (batch->send_initial_metadata && + initial_metadata->idx.named.authority == nullptr) { + grpc_error* error = grpc_metadata_batch_add_head( + initial_metadata, &calld->authority_storage, + grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, + grpc_slice_ref(chand->default_authority))); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_batch_finish_with_failure(batch, error, + calld->call_combiner); + return; + } + } + // Pass control down the stack. + grpc_call_next_op(elem, batch); +} + +/* Constructor for call_data */ +grpc_error* init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { + call_data* calld = static_cast(elem->call_data); + calld->call_combiner = args->call_combiner; + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +void destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} + +/* Constructor for channel_data */ +grpc_error* init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { + channel_data* chand = static_cast(elem->channel_data); + const grpc_arg* default_authority_arg = + grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); + GPR_ASSERT(default_authority_arg != nullptr); + chand->default_authority = grpc_slice_from_copied_string( + grpc_channel_arg_get_string(default_authority_arg)); + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +void destroy_channel_elem(grpc_channel_element* elem) { + channel_data* chand = static_cast(elem->channel_data); + grpc_slice_unref(chand->default_authority); +} +} // namespace + +const grpc_channel_filter grpc_client_authority_filter = { + authority_start_transport_stream_op_batch, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_channel_next_get_info, + "authority"}; diff --git a/src/core/lib/channel/client_authority_filter.h b/src/core/lib/channel/client_authority_filter.h new file mode 100644 index 0000000000..ba996dc823 --- /dev/null +++ b/src/core/lib/channel/client_authority_filter.h @@ -0,0 +1,34 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H + +#include + +#include + +#include "src/core/lib/channel/channel_stack.h" + +/// Filter responsible for setting the authority header, if not already set. It +/// uses the value of the GRPC_ARG_DEFAULT_AUTHORITY channel arg if the initial +/// metadata doesn't already contain an authority value. + +extern const grpc_channel_filter grpc_client_authority_filter; + +#endif /* GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H */ diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 252b25bc0a..295f13c3b7 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -58,7 +58,7 @@ static grpc_security_status ssl_create_security_connector( const char* overridden_target_name = nullptr; for (size_t i = 0; args && i < args->num_args; i++) { grpc_arg* arg = &args->args[i]; - if (strcmp(arg->key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == 0 && + if (strcmp(arg->key, GRPC_ARG_DEFAULT_AUTHORITY) == 0 && arg->type == GRPC_ARG_STRING) { overridden_target_name = arg->value.string; break; diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 3cc151bec7..7b90b19075 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -465,12 +465,10 @@ static bool fake_channel_check_call_host(grpc_channel_security_connector* sc, grpc_error** error) { grpc_fake_channel_security_connector* c = reinterpret_cast(sc); - if (c->is_lb_channel) { - // TODO(dgq): verify that the host (ie, authority header) matches that of - // the LB, as opposed to that of the backends. - } else { - // TODO(dgq): verify that the host (ie, authority header) matches that of - // the backend, not the LB's. + if (c->is_lb_channel && strcmp(host, c->target) != 0) { + gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s' for an LB call", + host, c->target); + abort(); } return true; } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 03353d6beb..48bc69509f 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -55,7 +56,6 @@ typedef struct registered_call { struct grpc_channel { int is_client; grpc_compression_options compression_options; - grpc_mdelem default_authority; gpr_atm call_size_estimate; @@ -108,40 +108,8 @@ grpc_channel* grpc_channel_create_with_builder( grpc_compression_options_init(&channel->compression_options); for (size_t i = 0; i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "%s ignored: it must be a string", - GRPC_ARG_DEFAULT_AUTHORITY); - } else { - if (!GRPC_MDISNULL(channel->default_authority)) { - /* setting this takes precedence over anything else */ - GRPC_MDELEM_UNREF(channel->default_authority); - } - channel->default_authority = grpc_mdelem_from_slices( - GRPC_MDSTR_AUTHORITY, - grpc_slice_intern( - grpc_slice_from_static_string(args->args[i].value.string))); - } - } else if (0 == - strcmp(args->args[i].key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "%s ignored: it must be a string", - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - } else { - if (!GRPC_MDISNULL(channel->default_authority)) { - /* other ways of setting this (notably ssl) take precedence */ - gpr_log(GPR_ERROR, - "%s ignored: default host already set some other way", - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - } else { - channel->default_authority = grpc_mdelem_from_slices( - GRPC_MDSTR_AUTHORITY, - grpc_slice_intern( - grpc_slice_from_static_string(args->args[i].value.string))); - } - } - } else if (0 == strcmp(args->args[i].key, - GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) { + if (0 == + strcmp(args->args[i].key, GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) { channel->compression_options.default_level.is_set = true; channel->compression_options.default_level.level = static_cast(grpc_channel_arg_get_integer( @@ -169,12 +137,49 @@ done: return channel; } +static grpc_core::UniquePtr get_default_authority( + const char* target, const grpc_channel_args* input_args, + grpc_channel_stack_type channel_stack_type) { + bool has_default_authority = false; + char* ssl_override = nullptr; + grpc_core::UniquePtr default_authority; + const size_t num_args = input_args != nullptr ? input_args->num_args : 0; + for (size_t i = 0; i < num_args; ++i) { + if (0 == strcmp(input_args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) { + has_default_authority = true; + } else if (0 == strcmp(input_args->args[i].key, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) { + ssl_override = input_args->args[i].value.string; + } + } + if (!has_default_authority && ssl_override != nullptr) { + default_authority.reset(gpr_strdup(ssl_override)); + } + return default_authority; +} + +static grpc_channel_args* build_channel_args( + const grpc_channel_args* input_args, char* default_authority) { + grpc_arg new_args[1]; + size_t num_new_args = 0; + if (default_authority != nullptr) { + new_args[num_new_args++] = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), default_authority); + } + return grpc_channel_args_copy_and_add(input_args, new_args, num_new_args); +} + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, grpc_transport* optional_transport) { grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); - grpc_channel_stack_builder_set_channel_arguments(builder, input_args); + const grpc_core::UniquePtr default_authority = + get_default_authority(target, input_args, channel_stack_type); + grpc_channel_args* args = + build_channel_args(input_args, default_authority.get()); + grpc_channel_stack_builder_set_channel_arguments(builder, args); + grpc_channel_args_destroy(args); grpc_channel_stack_builder_set_target(builder, target); grpc_channel_stack_builder_set_transport(builder, optional_transport); if (!grpc_channel_init_create_stack(builder, channel_stack_type)) { @@ -246,8 +251,6 @@ static grpc_call* grpc_channel_create_call_internal( send_metadata[num_metadata++] = path_mdelem; if (!GRPC_MDISNULL(authority_mdelem)) { send_metadata[num_metadata++] = authority_mdelem; - } else if (!GRPC_MDISNULL(channel->default_authority)) { - send_metadata[num_metadata++] = GRPC_MDELEM_REF(channel->default_authority); } grpc_call_create_args args; @@ -377,7 +380,6 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } - GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); gpr_free(channel); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index ac9f9e6066..10c65ce09f 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,6 +27,7 @@ #include #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/client_authority_filter.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/debug/stats.h" @@ -83,6 +84,13 @@ static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) { } static void register_builtin_channel_init() { + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, + prepend_filter, + (void*)(&grpc_client_authority_filter)); + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, + prepend_filter, + (void*)(&grpc_client_authority_filter)); + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, nullptr); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 994443c651..7bd1adf8fe 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,6 +60,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc index f02c8180f2..e5953acedc 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.cc +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -66,35 +66,37 @@ int main(int argc, char** argv) { minimal_stack_arg.key = const_cast(GRPC_ARG_MINIMAL_STACK); minimal_stack_arg.value.integer = 1; grpc_channel_args minimal_stack_args = {1, &minimal_stack_arg}; - errors += CHECK_STACK("unknown", &minimal_stack_args, - GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL); + errors += + CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, + "authority", "connected", NULL); errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, - "connected", NULL); + "authority", "connected", NULL); errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, "server", "connected", NULL); errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, - "http-client", "connected", NULL); + "authority", "http-client", "connected", NULL); errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, - "http-client", "connected", NULL); + "authority", "http-client", "connected", NULL); errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, "server", "http-server", "connected", NULL); errors += CHECK_STACK(nullptr, &minimal_stack_args, GRPC_CLIENT_CHANNEL, "client-channel", NULL); // tests with a default stack - errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, - "message_size", "deadline", "connected", NULL); - errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_SUBCHANNEL, + errors += + CHECK_STACK("unknown", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, "authority", + "message_size", "deadline", "connected", NULL); + errors += CHECK_STACK("unknown", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority", "message_size", "connected", NULL); errors += CHECK_STACK("unknown", nullptr, GRPC_SERVER_CHANNEL, "server", "message_size", "deadline", "connected", NULL); errors += CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, - "message_size", "deadline", "http-client", + "authority", "message_size", "deadline", "http-client", "message_compress", "connected", NULL); - errors += - CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_SUBCHANNEL, "message_size", - "http-client", "message_compress", "connected", NULL); + errors += CHECK_STACK("chttp2", nullptr, GRPC_CLIENT_SUBCHANNEL, "authority", + "message_size", "http-client", "message_compress", + "connected", NULL); errors += CHECK_STACK("chttp2", nullptr, GRPC_SERVER_CHANNEL, "server", "message_size", "deadline", "http-server", "message_compress", "connected", NULL); diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc index 3191f76688..cda716a259 100644 --- a/test/core/end2end/tests/default_host.cc +++ b/test/core/end2end/tests/default_host.cc @@ -191,7 +191,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); - GPR_ASSERT(grpc_slice_buf_start_eq(call_details.host, "localhost", 9)); + char* target = grpc_channel_get_target(f.client); + GPR_ASSERT(grpc_slice_buf_start_eq(call_details.host, target, 9)); + gpr_free(target); GPR_ASSERT(was_cancelled == 1); grpc_slice_unref(details); @@ -216,10 +218,9 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { } void default_host(grpc_end2end_test_config config) { - if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) == 0) - return; - if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) + if ((config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) != 0) { return; + } test_invoke_simple_request(config); } diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD index e848dded13..77df1cc989 100644 --- a/test/core/surface/BUILD +++ b/test/core/surface/BUILD @@ -90,18 +90,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "grpc_invalid_channel_args_test", - srcs = ["invalid_channel_args_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//test/core/util:gpr_test_util", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "lame_client_test", srcs = ["lame_client_test.cc"], diff --git a/test/core/surface/invalid_channel_args_test.cc b/test/core/surface/invalid_channel_args_test.cc deleted file mode 100644 index 7c5f1f0352..0000000000 --- a/test/core/surface/invalid_channel_args_test.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#include -#include -#include -#include "test/core/util/test_config.h" - -static char* g_last_log_error_message = nullptr; -static const char* g_file_name = "channel.cc"; - -static int ends_with(const char* src, const char* suffix) { - size_t src_len = strlen(src); - size_t suffix_len = strlen(suffix); - if (src_len < suffix_len) { - return 0; - } - return strcmp(src + src_len - suffix_len, suffix) == 0; -} - -static void log_error_sink(gpr_log_func_args* args) { - if (args->severity == GPR_LOG_SEVERITY_ERROR && - ends_with(args->file, g_file_name)) { - g_last_log_error_message = gpr_strdup(args->message); - } -} - -static void verify_last_error(const char* message) { - if (message == nullptr) { - GPR_ASSERT(g_last_log_error_message == nullptr); - return; - } - GPR_ASSERT(strcmp(message, g_last_log_error_message) == 0); - gpr_free(g_last_log_error_message); - g_last_log_error_message = nullptr; -} - -static char* compose_error_string(const char* key, const char* message) { - char* ret; - gpr_asprintf(&ret, "%s%s", key, message); - return ret; -} - -static void one_test(grpc_channel_args* args, char* expected_error_message) { - grpc_channel* chan = - grpc_insecure_channel_create("nonexistant:54321", args, nullptr); - verify_last_error(expected_error_message); - gpr_free(expected_error_message); - grpc_channel_destroy(chan); -} - -static void test_no_error_message(void) { one_test(nullptr, nullptr); } - -static void test_default_authority_type(void) { - grpc_arg client_arg; - grpc_channel_args client_args; - char* expected_error_message; - - client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = const_cast(GRPC_ARG_DEFAULT_AUTHORITY); - client_arg.value.integer = 0; - - client_args.num_args = 1; - client_args.args = &client_arg; - expected_error_message = compose_error_string( - GRPC_ARG_DEFAULT_AUTHORITY, " ignored: it must be a string"); - one_test(&client_args, expected_error_message); -} - -static void test_ssl_name_override_type(void) { - grpc_arg client_arg; - grpc_channel_args client_args; - char* expected_error_message; - - client_arg.type = GRPC_ARG_INTEGER; - client_arg.key = const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - client_arg.value.integer = 0; - - client_args.num_args = 1; - client_args.args = &client_arg; - expected_error_message = compose_error_string( - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, " ignored: it must be a string"); - one_test(&client_args, expected_error_message); -} - -static void test_ssl_name_override_failed(void) { - grpc_arg client_arg[2]; - grpc_channel_args client_args; - char* expected_error_message; - - client_arg[0].type = GRPC_ARG_STRING; - client_arg[0].key = const_cast(GRPC_ARG_DEFAULT_AUTHORITY); - client_arg[0].value.string = const_cast("default"); - client_arg[1].type = GRPC_ARG_STRING; - client_arg[1].key = const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG); - client_arg[1].value.string = const_cast("ssl"); - - client_args.num_args = 2; - client_args.args = client_arg; - expected_error_message = - compose_error_string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - " ignored: default host already set some other way"); - one_test(&client_args, expected_error_message); -} - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - grpc_init(); - gpr_set_log_function(log_error_sink); - - test_no_error_message(); - test_default_authority_type(); - test_ssl_name_override_type(); - test_ssl_name_override_failed(); - - grpc_shutdown(); - - return 0; -} diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ff5abc679d..f1fb7d29fc 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,6 +1007,7 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/client_authority_filter.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e7e9e04979..1f19bac169 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1034,6 +1034,8 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/client_authority_filter.cc \ +src/core/lib/channel/client_authority_filter.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f5a9eb828e..fa34d963aa 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1000,23 +1000,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_invalid_channel_args_test", - "src": [ - "test/core/surface/invalid_channel_args_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -9005,6 +8988,7 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/client_authority_filter.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -9162,6 +9146,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -9306,6 +9291,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 1406c4ac7e..db2776ba75 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1297,30 +1297,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "grpc_invalid_channel_args_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, -- cgit v1.2.3 From 7b84b3d519b0fb678876af10c0bc2206020dbe91 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 12 Mar 2018 12:08:30 -0700 Subject: PR comments --- .../client_channel/client_channel_plugin.cc | 27 ---------------------- .../client_channel/lb_policy/grpclb/grpclb.cc | 4 ++++ .../chttp2/client/insecure/channel_create.cc | 2 -- src/core/lib/channel/client_authority_filter.cc | 2 +- src/core/lib/channel/client_authority_filter.h | 2 +- src/core/lib/surface/channel.cc | 6 +++++ 6 files changed, 12 insertions(+), 31 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index ed3ebd2696..98d9d02110 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -39,31 +39,6 @@ static bool append_filter(grpc_channel_stack_builder* builder, void* arg) { builder, static_cast(arg), nullptr, nullptr); } -// Only used for direct channels, as they don't create subchannels, which is -// where default authority is handled for regular channels. -static bool set_default_host_if_unset(grpc_channel_stack_builder* builder, - void* unused) { - const grpc_channel_args* args = - grpc_channel_stack_builder_get_channel_arguments(builder); - for (size_t i = 0; i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY) || - 0 == strcmp(args->args[i].key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) { - return true; - } - } - grpc_core::UniquePtr default_authority = - grpc_core::ResolverRegistry::GetDefaultAuthority( - grpc_channel_stack_builder_get_target(builder)); - if (default_authority.get() != nullptr) { - grpc_arg arg = grpc_channel_arg_string_create( - (char*)GRPC_ARG_DEFAULT_AUTHORITY, default_authority.get()); - grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1); - grpc_channel_stack_builder_set_channel_arguments(builder, new_args); - grpc_channel_args_destroy(new_args); - } - return true; -} - void grpc_client_channel_init(void) { grpc_core::LoadBalancingPolicyRegistry::Builder::InitRegistry(); grpc_core::ResolverRegistry::Builder::InitRegistry(); @@ -71,8 +46,6 @@ void grpc_client_channel_init(void) { grpc_proxy_mapper_registry_init(); grpc_register_http_proxy_mapper(); grpc_subchannel_index_init(); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MIN, - set_default_host_if_unset, nullptr); grpc_channel_init_register_stage( GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, (void*)&grpc_client_channel_filter); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 49918e11b7..17ab0febb7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -983,6 +983,10 @@ grpc_channel_args* BuildBalancerChannelArgs( // authority table (see \a grpc_lb_policy_grpclb_modify_lb_channel_args), // as opposed to the authority from the parent channel. GRPC_ARG_DEFAULT_AUTHORITY, + // Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the LB channel should be + // treated as a stand-alone channel and not inherit this argument from the + // args of the parent channel. + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, }; // Channel args to add. const grpc_arg args_to_add[] = { diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index 8424cc5bc6..9fb87c2164 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -65,11 +65,9 @@ static grpc_subchannel* client_channel_factory_create_subchannel( static_cast(gpr_malloc(sizeof(*final_sc_args))); memcpy(final_sc_args, args, sizeof(*args)); final_sc_args->args = add_default_authority_if_not_present(args->args); - grpc_connector* connector = grpc_chttp2_connector_create(); grpc_subchannel* s = grpc_subchannel_create(connector, final_sc_args); grpc_connector_unref(connector); - grpc_channel_args_destroy( const_cast(final_sc_args->args)); gpr_free(final_sc_args); diff --git a/src/core/lib/channel/client_authority_filter.cc b/src/core/lib/channel/client_authority_filter.cc index 57c5d29a93..f684684be1 100644 --- a/src/core/lib/channel/client_authority_filter.cc +++ b/src/core/lib/channel/client_authority_filter.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2017 gRPC authors. + * Copyright 2018 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/core/lib/channel/client_authority_filter.h b/src/core/lib/channel/client_authority_filter.h index ba996dc823..c101c359d2 100644 --- a/src/core/lib/channel/client_authority_filter.h +++ b/src/core/lib/channel/client_authority_filter.h @@ -1,6 +1,6 @@ /* * - * Copyright 2017 gRPC authors. + * Copyright 2018 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 48bc69509f..93f3009dba 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -155,6 +155,12 @@ static grpc_core::UniquePtr get_default_authority( if (!has_default_authority && ssl_override != nullptr) { default_authority.reset(gpr_strdup(ssl_override)); } + if (channel_stack_type == GRPC_CLIENT_DIRECT_CHANNEL && + default_authority == nullptr) { + // Set the default authority. This is handled by the subchannel stack for + // regular client channels. + default_authority.reset(gpr_strdup(target)); + } return default_authority; } -- cgit v1.2.3 From 7573f989add175f3d1aef5b2015a263b410d0f2a Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Mon, 12 Mar 2018 18:06:13 -0700 Subject: Fix call stack ref flake --- src/core/lib/surface/call.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index c4844da318..deb2b9f45f 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -379,7 +379,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, bool immediately_cancel = false; if (args->parent != nullptr) { - child_call* cc = call->child = + call->child = static_cast(gpr_arena_alloc(arena, sizeof(child_call))); call->child->parent = args->parent; @@ -387,10 +387,6 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, GPR_ASSERT(call->is_client); GPR_ASSERT(!args->parent->is_client); - parent_call* pc = get_or_create_parent_call(args->parent); - - gpr_mu_lock(&pc->child_list_mu); - if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) { send_deadline = GPR_MIN(send_deadline, args->parent->send_deadline); } @@ -418,18 +414,6 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, immediately_cancel = true; } } - - if (pc->first_child == nullptr) { - pc->first_child = call; - cc->sibling_next = cc->sibling_prev = call; - } else { - cc->sibling_next = pc->first_child; - cc->sibling_prev = pc->first_child->child->sibling_prev; - cc->sibling_next->child->sibling_prev = - cc->sibling_prev->child->sibling_next = call; - } - - gpr_mu_unlock(&pc->child_list_mu); } call->send_deadline = send_deadline; @@ -446,6 +430,22 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args, &call->call_combiner}; add_init_error(&error, grpc_call_stack_init(channel_stack, 1, destroy_call, call, &call_args)); + // Publish this call to parent only after the call stack has been initialized. + if (args->parent != nullptr) { + child_call* cc = call->child; + parent_call* pc = get_or_create_parent_call(args->parent); + gpr_mu_lock(&pc->child_list_mu); + if (pc->first_child == nullptr) { + pc->first_child = call; + cc->sibling_next = cc->sibling_prev = call; + } else { + cc->sibling_next = pc->first_child; + cc->sibling_prev = pc->first_child->child->sibling_prev; + cc->sibling_next->child->sibling_prev = + cc->sibling_prev->child->sibling_next = call; + } + gpr_mu_unlock(&pc->child_list_mu); + } if (error != GRPC_ERROR_NONE) { cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error)); } -- cgit v1.2.3 From aa843f2bfc83b588a645d5edc9300b0e1d353f93 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 13 Mar 2018 08:36:16 -0700 Subject: Testing making the authority filter a plugin, for cronet --- BUILD | 16 +++++++++++++++ CMakeLists.txt | 8 ++------ build.yaml | 12 +++++++++-- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 3 +-- gRPC-Core.podspec | 6 +++--- grpc.gemspec | 4 ++-- grpc.gyp | 6 ++---- package.xml | 4 ++-- src/core/lib/channel/client_authority_filter.cc | 18 +++++++++++++++++ src/core/lib/surface/init.cc | 7 ------- src/core/lib/surface/init_secure.cc | 4 ++-- src/core/plugin_registry/grpc_plugin_registry.cc | 4 ++++ .../grpc_unsecure_plugin_registry.cc | 4 ++++ src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.c++.internal | 1 - tools/run_tests/generated/sources_and_headers.json | 23 +++++++++++++++++++--- 18 files changed, 89 insertions(+), 37 deletions(-) (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 49f45f8218..75aebb2462 100644 --- a/BUILD +++ b/BUILD @@ -966,6 +966,7 @@ grpc_cc_library( # standard plugins "census", "grpc_deadline_filter", + "grpc_client_authority_filter", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", "grpc_server_load_reporting", @@ -1036,6 +1037,7 @@ grpc_cc_library( deps = [ "gpr_base", "grpc_base", + "grpc_client_authority_filter", "grpc_deadline_filter", "inlined_vector", "orphanable", @@ -1072,6 +1074,20 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_client_authority_filter", + srcs = [ + "src/core/lib/channel/client_authority_filter.cc", + ], + hdrs = [ + "src/core/lib/channel/client_authority_filter.h", + ], + language = "c++", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_message_size_filter", srcs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index d3e84c7751..1657f1ae7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -855,7 +855,6 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1133,6 +1132,7 @@ add_library(grpc src/core/ext/census/grpc_context.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc + src/core/lib/channel/client_authority_filter.cc src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc src/core/ext/filters/workarounds/workaround_utils.cc src/core/plugin_registry/grpc_plugin_registry.cc @@ -1231,7 +1231,6 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1598,7 +1597,6 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1888,7 +1886,6 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2158,7 +2155,6 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2371,6 +2367,7 @@ add_library(grpc_unsecure src/core/ext/census/grpc_context.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc + src/core/lib/channel/client_authority_filter.cc src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc src/core/ext/filters/workarounds/workaround_utils.cc src/core/plugin_registry/grpc_unsecure_plugin_registry.cc @@ -2962,7 +2959,6 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/client_authority_filter.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc diff --git a/build.yaml b/build.yaml index eab2897706..20581ae00e 100644 --- a/build.yaml +++ b/build.yaml @@ -232,7 +232,6 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - - src/core/lib/channel/client_authority_filter.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc @@ -389,7 +388,6 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - - src/core/lib/channel/client_authority_filter.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h @@ -517,6 +515,14 @@ filegroups: uses: - grpc_codegen - grpc_trace_headers +- name: grpc_client_authority_filter + headers: + - src/core/lib/channel/client_authority_filter.h + src: + - src/core/lib/channel/client_authority_filter.cc + plugin: grpc_client_authority_filter + uses: + - grpc_base - name: grpc_client_channel headers: - src/core/ext/filters/client_channel/backup_poller.h @@ -1354,6 +1360,7 @@ libs: - grpc_max_age_filter - grpc_message_size_filter - grpc_deadline_filter + - grpc_client_authority_filter - grpc_workaround_cronet_compression_filter - grpc_server_backward_compatibility generate_plugin_registry: true @@ -1456,6 +1463,7 @@ libs: - grpc_max_age_filter - grpc_message_size_filter - grpc_deadline_filter + - grpc_client_authority_filter - grpc_workaround_cronet_compression_filter - grpc_server_backward_compatibility generate_plugin_registry: true diff --git a/config.m4 b/config.m4 index 3b061e565e..9b48890d4c 100644 --- a/config.m4 +++ b/config.m4 @@ -84,7 +84,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -362,6 +361,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_plugin_registry.cc \ diff --git a/config.w32 b/config.w32 index 1b89419c57..b6b417e3de 100644 --- a/config.w32 +++ b/config.w32 @@ -61,7 +61,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + - "src\\core\\lib\\channel\\client_authority_filter.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + @@ -339,6 +338,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\census\\grpc_context.cc " + "src\\core\\ext\\filters\\max_age\\max_age_filter.cc " + "src\\core\\ext\\filters\\message_size\\message_size_filter.cc " + + "src\\core\\lib\\channel\\client_authority_filter.cc " + "src\\core\\ext\\filters\\workarounds\\workaround_cronet_compression_filter.cc " + "src\\core\\ext\\filters\\workarounds\\workaround_utils.cc " + "src\\core\\plugin_registry\\grpc_plugin_registry.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 6334ac433d..5e8ae3f9a6 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -343,7 +343,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -480,6 +479,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h' @@ -523,7 +523,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 5827b397ff..242bc49bd3 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -354,7 +354,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -491,6 +490,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.cc', @@ -499,7 +499,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -774,6 +773,7 @@ Pod::Spec.new do |s| 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc' @@ -910,7 +910,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/client_authority_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -1047,6 +1046,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', + 'src/core/lib/channel/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h' end diff --git a/grpc.gemspec b/grpc.gemspec index 06520c1f95..33ca745e69 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -284,7 +284,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) - s.files += %w( src/core/lib/channel/client_authority_filter.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) @@ -421,6 +420,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) + s.files += %w( src/core/lib/channel/client_authority_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.cc ) @@ -429,7 +429,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) - s.files += %w( src/core/lib/channel/client_authority_filter.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) @@ -707,6 +706,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/census/grpc_context.cc ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.cc ) + s.files += %w( src/core/lib/channel/client_authority_filter.cc ) s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.cc ) s.files += %w( src/core/plugin_registry/grpc_plugin_registry.cc ) diff --git a/grpc.gyp b/grpc.gyp index a398e4f460..04421bad57 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -236,7 +236,6 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -514,6 +513,7 @@ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc', @@ -569,7 +569,6 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -787,7 +786,6 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -984,7 +982,6 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -1197,6 +1194,7 @@ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_unsecure_plugin_registry.cc', diff --git a/package.xml b/package.xml index 0abcb89738..a8a3c4f356 100644 --- a/package.xml +++ b/package.xml @@ -291,7 +291,6 @@ - @@ -428,6 +427,7 @@ + @@ -436,7 +436,6 @@ - @@ -714,6 +713,7 @@ + diff --git a/src/core/lib/channel/client_authority_filter.cc b/src/core/lib/channel/client_authority_filter.cc index f684684be1..bf37f52e9c 100644 --- a/src/core/lib/channel/client_authority_filter.cc +++ b/src/core/lib/channel/client_authority_filter.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -115,3 +116,20 @@ const grpc_channel_filter grpc_client_authority_filter = { destroy_channel_elem, grpc_channel_next_get_info, "authority"}; + +static bool add_client_authority_filter(grpc_channel_stack_builder* builder, + void* arg) { + return grpc_channel_stack_builder_prepend_filter( + builder, static_cast(arg), nullptr, nullptr); +} + +void grpc_client_authority_filter_init(void) { + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, + add_client_authority_filter, + (void*)&grpc_client_authority_filter); + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, + add_client_authority_filter, + (void*)&grpc_client_authority_filter); +} + +void grpc_client_authority_filter_shutdown(void) {} diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 10c65ce09f..2d29c7d95f 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -84,13 +84,6 @@ static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) { } static void register_builtin_channel_init() { - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, - prepend_filter, - (void*)(&grpc_client_authority_filter)); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, - prepend_filter, - (void*)(&grpc_client_authority_filter)); - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, nullptr); diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index 78e983e0cd..9700f43a55 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -67,9 +67,9 @@ static bool maybe_prepend_server_auth_filter( } void grpc_register_security_filters(void) { - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX - 1, maybe_prepend_client_auth_filter, nullptr); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX - 1, maybe_prepend_client_auth_filter, nullptr); grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, maybe_prepend_server_auth_filter, nullptr); diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index 6f11e6bb5b..e371310fa1 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -52,6 +52,8 @@ void grpc_max_age_filter_init(void); void grpc_max_age_filter_shutdown(void); void grpc_message_size_filter_init(void); void grpc_message_size_filter_shutdown(void); +void grpc_client_authority_filter_init(void); +void grpc_client_authority_filter_shutdown(void); void grpc_workaround_cronet_compression_filter_init(void); void grpc_workaround_cronet_compression_filter_shutdown(void); @@ -88,6 +90,8 @@ void grpc_register_built_in_plugins(void) { grpc_max_age_filter_shutdown); grpc_register_plugin(grpc_message_size_filter_init, grpc_message_size_filter_shutdown); + grpc_register_plugin(grpc_client_authority_filter_init, + grpc_client_authority_filter_shutdown); grpc_register_plugin(grpc_workaround_cronet_compression_filter_init, grpc_workaround_cronet_compression_filter_shutdown); } diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc index b08c5ce3ae..283db5b4f4 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc @@ -50,6 +50,8 @@ void grpc_max_age_filter_init(void); void grpc_max_age_filter_shutdown(void); void grpc_message_size_filter_init(void); void grpc_message_size_filter_shutdown(void); +void grpc_client_authority_filter_init(void); +void grpc_client_authority_filter_shutdown(void); void grpc_workaround_cronet_compression_filter_init(void); void grpc_workaround_cronet_compression_filter_shutdown(void); @@ -84,6 +86,8 @@ void grpc_register_built_in_plugins(void) { grpc_max_age_filter_shutdown); grpc_register_plugin(grpc_message_size_filter_init, grpc_message_size_filter_shutdown); + grpc_register_plugin(grpc_client_authority_filter_init, + grpc_client_authority_filter_shutdown); grpc_register_plugin(grpc_workaround_cronet_compression_filter_init, grpc_workaround_cronet_compression_filter_shutdown); } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7bd1adf8fe..bb426b070f 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,7 +60,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/client_authority_filter.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -338,6 +337,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', + 'src/core/lib/channel/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index f1fb7d29fc..ff5abc679d 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,7 +1007,6 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/client_authority_filter.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index fa34d963aa..07edd14b04 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6610,6 +6610,7 @@ "census", "gpr", "grpc_base", + "grpc_client_authority_filter", "grpc_deadline_filter", "grpc_lb_policy_grpclb_secure", "grpc_lb_policy_pick_first", @@ -6717,6 +6718,7 @@ "census", "gpr", "grpc_base", + "grpc_client_authority_filter", "grpc_deadline_filter", "grpc_lb_policy_grpclb", "grpc_lb_policy_pick_first", @@ -8988,7 +8990,6 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/client_authority_filter.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -9146,7 +9147,6 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -9291,7 +9291,6 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -9418,6 +9417,24 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/lib/channel/client_authority_filter.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_client_authority_filter", + "src": [ + "src/core/lib/channel/client_authority_filter.cc", + "src/core/lib/channel/client_authority_filter.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", -- cgit v1.2.3 From 2f6fc700de0431878ade712051981a2609793553 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 14 Mar 2018 11:19:26 -0700 Subject: Abort if direct channel doesn't provide default authority ch arg --- Makefile | 8 ++------ src/core/lib/surface/channel.cc | 7 ++++--- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/core/lib/surface') diff --git a/Makefile b/Makefile index 02e1215459..93b3588de2 100644 --- a/Makefile +++ b/Makefile @@ -3160,7 +3160,6 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3438,6 +3437,7 @@ LIBGRPC_SRC = \ src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_plugin_registry.cc \ @@ -3538,7 +3538,6 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3906,7 +3905,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4189,7 +4187,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4439,7 +4436,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4652,6 +4648,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ + src/core/lib/channel/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_unsecure_plugin_registry.cc \ @@ -5242,7 +5239,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/client_authority_filter.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 93f3009dba..274dfe38bf 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -157,9 +157,10 @@ static grpc_core::UniquePtr get_default_authority( } if (channel_stack_type == GRPC_CLIENT_DIRECT_CHANNEL && default_authority == nullptr) { - // Set the default authority. This is handled by the subchannel stack for - // regular client channels. - default_authority.reset(gpr_strdup(target)); + gpr_log(GPR_ERROR, + "Direct channels must specify a value for the " + "GRPC_ARG_DEFAULT_AUTHORITY channel arg."); + abort(); } return default_authority; } -- cgit v1.2.3 From f73e76d59682faa44b382e83c9d36c9664d15c23 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 14 Mar 2018 12:50:48 -0700 Subject: Fix check in channel.cc and tweak direct channel tests --- src/core/lib/surface/channel.cc | 2 +- test/core/end2end/fixtures/h2_sockpair+trace.cc | 9 +++++++-- test/core/end2end/fixtures/h2_sockpair.cc | 8 +++++++- test/core/end2end/fixtures/h2_sockpair_1byte.cc | 8 +++++++- test/core/end2end/fuzzers/client_fuzzer.cc | 9 ++++++++- 5 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 274dfe38bf..9d38fe9c71 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -156,7 +156,7 @@ static grpc_core::UniquePtr get_default_authority( default_authority.reset(gpr_strdup(ssl_override)); } if (channel_stack_type == GRPC_CLIENT_DIRECT_CHANNEL && - default_authority == nullptr) { + !has_default_authority) { gpr_log(GPR_ERROR, "Direct channels must specify a value for the " "GRPC_ARG_DEFAULT_AUTHORITY channel arg."); diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index d539ddae8f..701113461f 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -63,9 +63,14 @@ typedef struct { static void client_setup_transport(void* ts, grpc_transport* transport) { sp_client_setup* cs = static_cast(ts); - - cs->f->client = grpc_channel_create("socketpair-target", cs->client_args, + grpc_arg authority_arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), + const_cast("test-authority")); + grpc_channel_args* args = + grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); + cs->f->client = grpc_channel_create("socketpair-target", args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_channel_args_destroy(args); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index 75f64024cd..24a1d6dd32 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -58,8 +58,14 @@ typedef struct { static void client_setup_transport(void* ts, grpc_transport* transport) { sp_client_setup* cs = static_cast(ts); - cs->f->client = grpc_channel_create("socketpair-target", cs->client_args, + grpc_arg authority_arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), + const_cast("test-authority")); + grpc_channel_args* args = + grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); + cs->f->client = grpc_channel_create("socketpair-target", args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_channel_args_destroy(args); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index 929631917d..d812c226e9 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -58,8 +58,14 @@ typedef struct { static void client_setup_transport(void* ts, grpc_transport* transport) { sp_client_setup* cs = static_cast(ts); - cs->f->client = grpc_channel_create("socketpair-target", cs->client_args, + grpc_arg authority_arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), + const_cast("test-authority")); + grpc_channel_args* args = + grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); + cs->f->client = grpc_channel_create("socketpair-target", args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_channel_args_destroy(args); } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index 16acf8ef28..e21006bb67 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -20,6 +20,7 @@ #include #include +#include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/iomgr/executor.h" @@ -58,8 +59,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_create_chttp2_transport(nullptr, mock_endpoint, true); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); + grpc_arg authority_arg = grpc_channel_arg_string_create( + const_cast(GRPC_ARG_DEFAULT_AUTHORITY), + const_cast("test-authority")); + grpc_channel_args* args = + grpc_channel_args_copy_and_add(nullptr, &authority_arg, 1); grpc_channel* channel = grpc_channel_create( - "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport); + "test-target", args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_channel_args_destroy(args); grpc_slice host = grpc_slice_from_static_string("localhost"); grpc_call* call = grpc_channel_create_call( channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host, -- cgit v1.2.3 From c0cd82faedfdfc4af4931d008b07094c8911dfe5 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 14 Mar 2018 15:33:57 -0700 Subject: Remove unnecessary includes of exec_ctx.h --- src/core/ext/filters/client_channel/backup_poller.h | 1 - src/core/ext/filters/client_channel/lb_policy_factory.h | 1 - src/core/ext/filters/client_channel/lb_policy_registry.h | 1 - .../filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h | 1 - .../ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h | 1 - src/core/ext/filters/client_channel/uri_parser.h | 1 - src/core/ext/filters/deadline/deadline_filter.cc | 1 - src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc | 1 - src/core/ext/transport/chttp2/server/chttp2_server.h | 2 +- src/core/ext/transport/chttp2/transport/frame_data.h | 1 - src/core/ext/transport/chttp2/transport/frame_goaway.h | 1 - src/core/ext/transport/chttp2/transport/frame_ping.h | 1 - src/core/ext/transport/chttp2/transport/frame_rst_stream.h | 1 - src/core/ext/transport/chttp2/transport/frame_settings.h | 1 - src/core/ext/transport/chttp2/transport/frame_window_update.h | 1 - src/core/ext/transport/chttp2/transport/hpack_parser.h | 1 - src/core/lib/channel/handshaker_factory.h | 1 - src/core/lib/channel/handshaker_registry.h | 1 - src/core/lib/compression/stream_compression_identity.cc | 1 - src/core/lib/iomgr/call_combiner.h | 1 - src/core/lib/iomgr/lockfree_event.h | 2 +- src/core/lib/iomgr/resolve_address.h | 1 - src/core/lib/iomgr/resource_quota.h | 2 +- src/core/lib/iomgr/socket_windows.h | 1 - src/core/lib/iomgr/timer_uv.h | 2 -- src/core/lib/security/transport/security_handshaker.h | 1 - src/core/lib/slice/slice_buffer.cc | 1 + src/core/lib/slice/slice_internal.h | 2 -- src/core/lib/surface/byte_buffer.cc | 1 + src/core/lib/surface/byte_buffer_reader.cc | 1 + src/core/lib/transport/byte_stream.h | 2 +- src/core/lib/transport/connectivity_state.h | 2 +- src/core/lib/transport/metadata.h | 2 +- src/core/lib/transport/metadata_batch.h | 1 + src/core/lib/transport/status_conversion.h | 1 + .../alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc | 1 + .../alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc | 1 + test/core/compression/algorithm_test.cc | 1 + test/core/end2end/connection_refused_test.cc | 1 + test/core/end2end/tests/cancel_after_accept.cc | 1 + test/core/end2end/tests/cancel_after_round_trip.cc | 1 + test/core/end2end/tests/max_message_length.cc | 1 + test/core/iomgr/resource_quota_test.cc | 1 + test/core/slice/slice_hash_table_test.cc | 1 + test/core/slice/slice_test.cc | 3 +++ test/core/slice/slice_weak_hash_table_test.cc | 1 + test/core/transport/byte_stream_test.cc | 1 + test/core/transport/chttp2/bin_decoder_test.cc | 1 + test/core/transport/chttp2/hpack_parser_fuzzer_test.cc | 1 + test/core/transport/chttp2/hpack_parser_test.cc | 2 ++ test/core/transport/chttp2/hpack_table_test.cc | 1 + test/core/transport/connectivity_state_test.cc | 1 + test/core/transport/metadata_test.cc | 1 + .../alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc | 1 + .../zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc | 1 + 55 files changed, 34 insertions(+), 32 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 7285b9b93e..8f132f968c 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -23,7 +23,6 @@ #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/iomgr/exec_ctx.h" /* Start polling \a interested_parties periodically in the timer thread */ void grpc_client_channel_start_backup_polling( diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index b8bbd32072..6440258158 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -21,7 +21,6 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/ext/filters/client_channel/client_channel_factory.h" diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h index 2283d848bd..2e9bb061ed 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.h +++ b/src/core/ext/filters/client_channel/lb_policy_registry.h @@ -24,7 +24,6 @@ #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" -#include "src/core/lib/iomgr/exec_ctx.h" namespace grpc_core { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h index 0bc13e35f4..6239549534 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset_set.h" typedef struct grpc_ares_ev_driver grpc_ares_ev_driver; diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index bda9cd1729..3e8ea01e12 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -22,7 +22,6 @@ #include #include "src/core/ext/filters/client_channel/lb_policy_factory.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h index 1966da932b..d749f23308 100644 --- a/src/core/ext/filters/client_channel/uri_parser.h +++ b/src/core/ext/filters/client_channel/uri_parser.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" typedef struct { char* scheme; diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index dda3b61108..27d3eac8d6 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -27,7 +27,6 @@ #include #include "src/core/lib/channel/channel_stack_builder.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel_init.h" diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc index 479f0da572..b95c9dae53 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -29,7 +29,6 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/tcp_client_posix.h" #include "src/core/lib/iomgr/tcp_posix.h" #include "src/core/lib/surface/api_trace.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index 7b41972160..6e51001b53 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -23,7 +23,7 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/error.h" /// Adds a port to \a server. Sets \a port_num to the port number. /// Takes ownership of \a args. diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index 4b0f873644..e5d01f764e 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -26,7 +26,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/transport.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index e17ed8d563..66c7a68bef 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -24,7 +24,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { GRPC_CHTTP2_GOAWAY_LSI0, diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 8718d6a097..55a4499ad5 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef struct { uint8_t byte; diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index bb2d34f918..6bcf9c4479 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/transport.h" typedef struct { diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index df19627194..8d8d9b1a91 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -24,7 +24,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { GRPC_CHTTP2_SPS_ID0, diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 30667c77e1..3d2391f637 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/transport.h" typedef struct { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index b3b8018b98..3e05de4b92 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -25,7 +25,6 @@ #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/hpack_table.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/metadata.h" typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h index 9e36443958..3e45fcf20e 100644 --- a/src/core/lib/channel/handshaker_factory.h +++ b/src/core/lib/channel/handshaker_factory.h @@ -24,7 +24,6 @@ #include #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/iomgr/exec_ctx.h" // A handshaker factory is used to create handshakers. diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h index b42d61ff43..82ad9c5b9a 100644 --- a/src/core/lib/channel/handshaker_registry.h +++ b/src/core/lib/channel/handshaker_registry.h @@ -24,7 +24,6 @@ #include #include "src/core/lib/channel/handshaker_factory.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { HANDSHAKER_CLIENT = 0, diff --git a/src/core/lib/compression/stream_compression_identity.cc b/src/core/lib/compression/stream_compression_identity.cc index 52a6236621..b7981394d5 100644 --- a/src/core/lib/compression/stream_compression_identity.cc +++ b/src/core/lib/compression/stream_compression_identity.cc @@ -22,7 +22,6 @@ #include #include "src/core/lib/compression/stream_compression_identity.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #define OUTPUT_BLOCK_SIZE (1024) diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index 16829e5707..0ccd08ea57 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -27,7 +27,6 @@ #include "src/core/lib/gpr/mpscq.h" #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/exec_ctx.h" // A simple, lock-free mechanism for serializing activity related to a // single call. This is similar to a combiner but is more lightweight. diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index 83de656f5f..b507b94648 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -25,7 +25,7 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" namespace grpc_core { diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index 10a7822654..c662406753 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset_set.h" #define GRPC_MAX_SOCKADDR_SIZE 128 diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index 4e1c651278..f939cfd449 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -24,7 +24,7 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" /** \file Tracks resource usage against a pool. diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index 3ff2c307e2..df02c0fc59 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -29,7 +29,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr_internal.h" /* This holds the data for an outstanding read or write on a socket. diff --git a/src/core/lib/iomgr/timer_uv.h b/src/core/lib/iomgr/timer_uv.h index 093b2d085d..10dc46e0c9 100644 --- a/src/core/lib/iomgr/timer_uv.h +++ b/src/core/lib/iomgr/timer_uv.h @@ -21,8 +21,6 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" - struct grpc_timer { grpc_closure* closure; /* This is actually a uv_timer_t*, but we want to keep platform-specific diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index ecf59ec5c5..88483b02e7 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -22,7 +22,6 @@ #include #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/security/security_connector/security_connector.h" /// Creates a security handshaker using \a handshaker. diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index e418ab10ef..58ca495517 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" /* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 065c25c90c..5d3d26b67b 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -24,8 +24,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" - grpc_slice grpc_slice_ref_internal(grpc_slice slice); void grpc_slice_unref_internal(grpc_slice slice); void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb); diff --git a/src/core/lib/surface/byte_buffer.cc b/src/core/lib/surface/byte_buffer.cc index fce87dc611..6246796e46 100644 --- a/src/core/lib/surface/byte_buffer.cc +++ b/src/core/lib/surface/byte_buffer.cc @@ -22,6 +22,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slices, diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc index a10f1a3933..1debc98ea0 100644 --- a/src/core/lib/surface/byte_buffer_reader.cc +++ b/src/core/lib/surface/byte_buffer_reader.cc @@ -29,6 +29,7 @@ #include #include "src/core/lib/compression/message_compress.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" static int is_compressed(grpc_byte_buffer* buffer) { diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index 95a756a5e4..eff832515d 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -24,7 +24,7 @@ #include #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" /** Internal bit flag for grpc_begin_message's \a flags signaling the use of * compression for the message */ diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 421db5aa39..ecb083cfc2 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -23,7 +23,7 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" typedef struct grpc_connectivity_state_watcher { /** we keep watchers in a linked list */ diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 5e0ecbdb96..78df4bc3a3 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -24,8 +24,8 @@ #include #include +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/iomgr/exec_ctx.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 3876063b52..7068750b6f 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -26,6 +26,7 @@ #include #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index 9f14e9bee0..487f00c08b 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -22,6 +22,7 @@ #include #include + #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc index ff91aea350..1048b600f0 100644 --- a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" const size_t kInitialIovecBufferSize = 8; diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc index 8c764961b3..608213745e 100644 --- a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 3dcddf3e67..8989a41989 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index ff830b47cd..33812ec8e5 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -25,6 +25,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index ee1a0bbccc..e94ea51a75 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index bf3be1c8b7..4890b3013f 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index 3dd1737793..fa5b3b6e9b 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc index 921a24ebf2..059ff7b5f8 100644 --- a/test/core/iomgr/resource_quota_test.cc +++ b/test/core/iomgr/resource_quota_test.cc @@ -21,6 +21,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/slice/slice_hash_table_test.cc b/test/core/slice/slice_hash_table_test.cc index 279b543098..43ddfe9bf2 100644 --- a/test/core/slice/slice_hash_table_test.cc +++ b/test/core/slice/slice_hash_table_test.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index 5a49793a9e..e683c41f31 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -16,8 +16,11 @@ * */ +#include + #include +#include #include #include diff --git a/test/core/slice/slice_weak_hash_table_test.cc b/test/core/slice/slice_weak_hash_table_test.cc index 4711d2fd26..b0a243d572 100644 --- a/test/core/slice/slice_weak_hash_table_test.cc +++ b/test/core/slice/slice_weak_hash_table_test.cc @@ -28,6 +28,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index 80692ec2da..df09637249 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -23,6 +23,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc index 751dd90c8c..b4b07986a3 100644 --- a/test/core/transport/chttp2/bin_decoder_test.cc +++ b/test/core/transport/chttp2/bin_decoder_test.cc @@ -25,6 +25,7 @@ #include #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index 9a195daee0..a8eec1eefd 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -24,6 +24,7 @@ #include #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" bool squelch = true; diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 9d3456a873..43b6c79e8a 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -24,6 +24,8 @@ #include #include #include + +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/parse_hexstring.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc index e316cf63a0..3ab463b631 100644 --- a/test/core/transport/chttp2/hpack_table_test.cc +++ b/test/core/transport/chttp2/hpack_table_test.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc index f5894599e5..cbd6318f52 100644 --- a/test/core/transport/connectivity_state_test.cc +++ b/test/core/transport/connectivity_state_test.cc @@ -22,6 +22,7 @@ #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" #include "test/core/util/tracer_util.h" diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc index 786df97285..4be34f72d9 100644 --- a/test/core/transport/metadata_test.cc +++ b/test/core/transport/metadata_test.cc @@ -28,6 +28,7 @@ #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc index fbbea71cb7..b763f19d50 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc @@ -19,6 +19,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc index 2388be95cd..32159e22f2 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc @@ -20,6 +20,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" -- cgit v1.2.3 From 961353ab6d1b48da74e307f805f45509c4a7de7f Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 15 Mar 2018 16:11:05 -0700 Subject: moved filter to ext --- BUILD | 6 +- CMakeLists.txt | 4 +- Makefile | 4 +- build.yaml | 4 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 4 +- package.xml | 4 +- .../ext/filters/http/client_authority_filter.cc | 135 +++++++++++++++++++++ .../ext/filters/http/client_authority_filter.h | 34 ++++++ src/core/lib/channel/client_authority_filter.cc | 135 --------------------- src/core/lib/channel/client_authority_filter.h | 34 ------ src/core/lib/surface/init.cc | 1 - src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 6 +- 19 files changed, 195 insertions(+), 198 deletions(-) create mode 100644 src/core/ext/filters/http/client_authority_filter.cc create mode 100644 src/core/ext/filters/http/client_authority_filter.h delete mode 100644 src/core/lib/channel/client_authority_filter.cc delete mode 100644 src/core/lib/channel/client_authority_filter.h (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 75aebb2462..8a4349eb81 100644 --- a/BUILD +++ b/BUILD @@ -676,7 +676,6 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/client_authority_filter.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -812,7 +811,6 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/client_authority_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -1077,10 +1075,10 @@ grpc_cc_library( grpc_cc_library( name = "grpc_client_authority_filter", srcs = [ - "src/core/lib/channel/client_authority_filter.cc", + "src/core/ext/filters/http/client_authority_filter.cc", ], hdrs = [ - "src/core/lib/channel/client_authority_filter.h", + "src/core/ext/filters/http/client_authority_filter.h", ], language = "c++", deps = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1657f1ae7e..836b36a7eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1132,7 +1132,7 @@ add_library(grpc src/core/ext/census/grpc_context.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc - src/core/lib/channel/client_authority_filter.cc + src/core/ext/filters/http/client_authority_filter.cc src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc src/core/ext/filters/workarounds/workaround_utils.cc src/core/plugin_registry/grpc_plugin_registry.cc @@ -2367,7 +2367,7 @@ add_library(grpc_unsecure src/core/ext/census/grpc_context.cc src/core/ext/filters/max_age/max_age_filter.cc src/core/ext/filters/message_size/message_size_filter.cc - src/core/lib/channel/client_authority_filter.cc + src/core/ext/filters/http/client_authority_filter.cc src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc src/core/ext/filters/workarounds/workaround_utils.cc src/core/plugin_registry/grpc_unsecure_plugin_registry.cc diff --git a/Makefile b/Makefile index 93b3588de2..df30405d8b 100644 --- a/Makefile +++ b/Makefile @@ -3437,7 +3437,7 @@ LIBGRPC_SRC = \ src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ - src/core/lib/channel/client_authority_filter.cc \ + src/core/ext/filters/http/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_plugin_registry.cc \ @@ -4648,7 +4648,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ - src/core/lib/channel/client_authority_filter.cc \ + src/core/ext/filters/http/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_unsecure_plugin_registry.cc \ diff --git a/build.yaml b/build.yaml index 20581ae00e..7a2d5cf884 100644 --- a/build.yaml +++ b/build.yaml @@ -517,9 +517,9 @@ filegroups: - grpc_trace_headers - name: grpc_client_authority_filter headers: - - src/core/lib/channel/client_authority_filter.h + - src/core/ext/filters/http/client_authority_filter.h src: - - src/core/lib/channel/client_authority_filter.cc + - src/core/ext/filters/http/client_authority_filter.cc plugin: grpc_client_authority_filter uses: - grpc_base diff --git a/config.m4 b/config.m4 index 9b48890d4c..756108ba3a 100644 --- a/config.m4 +++ b/config.m4 @@ -361,7 +361,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/census/grpc_context.cc \ src/core/ext/filters/max_age/max_age_filter.cc \ src/core/ext/filters/message_size/message_size_filter.cc \ - src/core/lib/channel/client_authority_filter.cc \ + src/core/ext/filters/http/client_authority_filter.cc \ src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc \ src/core/ext/filters/workarounds/workaround_utils.cc \ src/core/plugin_registry/grpc_plugin_registry.cc \ diff --git a/config.w32 b/config.w32 index b6b417e3de..755dd08007 100644 --- a/config.w32 +++ b/config.w32 @@ -338,7 +338,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\census\\grpc_context.cc " + "src\\core\\ext\\filters\\max_age\\max_age_filter.cc " + "src\\core\\ext\\filters\\message_size\\message_size_filter.cc " + - "src\\core\\lib\\channel\\client_authority_filter.cc " + + "src\\core\\ext\\filters\\http\\client_authority_filter.cc " + "src\\core\\ext\\filters\\workarounds\\workaround_cronet_compression_filter.cc " + "src\\core\\ext\\filters\\workarounds\\workaround_utils.cc " + "src\\core\\plugin_registry\\grpc_plugin_registry.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 5e8ae3f9a6..ae68984e65 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -479,7 +479,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', - 'src/core/lib/channel/client_authority_filter.h', + 'src/core/ext/filters/http/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h' diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 242bc49bd3..e469a99b67 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -490,7 +490,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', - 'src/core/lib/channel/client_authority_filter.h', + 'src/core/ext/filters/http/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.cc', @@ -773,7 +773,7 @@ Pod::Spec.new do |s| 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', - 'src/core/lib/channel/client_authority_filter.cc', + 'src/core/ext/filters/http/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc' @@ -1046,7 +1046,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', - 'src/core/lib/channel/client_authority_filter.h', + 'src/core/ext/filters/http/client_authority_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h' end diff --git a/grpc.gemspec b/grpc.gemspec index 33ca745e69..c797b28d54 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -420,7 +420,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) - s.files += %w( src/core/lib/channel/client_authority_filter.h ) + s.files += %w( src/core/ext/filters/http/client_authority_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.cc ) @@ -706,7 +706,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/census/grpc_context.cc ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.cc ) - s.files += %w( src/core/lib/channel/client_authority_filter.cc ) + s.files += %w( src/core/ext/filters/http/client_authority_filter.cc ) s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.cc ) s.files += %w( src/core/plugin_registry/grpc_plugin_registry.cc ) diff --git a/grpc.gyp b/grpc.gyp index 04421bad57..9448183e69 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -513,7 +513,7 @@ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', - 'src/core/lib/channel/client_authority_filter.cc', + 'src/core/ext/filters/http/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc', @@ -1194,7 +1194,7 @@ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', - 'src/core/lib/channel/client_authority_filter.cc', + 'src/core/ext/filters/http/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_unsecure_plugin_registry.cc', diff --git a/package.xml b/package.xml index a8a3c4f356..79eeffbb0c 100644 --- a/package.xml +++ b/package.xml @@ -427,7 +427,7 @@ - + @@ -713,7 +713,7 @@ - + diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc new file mode 100644 index 0000000000..5294cfdcc5 --- /dev/null +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -0,0 +1,135 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "src/core/ext/filters/http/client_authority_filter.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/surface/call.h" +#include "src/core/lib/surface/channel_init.h" +#include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/transport/static_metadata.h" + +namespace { + +struct call_data { + grpc_linked_mdelem authority_storage; + grpc_call_combiner* call_combiner; +}; + +struct channel_data { + grpc_slice default_authority; +}; + +void authority_start_transport_stream_op_batch( + grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { + channel_data* chand = static_cast(elem->channel_data); + call_data* calld = static_cast(elem->call_data); + // Handle send_initial_metadata. + auto* initial_metadata = + batch->payload->send_initial_metadata.send_initial_metadata; + // If the initial metadata doesn't already contain :authority, add it. + if (batch->send_initial_metadata && + initial_metadata->idx.named.authority == nullptr) { + grpc_error* error = grpc_metadata_batch_add_head( + initial_metadata, &calld->authority_storage, + grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, + grpc_slice_ref(chand->default_authority))); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_batch_finish_with_failure(batch, error, + calld->call_combiner); + return; + } + } + // Pass control down the stack. + grpc_call_next_op(elem, batch); +} + +/* Constructor for call_data */ +grpc_error* init_call_elem(grpc_call_element* elem, + const grpc_call_element_args* args) { + call_data* calld = static_cast(elem->call_data); + calld->call_combiner = args->call_combiner; + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +void destroy_call_elem(grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} + +/* Constructor for channel_data */ +grpc_error* init_channel_elem(grpc_channel_element* elem, + grpc_channel_element_args* args) { + channel_data* chand = static_cast(elem->channel_data); + const grpc_arg* default_authority_arg = + grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); + GPR_ASSERT(default_authority_arg != nullptr); + chand->default_authority = grpc_slice_from_copied_string( + grpc_channel_arg_get_string(default_authority_arg)); + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +void destroy_channel_elem(grpc_channel_element* elem) { + channel_data* chand = static_cast(elem->channel_data); + grpc_slice_unref(chand->default_authority); +} +} // namespace + +const grpc_channel_filter grpc_client_authority_filter = { + authority_start_transport_stream_op_batch, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_channel_next_get_info, + "authority"}; + +static bool add_client_authority_filter(grpc_channel_stack_builder* builder, + void* arg) { + return grpc_channel_stack_builder_prepend_filter( + builder, static_cast(arg), nullptr, nullptr); +} + +void grpc_client_authority_filter_init(void) { + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, + add_client_authority_filter, + (void*)&grpc_client_authority_filter); + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, + add_client_authority_filter, + (void*)&grpc_client_authority_filter); +} + +void grpc_client_authority_filter_shutdown(void) {} diff --git a/src/core/ext/filters/http/client_authority_filter.h b/src/core/ext/filters/http/client_authority_filter.h new file mode 100644 index 0000000000..5824e91ff2 --- /dev/null +++ b/src/core/ext/filters/http/client_authority_filter.h @@ -0,0 +1,34 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_AUTHORITY_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_AUTHORITY_FILTER_H + +#include + +#include + +#include "src/core/lib/channel/channel_stack.h" + +/// Filter responsible for setting the authority header, if not already set. It +/// uses the value of the GRPC_ARG_DEFAULT_AUTHORITY channel arg if the initial +/// metadata doesn't already contain an authority value. + +extern const grpc_channel_filter grpc_client_authority_filter; + +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_AUTHORITY_FILTER_H */ diff --git a/src/core/lib/channel/client_authority_filter.cc b/src/core/lib/channel/client_authority_filter.cc deleted file mode 100644 index bf37f52e9c..0000000000 --- a/src/core/lib/channel/client_authority_filter.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/client_authority_filter.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/surface/call.h" -#include "src/core/lib/surface/channel_init.h" -#include "src/core/lib/surface/channel_stack_type.h" -#include "src/core/lib/transport/static_metadata.h" - -namespace { - -struct call_data { - grpc_linked_mdelem authority_storage; - grpc_call_combiner* call_combiner; -}; - -struct channel_data { - grpc_slice default_authority; -}; - -void authority_start_transport_stream_op_batch( - grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { - channel_data* chand = static_cast(elem->channel_data); - call_data* calld = static_cast(elem->call_data); - // Handle send_initial_metadata. - auto* initial_metadata = - batch->payload->send_initial_metadata.send_initial_metadata; - // If the initial metadata doesn't already contain :authority, add it. - if (batch->send_initial_metadata && - initial_metadata->idx.named.authority == nullptr) { - grpc_error* error = grpc_metadata_batch_add_head( - initial_metadata, &calld->authority_storage, - grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY, - grpc_slice_ref(chand->default_authority))); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_batch_finish_with_failure(batch, error, - calld->call_combiner); - return; - } - } - // Pass control down the stack. - grpc_call_next_op(elem, batch); -} - -/* Constructor for call_data */ -grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { - call_data* calld = static_cast(elem->call_data); - calld->call_combiner = args->call_combiner; - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} - -/* Constructor for channel_data */ -grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { - channel_data* chand = static_cast(elem->channel_data); - const grpc_arg* default_authority_arg = - grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); - GPR_ASSERT(default_authority_arg != nullptr); - chand->default_authority = grpc_slice_from_copied_string( - grpc_channel_arg_get_string(default_authority_arg)); - GPR_ASSERT(!args->is_last); - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -void destroy_channel_elem(grpc_channel_element* elem) { - channel_data* chand = static_cast(elem->channel_data); - grpc_slice_unref(chand->default_authority); -} -} // namespace - -const grpc_channel_filter grpc_client_authority_filter = { - authority_start_transport_stream_op_batch, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_channel_next_get_info, - "authority"}; - -static bool add_client_authority_filter(grpc_channel_stack_builder* builder, - void* arg) { - return grpc_channel_stack_builder_prepend_filter( - builder, static_cast(arg), nullptr, nullptr); -} - -void grpc_client_authority_filter_init(void) { - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, - add_client_authority_filter, - (void*)&grpc_client_authority_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, - add_client_authority_filter, - (void*)&grpc_client_authority_filter); -} - -void grpc_client_authority_filter_shutdown(void) {} diff --git a/src/core/lib/channel/client_authority_filter.h b/src/core/lib/channel/client_authority_filter.h deleted file mode 100644 index c101c359d2..0000000000 --- a/src/core/lib/channel/client_authority_filter.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H - -#include - -#include - -#include "src/core/lib/channel/channel_stack.h" - -/// Filter responsible for setting the authority header, if not already set. It -/// uses the value of the GRPC_ARG_DEFAULT_AUTHORITY channel arg if the initial -/// metadata doesn't already contain an authority value. - -extern const grpc_channel_filter grpc_client_authority_filter; - -#endif /* GRPC_CORE_LIB_CHANNEL_CLIENT_AUTHORITY_FILTER_H */ diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 2d29c7d95f..ac9f9e6066 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,7 +27,6 @@ #include #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/client_authority_filter.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/debug/stats.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index bb426b070f..5c9107cf2a 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -337,7 +337,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/census/grpc_context.cc', 'src/core/ext/filters/max_age/max_age_filter.cc', 'src/core/ext/filters/message_size/message_size_filter.cc', - 'src/core/lib/channel/client_authority_filter.cc', + 'src/core/ext/filters/http/client_authority_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 1f19bac169..68e808675e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -941,6 +941,8 @@ src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/filters/deadline/deadline_filter.h \ src/core/ext/filters/http/client/http_client_filter.cc \ src/core/ext/filters/http/client/http_client_filter.h \ +src/core/ext/filters/http/client_authority_filter.cc \ +src/core/ext/filters/http/client_authority_filter.h \ src/core/ext/filters/http/http_filters_plugin.cc \ src/core/ext/filters/http/message_compress/message_compress_filter.cc \ src/core/ext/filters/http/message_compress/message_compress_filter.h \ @@ -1034,8 +1036,6 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/client_authority_filter.cc \ -src/core/lib/channel/client_authority_filter.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 07edd14b04..e5a0d9a247 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9423,14 +9423,14 @@ "grpc_base" ], "headers": [ - "src/core/lib/channel/client_authority_filter.h" + "src/core/ext/filters/http/client_authority_filter.h" ], "is_filegroup": true, "language": "c", "name": "grpc_client_authority_filter", "src": [ - "src/core/lib/channel/client_authority_filter.cc", - "src/core/lib/channel/client_authority_filter.h" + "src/core/ext/filters/http/client_authority_filter.cc", + "src/core/ext/filters/http/client_authority_filter.h" ], "third_party": false, "type": "filegroup" -- cgit v1.2.3 From f2bea3725f8218777268decfd37c7b543f839d9f Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Mon, 19 Mar 2018 12:05:18 -0700 Subject: Revert "Channel Tracing Implementation; Part 1" --- BUILD | 8 +- CMakeLists.txt | 80 +--- Makefile | 114 +----- build.yaml | 35 +- config.m4 | 4 +- config.w32 | 4 +- gRPC-C++.podspec | 7 +- gRPC-Core.podspec | 12 +- grpc.def | 2 - grpc.gemspec | 8 +- grpc.gyp | 18 +- include/grpc/grpc.h | 8 - include/grpc/impl/codegen/grpc_types.h | 4 - package.xml | 8 +- .../ext/filters/client_channel/client_channel.cc | 2 +- .../ext/filters/client_channel/method_params.cc | 2 +- .../ext/filters/client_channel/method_params.h | 2 +- src/core/ext/filters/client_channel/status_util.cc | 100 +++++ src/core/ext/filters/client_channel/status_util.h | 58 +++ src/core/ext/filters/client_channel/subchannel.cc | 1 - src/core/lib/channel/channel_trace.cc | 238 ----------- src/core/lib/channel/channel_trace.h | 133 ------ src/core/lib/channel/channel_trace_registry.cc | 80 ---- src/core/lib/channel/channel_trace_registry.h | 43 -- src/core/lib/channel/status_util.cc | 100 ----- src/core/lib/channel/status_util.h | 58 --- src/core/lib/json/json.cc | 36 -- src/core/lib/json/json.h | 21 +- src/core/lib/surface/channel.cc | 33 +- src/core/lib/surface/init.cc | 3 - src/proto/grpc/channelz/BUILD | 26 -- src/proto/grpc/channelz/channelz.proto | 456 --------------------- src/python/grpcio/grpc_core_dependencies.py | 4 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 - src/ruby/ext/grpc/rb_grpc_imports.generated.h | 6 - test/core/channel/BUILD | 29 -- test/core/channel/channel_trace_test.cc | 240 ----------- test/core/channel/status_util_test.cc | 49 --- test/core/client_channel/BUILD | 12 + test/core/client_channel/status_util_test.cc | 49 +++ test/core/surface/public_headers_must_be_c89.c | 2 - test/cpp/util/BUILD | 18 - test/cpp/util/channel_trace_proto_helper.cc | 56 --- test/cpp/util/channel_trace_proto_helper.h | 30 -- tools/doxygen/Doxyfile.c++.internal | 3 - tools/doxygen/Doxyfile.core.internal | 8 +- tools/run_tests/generated/sources_and_headers.json | 55 +-- tools/run_tests/generated/tests.json | 24 -- 48 files changed, 273 insertions(+), 2020 deletions(-) create mode 100644 src/core/ext/filters/client_channel/status_util.cc create mode 100644 src/core/ext/filters/client_channel/status_util.h delete mode 100644 src/core/lib/channel/channel_trace.cc delete mode 100644 src/core/lib/channel/channel_trace.h delete mode 100644 src/core/lib/channel/channel_trace_registry.cc delete mode 100644 src/core/lib/channel/channel_trace_registry.h delete mode 100644 src/core/lib/channel/status_util.cc delete mode 100644 src/core/lib/channel/status_util.h delete mode 100644 src/proto/grpc/channelz/BUILD delete mode 100644 src/proto/grpc/channelz/channelz.proto delete mode 100644 test/core/channel/channel_trace_test.cc delete mode 100644 test/core/channel/status_util_test.cc create mode 100644 test/core/client_channel/status_util_test.cc delete mode 100644 test/cpp/util/channel_trace_proto_helper.cc delete mode 100644 test/cpp/util/channel_trace_proto_helper.h (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index d59d2ad63f..6c18ad94d7 100644 --- a/BUILD +++ b/BUILD @@ -676,9 +676,6 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_trace.cc", - "src/core/lib/channel/channel_trace_registry.cc", - "src/core/lib/channel/status_util.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -823,9 +820,6 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channel_trace_registry.h", - "src/core/lib/channel/status_util.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -1022,6 +1016,7 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver.cc", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/retry_throttle.cc", + "src/core/ext/filters/client_channel/status_util.cc", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel_index.cc", "src/core/ext/filters/client_channel/uri_parser.cc", @@ -1044,6 +1039,7 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", + "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 56dcb4671b..77e84a0df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -532,7 +532,6 @@ endif() add_dependencies(buildtests_cxx byte_stream_test) add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) -add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx check_gcp_environment_linux_test) add_dependencies(buildtests_cxx check_gcp_environment_windows_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) @@ -856,13 +855,10 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1111,6 +1107,7 @@ add_library(grpc src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1244,13 +1241,10 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1437,6 +1431,7 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1623,13 +1618,10 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1785,6 +1777,7 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1925,13 +1918,10 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2087,6 +2077,7 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2207,13 +2198,10 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2402,6 +2390,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -3023,13 +3012,10 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -3190,6 +3176,7 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc + src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -3694,10 +3681,6 @@ if (gRPC_BUILD_TESTS) if (gRPC_BUILD_CODEGEN) add_library(grpc++_test_util - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.h @@ -3717,7 +3700,6 @@ add_library(grpc++_test_util ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h test/cpp/end2end/test_service_impl.cc test/cpp/util/byte_buffer_proto_helper.cc - test/cpp/util/channel_trace_proto_helper.cc test/cpp/util/create_test_channel.cc test/cpp/util/string_ref_helper.cc test/cpp/util/subprocess.cc @@ -3736,9 +3718,6 @@ if(WIN32 AND MSVC) endif() endif() -protobuf_generate_grpc_cpp( - src/proto/grpc/channelz/channelz.proto -) protobuf_generate_grpc_cpp( src/proto/grpc/health/v1/health.proto ) @@ -10149,51 +10128,6 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(channel_trace_test - test/core/channel/channel_trace_test.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - -protobuf_generate_grpc_cpp( - src/proto/grpc/channelz/channelz.proto -) - -target_include_directories(channel_trace_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(channel_trace_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc++_test_util - grpc++ - grpc - gpr_test_util - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(check_gcp_environment_linux_test test/core/security/check_gcp_environment_linux_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -13139,7 +13073,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(status_util_test - test/core/channel/status_util_test.cc + test/core/client_channel/status_util_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) diff --git a/Makefile b/Makefile index 50889716bd..3fa0f6617b 100644 --- a/Makefile +++ b/Makefile @@ -1129,7 +1129,6 @@ bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test -channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test check_gcp_environment_linux_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test check_gcp_environment_windows_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test @@ -1615,7 +1614,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ @@ -1782,7 +1780,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ @@ -2208,8 +2205,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) - $(E) "[RUN] Testing channel_trace_test" - $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing check_gcp_environment_linux_test" $(Q) $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test || ( echo test check_gcp_environment_linux_test failed ; exit 1 ) $(E) "[RUN] Testing check_gcp_environment_windows_test" @@ -2448,22 +2443,6 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(Q) mkdir -p $(@D) $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@ -ifeq ($(NO_PROTOC),true) -$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: protoc_dep_error -$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: protoc_dep_error -else - -$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: src/proto/grpc/channelz/channelz.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) - $(E) "[PROTOC] Generating protobuf CC file from $<" - $(Q) mkdir -p `dirname $@` - $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< - -$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: src/proto/grpc/channelz/channelz.proto $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) - $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" - $(Q) mkdir -p `dirname $@` - $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< -endif - ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/core/stats.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/core/stats.grpc.pb.cc: protoc_dep_error @@ -3181,13 +3160,10 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3436,6 +3412,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3571,13 +3548,10 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3764,6 +3738,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3951,13 +3926,10 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4113,6 +4085,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4246,13 +4219,10 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4408,6 +4378,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4508,13 +4479,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4703,6 +4671,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -5323,13 +5292,10 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5490,6 +5456,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -6017,14 +5984,12 @@ endif LIBGRPC++_TEST_UTIL_SRC = \ - $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc \ test/cpp/end2end/test_service_impl.cc \ test/cpp/util/byte_buffer_proto_helper.cc \ - test/cpp/util/channel_trace_proto_helper.cc \ test/cpp/util/create_test_channel.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ @@ -6160,14 +6125,13 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_TEST_UTIL_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc LIBGRPC++_TEST_UTIL_UNSECURE_SRC = \ @@ -16025,53 +15989,6 @@ endif endif -CHANNEL_TRACE_TEST_SRC = \ - test/core/channel/channel_trace_test.cc \ - $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ - -CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/channel_trace_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. - -$(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) -endif -endif -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc - - CHECK_GCP_ENVIRONMENT_LINUX_TEST_SRC = \ test/core/security/check_gcp_environment_linux_test.cc \ @@ -19194,7 +19111,7 @@ endif STATUS_UTIL_TEST_SRC = \ - test/core/channel/status_util_test.cc \ + test/core/client_channel/status_util_test.cc \ STATUS_UTIL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_UTIL_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -19225,7 +19142,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/core/channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a +$(OBJDIR)/$(CONFIG)/test/core/client_channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a deps_status_util_test: $(STATUS_UTIL_TEST_OBJS:.o=.dep) @@ -23637,7 +23554,6 @@ test/cpp/qps/server_async.cc: $(OPENSSL_DEP) test/cpp/qps/server_sync.cc: $(OPENSSL_DEP) test/cpp/qps/usage_timer.cc: $(OPENSSL_DEP) test/cpp/util/byte_buffer_proto_helper.cc: $(OPENSSL_DEP) -test/cpp/util/channel_trace_proto_helper.cc: $(OPENSSL_DEP) test/cpp/util/cli_call.cc: $(OPENSSL_DEP) test/cpp/util/cli_credentials.cc: $(OPENSSL_DEP) test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 0dd3d36d8c..a4875df9e5 100644 --- a/build.yaml +++ b/build.yaml @@ -232,13 +232,10 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - - src/core/lib/channel/channel_trace.cc - - src/core/lib/channel/channel_trace_registry.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc - - src/core/lib/channel/status_util.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -402,14 +399,11 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - - src/core/lib/channel/channel_trace.h - - src/core/lib/channel/channel_trace_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - - src/core/lib/channel/status_util.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h @@ -553,6 +547,7 @@ filegroups: - src/core/ext/filters/client_channel/resolver_factory.h - src/core/ext/filters/client_channel/resolver_registry.h - src/core/ext/filters/client_channel/retry_throttle.h + - src/core/ext/filters/client_channel/status_util.h - src/core/ext/filters/client_channel/subchannel.h - src/core/ext/filters/client_channel/subchannel_index.h - src/core/ext/filters/client_channel/uri_parser.h @@ -575,6 +570,7 @@ filegroups: - src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/retry_throttle.cc + - src/core/ext/filters/client_channel/status_util.cc - src/core/ext/filters/client_channel/subchannel.cc - src/core/ext/filters/client_channel/subchannel_index.cc - src/core/ext/filters/client_channel/uri_parser.cc @@ -1070,10 +1066,6 @@ filegroups: secure: true uses: - grpc_trace -- name: grpc++_channelz_proto - language: c++ - src: - - src/proto/grpc/channelz/channelz.proto - name: grpc++_codegen_base language: c++ public_headers: @@ -1622,20 +1614,17 @@ libs: headers: - test/cpp/end2end/test_service_impl.h - test/cpp/util/byte_buffer_proto_helper.h - - test/cpp/util/channel_trace_proto_helper.h - test/cpp/util/create_test_channel.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h src: - - src/proto/grpc/channelz/channelz.proto - src/proto/grpc/health/v1/health.proto - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo.proto - src/proto/grpc/testing/duplicate/echo_duplicate.proto - test/cpp/end2end/test_service_impl.cc - test/cpp/util/byte_buffer_proto_helper.cc - - test/cpp/util/channel_trace_proto_helper.cc - test/cpp/util/create_test_channel.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc @@ -4118,24 +4107,6 @@ targets: - grpc - gpr uses_polling: false -- name: channel_trace_test - gtest: true - build: test - language: c++ - src: - - test/core/channel/channel_trace_test.cc - deps: - - grpc_test_util - - grpc++_test_util - - grpc++ - - grpc - - gpr_test_util - - gpr - filegroups: - - grpc++_channelz_proto - uses: - - grpc++_test - uses_polling: false - name: check_gcp_environment_linux_test build: test language: c++ @@ -5157,7 +5128,7 @@ targets: build: test language: c++ src: - - test/core/channel/status_util_test.cc + - test/core/client_channel/status_util_test.cc deps: - grpc uses_polling: false diff --git a/config.m4 b/config.m4 index 3a81f9d7f9..2f17d0c4b7 100644 --- a/config.m4 +++ b/config.m4 @@ -84,13 +84,10 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_trace.cc \ - src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -339,6 +336,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ + src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ diff --git a/config.w32 b/config.w32 index 76be896e44..78f2fe079d 100644 --- a/config.w32 +++ b/config.w32 @@ -61,13 +61,10 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + - "src\\core\\lib\\channel\\channel_trace.cc " + - "src\\core\\lib\\channel\\channel_trace_registry.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + - "src\\core\\lib\\channel\\status_util.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + @@ -316,6 +313,7 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " + "src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " + + "src\\core\\ext\\filters\\client_channel\\status_util.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " + "src\\core\\ext\\filters\\client_channel\\uri_parser.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index f42bd4f81c..e1282611b0 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -326,6 +326,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', + 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -342,14 +343,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -526,14 +524,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 634bff2f06..39433ff819 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -337,6 +337,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', + 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -353,14 +354,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -502,13 +500,10 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -754,6 +749,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -908,6 +904,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', + 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -924,14 +921,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_trace.h', - 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.def b/grpc.def index 5ff3a1efe8..2bafebbbd4 100644 --- a/grpc.def +++ b/grpc.def @@ -45,8 +45,6 @@ EXPORTS grpc_insecure_channel_create grpc_lame_client_channel_create grpc_channel_destroy - grpc_channel_get_trace - grpc_channel_get_uuid grpc_call_cancel grpc_call_cancel_with_status grpc_call_ref diff --git a/grpc.gemspec b/grpc.gemspec index 3b07dd6433..3a57829943 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -267,6 +267,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver_factory.h ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.h ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.h ) + s.files += %w( src/core/ext/filters/client_channel/status_util.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) @@ -283,14 +284,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) - s.files += %w( src/core/lib/channel/channel_trace.h ) - s.files += %w( src/core/lib/channel/channel_trace_registry.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) - s.files += %w( src/core/lib/channel/status_util.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -432,13 +430,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) - s.files += %w( src/core/lib/channel/channel_trace.cc ) - s.files += %w( src/core/lib/channel/channel_trace_registry.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) - s.files += %w( src/core/lib/channel/status_util.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) @@ -687,6 +682,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc ) + s.files += %w( src/core/ext/filters/client_channel/status_util.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc ) diff --git a/grpc.gyp b/grpc.gyp index fc9a45d307..403d32831b 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -237,13 +237,10 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -492,6 +489,7 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -582,13 +580,10 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -744,6 +739,7 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -812,13 +808,10 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -974,6 +967,7 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -1021,13 +1015,10 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -1216,6 +1207,7 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -1396,14 +1388,12 @@ 'grpc', ], 'sources': [ - 'src/proto/grpc/channelz/channelz.proto', 'src/proto/grpc/health/v1/health.proto', 'src/proto/grpc/testing/echo_messages.proto', 'src/proto/grpc/testing/echo.proto', 'src/proto/grpc/testing/duplicate/echo_duplicate.proto', 'test/cpp/end2end/test_service_impl.cc', 'test/cpp/util/byte_buffer_proto_helper.cc', - 'test/cpp/util/channel_trace_proto_helper.cc', 'test/cpp/util/create_test_channel.cc', 'test/cpp/util/string_ref_helper.cc', 'test/cpp/util/subprocess.cc', diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index dd8a5d7d5f..c129a66949 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,14 +286,6 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -/** Returns the JSON formatted channel trace for this channel. The caller - owns the returned string and is responsible for freeing it. */ -GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel); - -/** Returns the channel uuid, which can be used to look up its trace at a - later time. */ -GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); - /** Error handling for grpc_call Most grpc_call functions return a grpc_error. If the error is not GRPC_OK then the operation failed due to some unsatisfied precondition. diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index b671ad653e..dcce2e7f9a 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -281,10 +281,6 @@ typedef struct { #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" /** The grpc_socket_factory instance to create and bind sockets. A pointer. */ #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" -/** The maximum number of trace events to keep in the tracer for each channel or - * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ -#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE \ - "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/package.xml b/package.xml index 0b3fc3a9a0..8f0dc55dbf 100644 --- a/package.xml +++ b/package.xml @@ -274,6 +274,7 @@ + @@ -290,14 +291,11 @@ - - - @@ -439,13 +437,10 @@ - - - @@ -694,6 +689,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index bf3911e5ee..bbc5160bec 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -38,12 +38,12 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/retry_throttle.h" +#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/ext/filters/client_channel/method_params.cc b/src/core/ext/filters/client_channel/method_params.cc index 1f116bb67d..374b87e170 100644 --- a/src/core/ext/filters/client_channel/method_params.cc +++ b/src/core/ext/filters/client_channel/method_params.cc @@ -26,7 +26,7 @@ #include #include "src/core/ext/filters/client_channel/method_params.h" -#include "src/core/lib/channel/status_util.h" +#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h index 099924edf3..48ece29867 100644 --- a/src/core/ext/filters/client_channel/method_params.h +++ b/src/core/ext/filters/client_channel/method_params.h @@ -21,7 +21,7 @@ #include -#include "src/core/lib/channel/status_util.h" +#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis diff --git a/src/core/ext/filters/client_channel/status_util.cc b/src/core/ext/filters/client_channel/status_util.cc new file mode 100644 index 0000000000..11f732ab44 --- /dev/null +++ b/src/core/ext/filters/client_channel/status_util.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/ext/filters/client_channel/status_util.h" + +#include "src/core/lib/gpr/useful.h" + +typedef struct { + const char* str; + grpc_status_code status; +} status_string_entry; + +static const status_string_entry g_status_string_entries[] = { + {"OK", GRPC_STATUS_OK}, + {"CANCELLED", GRPC_STATUS_CANCELLED}, + {"UNKNOWN", GRPC_STATUS_UNKNOWN}, + {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, + {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, + {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, + {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, + {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, + {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, + {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, + {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, + {"ABORTED", GRPC_STATUS_ABORTED}, + {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, + {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, + {"INTERNAL", GRPC_STATUS_INTERNAL}, + {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, + {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, +}; + +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { + if (strcmp(status_str, g_status_string_entries[i].str) == 0) { + *status = g_status_string_entries[i].status; + return true; + } + } + return false; +} + +const char* grpc_status_code_to_string(grpc_status_code status) { + switch (status) { + case GRPC_STATUS_OK: + return "OK"; + case GRPC_STATUS_CANCELLED: + return "CANCELLED"; + case GRPC_STATUS_UNKNOWN: + return "UNKNOWN"; + case GRPC_STATUS_INVALID_ARGUMENT: + return "INVALID_ARGUMENT"; + case GRPC_STATUS_DEADLINE_EXCEEDED: + return "DEADLINE_EXCEEDED"; + case GRPC_STATUS_NOT_FOUND: + return "NOT_FOUND"; + case GRPC_STATUS_ALREADY_EXISTS: + return "ALREADY_EXISTS"; + case GRPC_STATUS_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case GRPC_STATUS_UNAUTHENTICATED: + return "UNAUTHENTICATED"; + case GRPC_STATUS_RESOURCE_EXHAUSTED: + return "RESOURCE_EXHAUSTED"; + case GRPC_STATUS_FAILED_PRECONDITION: + return "FAILED_PRECONDITION"; + case GRPC_STATUS_ABORTED: + return "ABORTED"; + case GRPC_STATUS_OUT_OF_RANGE: + return "OUT_OF_RANGE"; + case GRPC_STATUS_UNIMPLEMENTED: + return "UNIMPLEMENTED"; + case GRPC_STATUS_INTERNAL: + return "INTERNAL"; + case GRPC_STATUS_UNAVAILABLE: + return "UNAVAILABLE"; + case GRPC_STATUS_DATA_LOSS: + return "DATA_LOSS"; + default: + return "UNKNOWN"; + } +} diff --git a/src/core/ext/filters/client_channel/status_util.h b/src/core/ext/filters/client_channel/status_util.h new file mode 100644 index 0000000000..e018709730 --- /dev/null +++ b/src/core/ext/filters/client_channel/status_util.h @@ -0,0 +1,58 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H + +#include + +#include + +#include +#include + +/// If \a status_str is a valid status string, sets \a status to the +/// corresponding status value and returns true. +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status); + +/// Returns the string form of \a status, or "UNKNOWN" if invalid. +const char* grpc_status_code_to_string(grpc_status_code status); + +namespace grpc_core { +namespace internal { + +/// A set of grpc_status_code values. +class StatusCodeSet { + public: + bool Empty() const { return status_code_mask_ == 0; } + + void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } + + bool Contains(grpc_status_code status) const { + return status_code_mask_ & (1 << status); + } + + private: + int status_code_mask_ = 0; // A bitfield of status codes in the set. +}; + +} // namespace internal +} // namespace grpc_core + +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H */ diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index d7815fb7e1..cae7cc35e3 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -40,7 +40,6 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc deleted file mode 100644 index 67d5fd364b..0000000000 --- a/src/core/lib/channel/channel_trace.cc +++ /dev/null @@ -1,238 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/channel/channel_trace.h" - -#include -#include -#include -#include -#include -#include - -#include "src/core/lib/channel/channel_trace_registry.h" -#include "src/core/lib/channel/status_util.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/surface/channel.h" -#include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/error_utils.h" - -namespace grpc_core { - -ChannelTrace::TraceEvent::TraceEvent( - Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer, ReferencedType type) - : severity_(severity), - data_(data), - timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME)), - next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)), - referenced_type_(type) {} - -ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data) - : severity_(severity), - data_(data), - timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME)), - next_(nullptr) {} - -ChannelTrace::TraceEvent::~TraceEvent() { grpc_slice_unref_internal(data_); } - -ChannelTrace::ChannelTrace(size_t max_events) - : channel_uuid_(-1), - num_events_logged_(0), - list_size_(0), - max_list_size_(max_events), - head_trace_(nullptr), - tail_trace_(nullptr) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - gpr_mu_init(&tracer_mu_); - channel_uuid_ = grpc_channel_trace_registry_register_channel_trace(this); - time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), - GPR_CLOCK_REALTIME); -} - -ChannelTrace::~ChannelTrace() { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - TraceEvent* it = head_trace_; - while (it != nullptr) { - TraceEvent* to_free = it; - it = it->next(); - Delete(to_free); - } - grpc_channel_trace_registry_unregister_channel_trace(channel_uuid_); - gpr_mu_destroy(&tracer_mu_); -} - -intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } - -void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { - ++num_events_logged_; - // first event case - if (head_trace_ == nullptr) { - head_trace_ = tail_trace_ = new_trace_event; - } - // regular event add case - else { - tail_trace_->set_next(new_trace_event); - tail_trace_ = tail_trace_->next(); - } - ++list_size_; - // maybe garbage collect the end - if (list_size_ > max_list_size_) { - TraceEvent* to_free = head_trace_; - head_trace_ = head_trace_->next(); - Delete(to_free); - --list_size_; - } -} - -void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - AddTraceEventHelper(New(severity, data)); -} - -void ChannelTrace::AddTraceEventReferencingChannel( - Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - // create and fill up the new event - AddTraceEventHelper( - New(severity, data, std::move(referenced_tracer), Channel)); -} - -void ChannelTrace::AddTraceEventReferencingSubchannel( - Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer) { - if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - // create and fill up the new event - AddTraceEventHelper(New( - severity, data, std::move(referenced_tracer), Subchannel)); -} - -namespace { - -// returns an allocated string that represents tm according to RFC-3339, and, -// more specifically, follows: -// https://developers.google.com/protocol-buffers/docs/proto3#json -// -// "Uses RFC 3339, where generated output will always be Z-normalized and uses -// 0, 3, 6 or 9 fractional digits." -char* fmt_time(gpr_timespec tm) { - char time_buffer[35]; - char ns_buffer[11]; // '.' + 9 digits of precision - struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); - strftime(time_buffer, sizeof(time_buffer), "%Y-%m-%dT%H:%M:%S", tm_info); - snprintf(ns_buffer, 11, ".%09d", tm.tv_nsec); - // This loop trims off trailing zeros by inserting a null character that the - // right point. We iterate in chunks of three because we want 0, 3, 6, or 9 - // fractional digits. - for (int i = 7; i >= 1; i -= 3) { - if (ns_buffer[i] == '0' && ns_buffer[i + 1] == '0' && - ns_buffer[i + 2] == '0') { - ns_buffer[i] = '\0'; - // Edge case in which all fractional digits were 0. - if (i == 1) { - ns_buffer[0] = '\0'; - } - } else { - break; - } - } - char* full_time_str; - gpr_asprintf(&full_time_str, "%s%sZ", time_buffer, ns_buffer); - return full_time_str; -} - -const char* severity_string(ChannelTrace::Severity severity) { - switch (severity) { - case ChannelTrace::Severity::Info: - return "CT_INFO"; - case ChannelTrace::Severity::Warning: - return "CT_WARNING"; - case ChannelTrace::Severity::Error: - return "CT_ERROR"; - default: - GPR_UNREACHABLE_CODE(return "CT_UNKNOWN"); - } -} - -} // anonymous namespace - -void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { - grpc_json* json_iterator = nullptr; - json_iterator = grpc_json_create_child(json_iterator, json, "description", - grpc_slice_to_c_string(data_), - GRPC_JSON_STRING, true); - json_iterator = grpc_json_create_child(json_iterator, json, "severity", - severity_string(severity_), - GRPC_JSON_STRING, false); - json_iterator = - grpc_json_create_child(json_iterator, json, "timestamp", - fmt_time(timestamp_), GRPC_JSON_STRING, true); - if (referenced_tracer_ != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); - grpc_json* child_ref = grpc_json_create_child( - json_iterator, json, - (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", nullptr, - GRPC_JSON_OBJECT, false); - json_iterator = grpc_json_create_child( - nullptr, child_ref, - (referenced_type_ == Channel) ? "channelId" : "subchannelId", uuid_str, - GRPC_JSON_STRING, true); - json_iterator = child_ref; - } -} - -char* ChannelTrace::RenderTrace() const { - if (!max_list_size_) - return nullptr; // tracing is disabled if max_events == 0 - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - char* num_events_logged_str; - gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); - grpc_json* json_iterator = nullptr; - json_iterator = - grpc_json_create_child(json_iterator, json, "numEventsLogged", - num_events_logged_str, GRPC_JSON_STRING, true); - json_iterator = - grpc_json_create_child(json_iterator, json, "creationTime", - fmt_time(time_created_), GRPC_JSON_STRING, true); - grpc_json* events = grpc_json_create_child(json_iterator, json, "events", - nullptr, GRPC_JSON_ARRAY, false); - json_iterator = nullptr; - TraceEvent* it = head_trace_; - while (it != nullptr) { - json_iterator = grpc_json_create_child(json_iterator, events, nullptr, - nullptr, GRPC_JSON_OBJECT, false); - it->RenderTraceEvent(json_iterator); - it = it->next(); - } - char* json_str = grpc_json_dump_to_string(json, 0); - grpc_json_destroy(json); - return json_str; -} - -} // namespace grpc_core diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h deleted file mode 100644 index 1df1e585f2..0000000000 --- a/src/core/lib/channel/channel_trace.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H - -#include - -#include -#include "src/core/lib/gprpp/ref_counted.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/json/json.h" - -namespace grpc_core { - -// Object used to hold live data for a channel. This data is exposed via the -// channelz service: -// https://github.com/grpc/proposal/blob/master/A14-channelz.md -class ChannelTrace : public RefCounted { - public: - ChannelTrace(size_t max_events); - ~ChannelTrace(); - - // returns the tracer's uuid - intptr_t GetUuid() const; - - enum Severity { - Unset = 0, // never to be used - Info, // we start at 1 to avoid using proto default values - Warning, - Error - }; - - // Adds a new trace event to the tracing object - // - // TODO(ncteisen): as this call is used more and more throughout the gRPC - // stack, determine if it makes more sense to accept a char* instead of a - // slice. - void AddTraceEvent(Severity severity, grpc_slice data); - - // Adds a new trace event to the tracing object. This trace event refers to a - // an event on a child of the channel. For example, if this channel has - // created a new subchannel, then it would record that with a TraceEvent - // referencing the new subchannel. - // - // TODO(ncteisen): Once channelz is implemented, the events should reference - // the overall channelz object, not just the ChannelTrace object. - // TODO(ncteisen): as this call is used more and more throughout the gRPC - // stack, determine if it makes more sense to accept a char* instead of a - // slice. - void AddTraceEventReferencingChannel( - Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer); - void AddTraceEventReferencingSubchannel( - Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer); - - // Returns the tracing data rendered as a grpc json string. - // The string is owned by the caller and must be freed. - char* RenderTrace() const; - - private: - // Types of objects that can be references by trace events. - enum ReferencedType { Channel, Subchannel }; - // Private class to encapsulate all the data and bookkeeping needed for a - // a trace event. - class TraceEvent { - public: - // Constructor for a TraceEvent that references a different channel. - // TODO(ncteisen): once channelz is implemented, this should reference the - // overall channelz object, not just the ChannelTrace object - TraceEvent(Severity severity, grpc_slice data, - RefCountedPtr referenced_tracer, - ReferencedType type); - - // Constructor for a TraceEvent that does not reverence a different - // channel. - TraceEvent(Severity severity, grpc_slice data); - - ~TraceEvent(); - - // Renders the data inside of this TraceEvent into a json object. This is - // used by the ChannelTrace, when it is rendering itself. - void RenderTraceEvent(grpc_json* json) const; - - // set and get for the next_ pointer. - TraceEvent* next() const { return next_; } - void set_next(TraceEvent* next) { next_ = next; } - - private: - Severity severity_; - grpc_slice data_; - gpr_timespec timestamp_; - TraceEvent* next_; - // the tracer object for the (sub)channel that this trace event refers to. - RefCountedPtr referenced_tracer_; - // the type that the referenced tracer points to. Unused if this trace - // does not point to any channel or subchannel - ReferencedType referenced_type_; - }; // TraceEvent - - // Internal helper to add and link in a trace event - void AddTraceEventHelper(TraceEvent* new_trace_event); - - gpr_mu tracer_mu_; - intptr_t channel_uuid_; - uint64_t num_events_logged_; - size_t list_size_; - size_t max_list_size_; - TraceEvent* head_trace_; - TraceEvent* tail_trace_; - gpr_timespec time_created_; -}; - -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H */ diff --git a/src/core/lib/channel/channel_trace_registry.cc b/src/core/lib/channel/channel_trace_registry.cc deleted file mode 100644 index 6c82431467..0000000000 --- a/src/core/lib/channel/channel_trace_registry.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/avl/avl.h" -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channel_trace_registry.h" -#include "src/core/lib/gpr/useful.h" - -#include -#include - -// file global lock and avl. -static gpr_mu g_mu; -static grpc_avl g_avl; -static gpr_atm g_uuid = 0; - -// avl vtable for uuid (intptr_t) -> ChannelTrace -// this table is only looking, it does not own anything. -static void destroy_intptr(void* not_used, void* user_data) {} -static void* copy_intptr(void* key, void* user_data) { return key; } -static long compare_intptr(void* key1, void* key2, void* user_data) { - return GPR_ICMP(key1, key2); -} - -static void destroy_channel_trace(void* trace, void* user_data) {} -static void* copy_channel_trace(void* trace, void* user_data) { return trace; } -static const grpc_avl_vtable avl_vtable = { - destroy_intptr, copy_intptr, compare_intptr, destroy_channel_trace, - copy_channel_trace}; - -void grpc_channel_trace_registry_init() { - gpr_mu_init(&g_mu); - g_avl = grpc_avl_create(&avl_vtable); -} - -void grpc_channel_trace_registry_shutdown() { - grpc_avl_unref(g_avl, nullptr); - gpr_mu_destroy(&g_mu); -} - -intptr_t grpc_channel_trace_registry_register_channel_trace( - grpc_core::ChannelTrace* channel_trace) { - intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); - gpr_mu_lock(&g_mu); - g_avl = grpc_avl_add(g_avl, (void*)prior, channel_trace, nullptr); - gpr_mu_unlock(&g_mu); - return prior; -} - -void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid) { - gpr_mu_lock(&g_mu); - g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr); - gpr_mu_unlock(&g_mu); -} - -grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( - intptr_t uuid) { - gpr_mu_lock(&g_mu); - grpc_core::ChannelTrace* ret = static_cast( - grpc_avl_get(g_avl, (void*)uuid, nullptr)); - gpr_mu_unlock(&g_mu); - return ret; -} diff --git a/src/core/lib/channel/channel_trace_registry.h b/src/core/lib/channel/channel_trace_registry.h deleted file mode 100644 index 391ecba7de..0000000000 --- a/src/core/lib/channel/channel_trace_registry.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H - -#include - -#include "src/core/lib/channel/channel_trace.h" - -#include - -// TODO(ncteisen): convert this file to C++ - -void grpc_channel_trace_registry_init(); -void grpc_channel_trace_registry_shutdown(); - -// globally registers a ChannelTrace. Returns its unique uuid -intptr_t grpc_channel_trace_registry_register_channel_trace( - grpc_core::ChannelTrace* channel_trace); -// globally unregisters the ChannelTrace that is associated to uuid. -void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid); -// if object with uuid has previously been registered, returns the ChannelTrace -// associated with that uuid. Else returns nullptr. -grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( - intptr_t uuid); - -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H */ diff --git a/src/core/lib/channel/status_util.cc b/src/core/lib/channel/status_util.cc deleted file mode 100644 index 563db40846..0000000000 --- a/src/core/lib/channel/status_util.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/channel/status_util.h" - -#include "src/core/lib/gpr/useful.h" - -typedef struct { - const char* str; - grpc_status_code status; -} status_string_entry; - -static const status_string_entry g_status_string_entries[] = { - {"OK", GRPC_STATUS_OK}, - {"CANCELLED", GRPC_STATUS_CANCELLED}, - {"UNKNOWN", GRPC_STATUS_UNKNOWN}, - {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, - {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, - {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, - {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, - {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, - {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, - {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, - {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, - {"ABORTED", GRPC_STATUS_ABORTED}, - {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, - {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, - {"INTERNAL", GRPC_STATUS_INTERNAL}, - {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, - {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, -}; - -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status) { - for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { - if (strcmp(status_str, g_status_string_entries[i].str) == 0) { - *status = g_status_string_entries[i].status; - return true; - } - } - return false; -} - -const char* grpc_status_code_to_string(grpc_status_code status) { - switch (status) { - case GRPC_STATUS_OK: - return "OK"; - case GRPC_STATUS_CANCELLED: - return "CANCELLED"; - case GRPC_STATUS_UNKNOWN: - return "UNKNOWN"; - case GRPC_STATUS_INVALID_ARGUMENT: - return "INVALID_ARGUMENT"; - case GRPC_STATUS_DEADLINE_EXCEEDED: - return "DEADLINE_EXCEEDED"; - case GRPC_STATUS_NOT_FOUND: - return "NOT_FOUND"; - case GRPC_STATUS_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case GRPC_STATUS_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case GRPC_STATUS_UNAUTHENTICATED: - return "UNAUTHENTICATED"; - case GRPC_STATUS_RESOURCE_EXHAUSTED: - return "RESOURCE_EXHAUSTED"; - case GRPC_STATUS_FAILED_PRECONDITION: - return "FAILED_PRECONDITION"; - case GRPC_STATUS_ABORTED: - return "ABORTED"; - case GRPC_STATUS_OUT_OF_RANGE: - return "OUT_OF_RANGE"; - case GRPC_STATUS_UNIMPLEMENTED: - return "UNIMPLEMENTED"; - case GRPC_STATUS_INTERNAL: - return "INTERNAL"; - case GRPC_STATUS_UNAVAILABLE: - return "UNAVAILABLE"; - case GRPC_STATUS_DATA_LOSS: - return "DATA_LOSS"; - default: - return "UNKNOWN"; - } -} diff --git a/src/core/lib/channel/status_util.h b/src/core/lib/channel/status_util.h deleted file mode 100644 index 5409de6b3c..0000000000 --- a/src/core/lib/channel/status_util.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H -#define GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H - -#include - -#include - -#include -#include - -/// If \a status_str is a valid status string, sets \a status to the -/// corresponding status value and returns true. -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status); - -/// Returns the string form of \a status, or "UNKNOWN" if invalid. -const char* grpc_status_code_to_string(grpc_status_code status); - -namespace grpc_core { -namespace internal { - -/// A set of grpc_status_code values. -class StatusCodeSet { - public: - bool Empty() const { return status_code_mask_ == 0; } - - void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } - - bool Contains(grpc_status_code status) const { - return status_code_mask_ & (1 << status); - } - - private: - int status_code_mask_ = 0; // A bitfield of status codes in the set. -}; - -} // namespace internal -} // namespace grpc_core - -#endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */ diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 816241bbf0..2141db4c5b 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -21,7 +21,6 @@ #include #include -#include #include "src/core/lib/json/json.h" @@ -47,40 +46,5 @@ void grpc_json_destroy(grpc_json* json) { json->parent->child = json->next; } - if (json->owns_value) { - gpr_free((void*)json->value); - } - gpr_free(json); } - -grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, - grpc_json* sibling) { - // first child case. - if (parent->child == nullptr) { - GPR_ASSERT(sibling == nullptr); - parent->child = child; - return child; - } - if (sibling == nullptr) { - sibling = parent->child; - } - // always find the right most sibling. - while (sibling->next != nullptr) { - sibling = sibling->next; - } - sibling->next = child; - return child; -} - -grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, - const char* key, const char* value, - grpc_json_type type, bool owns_value) { - grpc_json* child = grpc_json_create(type); - grpc_json_link_child(parent, child, sibling); - child->owns_value = owns_value; - child->parent = parent; - child->value = value; - child->key = key; - return child; -} diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index f93b43048b..3a62ef9cfb 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -21,7 +21,6 @@ #include -#include #include #include "src/core/lib/json/json_common.h" @@ -38,9 +37,6 @@ typedef struct grpc_json { grpc_json_type type; const char* key; const char* value; - - /* if set, destructor will free value */ - bool owns_value; } grpc_json; /* The next two functions are going to parse the input string, and @@ -71,24 +67,9 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent); /* Use these to create or delete a grpc_json object. * Deletion is recursive. We will not attempt to free any of the strings - * in any of the objects of that tree, unless the boolean, owns_value, - * is true. + * in any of the objects of that tree. */ grpc_json* grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json* json); -/* Links the child json object into the parent's json tree. If the parent - * already has children, then passing in the most recently added child as the - * sibling parameter is an optimization. For if sibling is NULL, this function - * will manually traverse the tree in order to find the right most sibling. - */ -grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, - grpc_json* sibling); - -/* Creates a child json object into the parent's json tree then links it in - * as described above. */ -grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, - const char* key, const char* value, - grpc_json_type type, bool owns_value); - #endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index cecc15b2df..03353d6beb 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -21,7 +21,6 @@ #include "src/core/lib/surface/channel.h" #include -#include #include #include @@ -31,12 +30,8 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -67,8 +62,6 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::RefCountedPtr tracer; - char* target; }; @@ -100,14 +93,12 @@ grpc_channel* grpc_channel_create_with_builder( grpc_error_string(error)); GRPC_ERROR_UNREF(error); gpr_free(target); - grpc_channel_args_destroy(args); - return channel; + goto done; } memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - size_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -170,33 +161,14 @@ grpc_channel* grpc_channel_create_with_builder( channel->compression_options.enabled_algorithms_bitset = static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ - } else if (0 == strcmp(args->args[i].key, - GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { - GPR_ASSERT(channel_tracer_max_nodes == 0); - // max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX - const grpc_integer_options options = {0, 0, INT_MAX}; - channel_tracer_max_nodes = - (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } } +done: grpc_channel_args_destroy(args); - channel->tracer = grpc_core::MakeRefCounted( - channel_tracer_max_nodes); - channel->tracer->AddTraceEvent( - grpc_core::ChannelTrace::Severity::Info, - grpc_slice_from_static_string("Channel created")); return channel; } -char* grpc_channel_get_trace(grpc_channel* channel) { - return channel->tracer->RenderTrace(); -} - -intptr_t grpc_channel_get_uuid(grpc_channel* channel) { - return channel->tracer->GetUuid(); -} - grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, @@ -405,7 +377,6 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } - channel->tracer.reset(); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index bd436d6857..ac9f9e6066 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,7 +27,6 @@ #include #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/debug/stats.h" @@ -129,7 +128,6 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); - grpc_channel_trace_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -178,7 +176,6 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); - grpc_channel_trace_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD deleted file mode 100644 index bdb03d5e2d..0000000000 --- a/src/proto/grpc/channelz/BUILD +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) # Apache v2 - -load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") - -grpc_package(name = "channelz", visibility = "public") - -grpc_proto_library( - name = "channelz_proto", - srcs = ["channelz.proto"], - has_services = True, - well_known_protos = True, -) diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto deleted file mode 100644 index 14db66a654..0000000000 --- a/src/proto/grpc/channelz/channelz.proto +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright 2018 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package grpc.channelz; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -// See go/grpc-channelz. - -// Channel is a logical grouping of channels, subchannels, and sockets. -message Channel { - // The identifier for this channel. - ChannelRef ref = 1; - // Data specific to this channel. - ChannelData data = 2; - // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. - - // There are no ordering guarantees on the order of channel refs. - // There may not be cycles in the ref graph. - // A channel ref may be present in more than one channel or subchannel. - repeated ChannelRef channel_ref = 3; - - // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. - // There are no ordering guarantees on the order of subchannel refs. - // There may not be cycles in the ref graph. - // A sub channel ref may be present in more than one channel or subchannel. - repeated SubchannelRef subchannel_ref = 4; - - // There are no ordering guarantees on the order of sockets. - repeated SocketRef socket = 5; -} - -// Subchannel is a logical grouping of channels, subchannels, and sockets. -// A subchannel is load balanced over by it's ancestor -message Subchannel { - // The identifier for this channel. - SubchannelRef ref = 1; - // Data specific to this channel. - ChannelData data = 2; - // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. - - // There are no ordering guarantees on the order of channel refs. - // There may not be cycles in the ref graph. - // A channel ref may be present in more than one channel or subchannel. - repeated ChannelRef channel_ref = 3; - - // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. - // There are no ordering guarantees on the order of subchannel refs. - // There may not be cycles in the ref graph. - // A sub channel ref may be present in more than one channel or subchannel. - repeated SubchannelRef subchannel_ref = 4; - - // There are no ordering guarantees on the order of sockets. - repeated SocketRef socket = 5; -} - -// These come from the specified states in this document: -// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md -message ChannelConnectivityState { - enum State { - UNKNOWN = 0; - IDLE = 1; - CONNECTING = 2; - READY = 3; - TRANSIENT_FAILURE = 4; - SHUTDOWN = 5; - } - State state = 1; -} - -message ChannelData { - - ChannelConnectivityState state = 1; - - // The target this channel originally tried to connect to. May be absent - string target = 2; - - ChannelTrace trace = 3; - - // The number of calls started on the channel - int64 calls_started = 4; - // The number of calls that have completed with an OK status - int64 calls_succeeded = 5; - // The number of calls that have a completed with a non-OK status - int64 calls_failed = 6; - - // The last time a call was started on the channel. - google.protobuf.Timestamp last_call_started_timestamp = 7; -} - -// A trace event is an interesting thing that happened to a channel or -// subchannel, such as creation, address resolution, subchannel creation, etc. -message ChannelTraceEvent { - // High level description of the event. - string description = 1; - // The supported severity levels of trace events. - enum Severity { - CT_UNKNOWN = 0; - CT_INFO = 1; - CT_WARNING = 2; - CT_ERROR = 3; - } - // the severity of the trace event - Severity severity = 2; - // When this event occurred. - google.protobuf.Timestamp timestamp = 3; - // ref of referenced channel or subchannel. - // Optional, only present if this event refers to a child object. For example, - // this field would be filled if this trace event was for a subchannel being - // created. - oneof child_ref { - ChannelRef channel_ref = 4; - SubchannelRef subchannel_ref = 5; - } -} - -message ChannelTrace { - // Number of events ever logged in this tracing object. This can differ from - // events.size() because events can be overwritten or garbage collected by - // implementations. - int64 num_events_logged = 1; - // Time that this channel was created. - google.protobuf.Timestamp creation_time = 2; - // List of events that have occurred on this channel. - repeated ChannelTraceEvent events = 3; -} - -message ChannelRef { - // The globally unique id for this channel. Must be a positive number. - int64 channel_id = 1; - // An optional name associated with the channel. - string name = 2; - // Intentionally don't use field numbers from other refs. - reserved 3, 4, 5, 6; -} - -message SubchannelRef { - // The globally unique id for this subchannel. Must be a positive number. - int64 subchannel_id = 7; - // An optional name associated with the subchannel. - string name = 8; - // Intentionally don't use field numbers from other refs. - reserved 1, 2, 3, 4, 5, 6; -} - -message SocketRef { - int64 socket_id = 3; - // An optional name associated with the socket. - string name = 4; - // Intentionally don't use field numbers from other refs. - reserved 1, 2, 5, 6, 7, 8; -} - -message ServerRef { - // A globally unique identifier for this server. Must be a positive number. - int64 server_id = 5; - // An optional name associated with the server. - string name = 6; - // Intentionally don't use field numbers from other refs. - reserved 1, 2, 3, 4, 7, 8; -} - -message Server { - ServerRef ref = 1; - ServerData data = 2; - - // The sockets that the server is listening on. There are no ordering - // guarantees. - repeated SocketRef listen_socket = 3; -} - -message ServerData { - ChannelTrace trace = 1; - - // The number of incoming calls started on the server - int64 calls_started = 2; - // The number of incoming calls that have completed with an OK status - int64 calls_succeeded = 3; - // The number of incoming calls that have a completed with a non-OK status - int64 calls_failed = 4; - - // The last time a call was started on the server. - google.protobuf.Timestamp last_call_started_timestamp = 5; -} - -// Information about an actual connection. Pronounced "sock-ay". -message Socket { - SocketRef ref = 1; - - SocketData data = 2; - // The locally bound address. - Address local = 3; - // The remote bound address. May be absent. - Address remote = 4; - Security security = 5; - - // Optional, represents the name of the remote endpoint, if different than - // the original target name. - string remote_name = 6; -} - -message SocketData { - // The number of streams that have been started. - int64 streams_started = 1; - // The number of streams that have ended successfully with the EoS bit set for - // both end points - int64 streams_succeeded = 2; - // The number of incoming streams that have a completed with a non-OK status - int64 streams_failed = 3; - - // The number of messages successfully sent on this socket. - int64 messages_sent = 4; - int64 messages_received = 5; - - // The number of keep alives sent. This is typically implemented with HTTP/2 - // ping messages. - int64 keep_alives_sent = 6; - - // The last time a stream was created by this endpoint. Usually unset for - // servers. - google.protobuf.Timestamp last_local_stream_created_timestamp = 7; - // The last time a stream was created by the remote endpoint. Usually unset - // for clients. - google.protobuf.Timestamp last_remote_stream_created_timestamp = 8; - - // The last time a message was sent by this endpoint. - google.protobuf.Timestamp last_message_sent_timestamp = 9; - // The last time a message was received by this endpoint. - google.protobuf.Timestamp last_message_received_timestamp = 10; - - // The amount of window, granted to the local endpoint by the remote endpoint. - // This may be slightly out of date due to network latency. This does NOT - // include stream level or TCP level flow control info. - google.protobuf.Int64Value local_flow_control_window = 11; - - // The amount of window, granted to the remote endpoint by the local endpoint. - // This may be slightly out of date due to network latency. This does NOT - // include stream level or TCP level flow control info. - google.protobuf.Int64Value remote_flow_control_window = 12; - - repeated SocketOption option = 13; -} - -message Address { - message TcpIpAddress { - // Either the IPv4 or IPv6 address in bytes. Will either be 4 bytes or 16 - // bytes in length. - bytes ip_address = 1; - // 0-64k, or -1 if not appropriate. - int32 port = 2; - } - // A Unix Domain Socket address. - message UdsAddress { - string filename = 1; - } - // An address type not included above. - message OtherAddress { - // The human readable version of the value. - string name = 1; - // The actual address message. - google.protobuf.Any value = 2; - } - - oneof address { - TcpIpAddress tcpip_address = 1; - UdsAddress uds_address = 2; - OtherAddress other_address = 3; - } -} - -message Security { - message Tls { - // The key exchange used. e.g. X25519 - string key_exchange = 1; - // The cipher used. e.g. AES_128_GCM. - string cipher = 2; - // the certificate used by this endpoint. - bytes local_certificate = 3; - // the certificate used by the remote endpoint. - bytes remote_certificate = 4; - } - message OtherSecurity { - // The human readable version of the value. - string name = 1; - // The actual security details message. - google.protobuf.Any value = 2; - } - oneof model { - Tls tls = 1; - OtherSecurity other = 2; - } -} - -message SocketOption { - string name = 1; - // The human readable value of this socket option. At least one of value or - // additional will be set. - string value = 2; - // Additional data associated with the socket option. At least one of value - // or additional will be set. - google.protobuf.Any additional = 3; -} - -// For use with SocketOption's additional field. This is primarily used for -// SO_RCVTIMEO and SO_SNDTIMEO -message SocketOptionTimeout { - google.protobuf.Duration duration = 1; -} - -message SocketOptionLinger { - bool active = 1; - google.protobuf.Duration duration = 2; -} - -// Tcp info for SOL_TCP, TCP_INFO -message SocketOptionTcpInfo { - uint32 tcpi_state = 1; - - uint32 tcpi_ca_state = 2; - uint32 tcpi_retransmits = 3; - uint32 tcpi_probes = 4; - uint32 tcpi_backoff = 5; - uint32 tcpi_options = 6; - uint32 tcpi_snd_wscale = 7; - uint32 tcpi_rcv_wscale = 8; - - uint32 tcpi_rto = 9; - uint32 tcpi_ato = 10; - uint32 tcpi_snd_mss = 11; - uint32 tcpi_rcv_mss = 12; - - uint32 tcpi_unacked = 13; - uint32 tcpi_sacked = 14; - uint32 tcpi_lost = 15; - uint32 tcpi_retrans = 16; - uint32 tcpi_fackets = 17; - - uint32 tcpi_last_data_sent = 18; - uint32 tcpi_last_ack_sent = 19; - uint32 tcpi_last_data_recv = 20; - uint32 tcpi_last_ack_recv = 21; - - uint32 tcpi_pmtu = 22; - uint32 tcpi_rcv_ssthresh = 23; - uint32 tcpi_rtt = 24; - uint32 tcpi_rttvar = 25; - uint32 tcpi_snd_ssthresh = 26; - uint32 tcpi_snd_cwnd = 27; - uint32 tcpi_advmss = 28; - uint32 tcpi_reordering = 29; -} - -service Channelz { - // Gets all root channels (e.g. channels the application has directly - // created). This does not include subchannels nor non-top level channels. - rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse); - // Gets all servers that exist in the process. - rpc GetServers(GetServersRequest) returns (GetServersResponse); - // Gets all server sockets that exist in the process. - rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse); - // Returns a single Channel, or else a NOT_FOUND code. - rpc GetChannel(GetChannelRequest) returns (GetChannelResponse); - // Returns a single Subchannel, or else a NOT_FOUND code. - rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse); - // Returns a single Socket or else a NOT_FOUND code. - rpc GetSocket(GetSocketRequest) returns (GetSocketResponse); -} - -message GetServersRequest { - // start_server_id indicates that only servers at or above this id should be - // included in the results. - int64 start_server_id = 1; -} - -message GetServersResponse { - // list of servers that the connection detail service knows about. Sorted in - // ascending server_id order. - repeated Server server = 1; - // If set, indicates that the list of servers is the final list. Requesting - // more servers will only return more if they are created after this RPC - // completes. - bool end = 2; -} - -message GetServerSocketsRequest { - int64 server_id = 1; - // start_socket_id indicates that only sockets at or above this id should be - // included in the results. - int64 start_socket_id = 2; -} - -message GetServerSocketsResponse { - // list of socket refs that the connection detail service knows about. Sorted in - // ascending socket_id order. - repeated SocketRef socket_ref = 1; - // If set, indicates that the list of sockets is the final list. Requesting - // more sockets will only return more if they are created after this RPC - // completes. - bool end = 2; -} - -message GetTopChannelsRequest { - // start_channel_id indicates that only channels at or above this id should be - // included in the results. - int64 start_channel_id = 1; -} - -message GetTopChannelsResponse { - // list of channels that the connection detail service knows about. Sorted in - // ascending channel_id order. - repeated Channel channel = 1; - // If set, indicates that the list of channels is the final list. Requesting - // more channels can only return more if they are created after this RPC - // completes. - bool end = 2; -} - -message GetChannelRequest { - int64 channel_id = 1; -} - -message GetChannelResponse { - Channel channel = 1; -} - -message GetSubchannelRequest { - int64 subchannel_id = 1; -} - -message GetSubchannelResponse { - Subchannel subchannel = 1; -} - -message GetSocketRequest { - int64 socket_id = 1; -} - -message GetSocketResponse { - Socket socket = 1; -} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 9807300527..d96cbec292 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,13 +60,10 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_trace.cc', - 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -315,6 +312,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', + 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 1c042739a8..c045480ff4 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -68,8 +68,6 @@ grpc_channel_get_info_type grpc_channel_get_info_import; grpc_insecure_channel_create_type grpc_insecure_channel_create_import; grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; grpc_channel_destroy_type grpc_channel_destroy_import; -grpc_channel_get_trace_type grpc_channel_get_trace_import; -grpc_channel_get_uuid_type grpc_channel_get_uuid_import; grpc_call_cancel_type grpc_call_cancel_import; grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; grpc_call_ref_type grpc_call_ref_import; @@ -306,8 +304,6 @@ void grpc_rb_load_imports(HMODULE library) { grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); - grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace"); - grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid"); grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 9a09321364..4f07452c68 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -179,12 +179,6 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo typedef void(*grpc_channel_destroy_type)(grpc_channel* channel); extern grpc_channel_destroy_type grpc_channel_destroy_import; #define grpc_channel_destroy grpc_channel_destroy_import -typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel); -extern grpc_channel_get_trace_type grpc_channel_get_trace_import; -#define grpc_channel_get_trace grpc_channel_get_trace_import -typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel); -extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import; -#define grpc_channel_get_uuid grpc_channel_get_uuid_import typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved); extern grpc_call_cancel_type grpc_call_cancel_import; #define grpc_call_cancel grpc_call_cancel_import diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 6bf4fcdbb8..c5dfd8ef37 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -65,32 +65,3 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) - -grpc_cc_test( - name = "channel_trace_test", - srcs = ["channel_trace_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - "//test/core/util:gpr_test_util", - "//test/core/util:grpc_test_util", - "//test/cpp/util:channel_trace_proto_helper", - ], - external_deps = [ - "gtest", - ], -) - -grpc_cc_test( - name = "status_util_test", - srcs = ["status_util_test.cc"], - language = "C++", - deps = [ - "//:grpc", - ], - external_deps = [ - "gtest", - ], -) diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc deleted file mode 100644 index 3c73e33612..0000000000 --- a/test/core/channel/channel_trace_test.cc +++ /dev/null @@ -1,240 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#include - -#include -#include - -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channel_trace_registry.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/json/json.h" - -#include "test/core/util/test_config.h" -#include "test/cpp/util/channel_trace_proto_helper.h" - -// remove me -#include -#include -#include - -namespace grpc_core { -namespace testing { -namespace { - -grpc_json* GetJsonChild(grpc_json* parent, const char* key) { - EXPECT_NE(parent, nullptr); - for (grpc_json* child = parent->child; child != nullptr; - child = child->next) { - if (child->key != nullptr && strcmp(child->key, key) == 0) return child; - } - return nullptr; -} - -void ValidateJsonArraySize(grpc_json* json, const char* key, - size_t expected_size) { - grpc_json* arr = GetJsonChild(json, key); - ASSERT_NE(arr, nullptr); - ASSERT_EQ(arr->type, GRPC_JSON_ARRAY); - size_t count = 0; - for (grpc_json* child = arr->child; child != nullptr; child = child->next) { - ++count; - } - ASSERT_EQ(count, expected_size); -} - -void ValidateChannelTraceData(grpc_json* json, - size_t num_events_logged_expected, - size_t actual_num_events_expected) { - ASSERT_NE(json, nullptr); - grpc_json* num_events_logged_json = GetJsonChild(json, "numEventsLogged"); - ASSERT_NE(num_events_logged_json, nullptr); - grpc_json* start_time = GetJsonChild(json, "creationTime"); - ASSERT_NE(start_time, nullptr); - size_t num_events_logged = - (size_t)strtol(num_events_logged_json->value, nullptr, 0); - ASSERT_EQ(num_events_logged, num_events_logged_expected); - ValidateJsonArraySize(json, "events", actual_num_events_expected); -} - -void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(ChannelTrace::Severity::Info, - grpc_slice_from_static_string("simple trace")); -} - -// checks for the existence of all the required members of the tracer. -void ValidateChannelTrace(RefCountedPtr tracer, - size_t expected_num_event_logged, size_t max_nodes) { - if (!max_nodes) return; - char* json_str = tracer->RenderTrace(); - grpc::testing::ValidateChannelTraceProtoJsonTranslation(json_str); - grpc_json* json = grpc_json_parse_string(json_str); - ValidateChannelTraceData(json, expected_num_event_logged, - GPR_MIN(expected_num_event_logged, max_nodes)); - grpc_json_destroy(json); - gpr_free(json_str); -} - -void ValidateTraceDataMatchedUuidLookup(RefCountedPtr tracer) { - intptr_t uuid = tracer->GetUuid(); - if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled - char* tracer_json_str = tracer->RenderTrace(); - ChannelTrace* uuid_lookup = - grpc_channel_trace_registry_get_channel_trace(uuid); - char* uuid_lookup_json_str = uuid_lookup->RenderTrace(); - EXPECT_EQ(strcmp(tracer_json_str, uuid_lookup_json_str), 0); - gpr_free(tracer_json_str); - gpr_free(uuid_lookup_json_str); -} - -} // anonymous namespace - -class ChannelTracerTest : public ::testing::TestWithParam {}; - -// Tests basic ChannelTrace functionality like construction, adding trace, and -// lookups by uuid. -TEST_P(ChannelTracerTest, BasicTest) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateTraceDataMatchedUuidLookup(tracer); - tracer->AddTraceEvent(ChannelTrace::Severity::Info, - grpc_slice_from_static_string("trace three")); - tracer->AddTraceEvent(ChannelTrace::Severity::Error, - grpc_slice_from_static_string("trace four error")); - ValidateChannelTrace(tracer, 4, GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 6, GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 10, GetParam()); - ValidateTraceDataMatchedUuidLookup(tracer); - tracer.reset(nullptr); -} - -// Tests more complex functionality, like a parent channel tracking -// subchannles. This exercises the ref/unref patterns since the parent tracer -// and this function will both hold refs to the subchannel. -TEST_P(ChannelTracerTest, ComplexTest) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel( - ChannelTrace::Severity::Info, - grpc_slice_from_static_string("subchannel one created"), sc1); - ValidateChannelTrace(tracer, 3, GetParam()); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - ValidateChannelTrace(sc1, 3, GetParam()); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - ValidateChannelTrace(sc1, 6, GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 5, GetParam()); - ValidateTraceDataMatchedUuidLookup(tracer); - RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel( - ChannelTrace::Severity::Info, - grpc_slice_from_static_string("LB channel two created"), sc2); - tracer->AddTraceEventReferencingSubchannel( - ChannelTrace::Severity::Warning, - grpc_slice_from_static_string("subchannel one inactive"), sc1); - ValidateChannelTrace(tracer, 7, GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateTraceDataMatchedUuidLookup(tracer); - tracer.reset(nullptr); - sc1.reset(nullptr); - sc2.reset(nullptr); -} - -// Test a case in which the parent channel has subchannels and the subchannels -// have connections. Ensures that everything lives as long as it should then -// gets deleted. -TEST_P(ChannelTracerTest, TestNesting) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(GetParam()); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 2, GetParam()); - RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel( - ChannelTrace::Severity::Info, - grpc_slice_from_static_string("subchannel one created"), sc1); - ValidateChannelTrace(tracer, 3, GetParam()); - AddSimpleTrace(sc1); - RefCountedPtr conn1 = MakeRefCounted(GetParam()); - // nesting one level deeper. - sc1->AddTraceEventReferencingSubchannel( - ChannelTrace::Severity::Info, - grpc_slice_from_static_string("connection one created"), conn1); - ValidateChannelTrace(tracer, 3, GetParam()); - AddSimpleTrace(conn1); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 5, GetParam()); - ValidateChannelTrace(conn1, 1, GetParam()); - RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel( - ChannelTrace::Severity::Info, - grpc_slice_from_static_string("subchannel two created"), sc2); - // this trace should not get added to the parents children since it is already - // present in the tracer. - tracer->AddTraceEventReferencingChannel( - ChannelTrace::Severity::Warning, - grpc_slice_from_static_string("subchannel one inactive"), sc1); - AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 8, GetParam()); - tracer.reset(nullptr); - sc1.reset(nullptr); - sc2.reset(nullptr); - conn1.reset(nullptr); -} - -INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest, - ::testing::Values(0, 1, 2, 6, 10, 15)); - -} // namespace testing -} // namespace grpc_core - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - grpc_init(); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - grpc_shutdown(); - return ret; -} diff --git a/test/core/channel/status_util_test.cc b/test/core/channel/status_util_test.cc deleted file mode 100644 index 1d64bf1995..0000000000 --- a/test/core/channel/status_util_test.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/lib/channel/status_util.h" - -#include - -namespace grpc_core { -namespace internal { -namespace { - -TEST(StatusCodeSet, Basic) { - StatusCodeSet set; - EXPECT_TRUE(set.Empty()); - EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_OK); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_UNAVAILABLE); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); -} - -} // namespace -} // namespace internal -} // namespace grpc_core - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index 5148dc5f74..d430b722df 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -53,3 +53,15 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "status_util_test", + srcs = ["status_util_test.cc"], + language = "C++", + deps = [ + "//:grpc", + ], + external_deps = [ + "gtest", + ], +) diff --git a/test/core/client_channel/status_util_test.cc b/test/core/client_channel/status_util_test.cc new file mode 100644 index 0000000000..f944990ad2 --- /dev/null +++ b/test/core/client_channel/status_util_test.cc @@ -0,0 +1,49 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/ext/filters/client_channel/status_util.h" + +#include + +namespace grpc_core { +namespace internal { +namespace { + +TEST(StatusCodeSet, Basic) { + StatusCodeSet set; + EXPECT_TRUE(set.Empty()); + EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_OK); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_UNAVAILABLE); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); +} + +} // namespace +} // namespace internal +} // namespace grpc_core + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index d858603e47..bd4dc0b60e 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -106,8 +106,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_insecure_channel_create); printf("%lx", (unsigned long) grpc_lame_client_channel_create); printf("%lx", (unsigned long) grpc_channel_destroy); - printf("%lx", (unsigned long) grpc_channel_get_trace); - printf("%lx", (unsigned long) grpc_channel_get_uuid); printf("%lx", (unsigned long) grpc_call_cancel); printf("%lx", (unsigned long) grpc_call_cancel_with_status); printf("%lx", (unsigned long) grpc_call_ref); diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 4ac8572072..4f84c73820 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -84,24 +84,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "channel_trace_proto_helper", - srcs = [ - "channel_trace_proto_helper.cc", - ], - hdrs = [ - "channel_trace_proto_helper.h", - ], - deps = [ - "//:grpc++", - "//src/proto/grpc/channelz:channelz_proto", - ], - external_deps = [ - "gtest", - "protobuf", - ], -) - grpc_cc_library( name = "test_util_unsecure", srcs = GRPCXX_TESTUTIL_SRCS, diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc deleted file mode 100644 index fbc9f1501c..0000000000 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test/cpp/util/channel_trace_proto_helper.h" - -#include -#include - -#include -#include -#include - -#include "src/proto/grpc/channelz/channelz.pb.h" - -namespace grpc { -namespace testing { - -void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) { - std::string tracer_json_str(tracer_json_c_str); - grpc::channelz::ChannelTrace channel_trace; - google::protobuf::util::JsonParseOptions parse_options; - // If the following line is failing, then uncomment the last line of the - // comment, and uncomment the lines that print the two strings. You can - // then compare the output, and determine what fields are missing. - // - // options.ignore_unknown_fields = true; - ASSERT_EQ(google::protobuf::util::JsonStringToMessage( - tracer_json_str, &channel_trace, parse_options), - google::protobuf::util::Status::OK); - std::string proto_json_str; - ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, - &proto_json_str), - google::protobuf::util::Status::OK); - // uncomment these to compare the the json strings. - // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str()); - // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); - ASSERT_EQ(tracer_json_str, proto_json_str); -} - -} // namespace testing -} // namespace grpc diff --git a/test/cpp/util/channel_trace_proto_helper.h b/test/cpp/util/channel_trace_proto_helper.h deleted file mode 100644 index d7043d9f06..0000000000 --- a/test/cpp/util/channel_trace_proto_helper.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H -#define GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H - -namespace grpc { -namespace testing { - -void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str); - -} // namespace testing -} // namespace grpc - -#endif // GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 52a16d6e98..c822d9b3cd 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,14 +1007,11 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_trace.h \ -src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 2757114b34..212e1d53dd 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -929,6 +929,8 @@ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/retry_throttle.h \ +src/core/ext/filters/client_channel/status_util.cc \ +src/core/ext/filters/client_channel/status_util.h \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel.h \ src/core/ext/filters/client_channel/subchannel_index.cc \ @@ -1032,10 +1034,6 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_trace.cc \ -src/core/lib/channel/channel_trace.h \ -src/core/lib/channel/channel_trace_registry.cc \ -src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1045,8 +1043,6 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/status_util.cc \ -src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 08dc3fa9ea..f80cd9f2b5 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3034,27 +3034,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc++", - "grpc++_channelz_proto", - "grpc++_test", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "channel_trace_test", - "src": [ - "test/core/channel/channel_trace_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -4503,7 +4482,7 @@ "language": "c++", "name": "status_util_test", "src": [ - "test/core/channel/status_util_test.cc" + "test/core/client_channel/status_util_test.cc" ], "third_party": false, "type": "target" @@ -6980,9 +6959,6 @@ "grpc_test_util" ], "headers": [ - "src/proto/grpc/channelz/channelz.grpc.pb.h", - "src/proto/grpc/channelz/channelz.pb.h", - "src/proto/grpc/channelz/channelz_mock.grpc.pb.h", "src/proto/grpc/health/v1/health.grpc.pb.h", "src/proto/grpc/health/v1/health.pb.h", "src/proto/grpc/health/v1/health_mock.grpc.pb.h", @@ -6997,7 +6973,6 @@ "src/proto/grpc/testing/echo_mock.grpc.pb.h", "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.h", @@ -7011,8 +6986,6 @@ "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.cc", "test/cpp/util/byte_buffer_proto_helper.h", - "test/cpp/util/channel_trace_proto_helper.cc", - "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.cc", @@ -9014,13 +8987,10 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_trace.cc", - "src/core/lib/channel/channel_trace_registry.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", - "src/core/lib/channel/status_util.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -9185,14 +9155,11 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9334,14 +9301,11 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_trace.h", - "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9489,6 +9453,7 @@ "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", + "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h" @@ -9532,6 +9497,8 @@ "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.cc", "src/core/ext/filters/client_channel/retry_throttle.h", + "src/core/ext/filters/client_channel/status_util.cc", + "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.cc", @@ -10470,20 +10437,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [], - "headers": [ - "src/proto/grpc/channelz/channelz.grpc.pb.h", - "src/proto/grpc/channelz/channelz.pb.h", - "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" - ], - "is_filegroup": true, - "language": "c++", - "name": "grpc++_channelz_proto", - "src": [], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "grpc_codegen" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 8a99792108..3d6b6caa2a 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3649,30 +3649,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "channel_trace_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, -- cgit v1.2.3 From 3b42f83068618d5888b870874937a185803a2db1 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 19 Mar 2018 13:22:35 -0700 Subject: Revert "Revert "Channel Tracing Implementation; Part 1"" This reverts commit f2bea3725f8218777268decfd37c7b543f839d9f. --- BUILD | 8 +- CMakeLists.txt | 80 +++- Makefile | 114 +++++- build.yaml | 35 +- config.m4 | 4 +- config.w32 | 4 +- gRPC-C++.podspec | 7 +- gRPC-Core.podspec | 12 +- grpc.def | 2 + grpc.gemspec | 8 +- grpc.gyp | 18 +- include/grpc/grpc.h | 8 + include/grpc/impl/codegen/grpc_types.h | 4 + package.xml | 8 +- .../ext/filters/client_channel/client_channel.cc | 2 +- .../ext/filters/client_channel/method_params.cc | 2 +- .../ext/filters/client_channel/method_params.h | 2 +- src/core/ext/filters/client_channel/status_util.cc | 100 ----- src/core/ext/filters/client_channel/status_util.h | 58 --- src/core/ext/filters/client_channel/subchannel.cc | 1 + src/core/lib/channel/channel_trace.cc | 238 +++++++++++ src/core/lib/channel/channel_trace.h | 133 ++++++ src/core/lib/channel/channel_trace_registry.cc | 80 ++++ src/core/lib/channel/channel_trace_registry.h | 43 ++ src/core/lib/channel/status_util.cc | 100 +++++ src/core/lib/channel/status_util.h | 58 +++ src/core/lib/json/json.cc | 36 ++ src/core/lib/json/json.h | 21 +- src/core/lib/surface/channel.cc | 33 +- src/core/lib/surface/init.cc | 3 + src/proto/grpc/channelz/BUILD | 26 ++ src/proto/grpc/channelz/channelz.proto | 456 +++++++++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 4 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 + src/ruby/ext/grpc/rb_grpc_imports.generated.h | 6 + test/core/channel/BUILD | 29 ++ test/core/channel/channel_trace_test.cc | 240 +++++++++++ test/core/channel/status_util_test.cc | 49 +++ test/core/client_channel/BUILD | 12 - test/core/client_channel/status_util_test.cc | 49 --- test/core/surface/public_headers_must_be_c89.c | 2 + test/cpp/util/BUILD | 18 + test/cpp/util/channel_trace_proto_helper.cc | 56 +++ test/cpp/util/channel_trace_proto_helper.h | 30 ++ tools/doxygen/Doxyfile.c++.internal | 3 + tools/doxygen/Doxyfile.core.internal | 8 +- tools/run_tests/generated/sources_and_headers.json | 55 ++- tools/run_tests/generated/tests.json | 24 ++ 48 files changed, 2020 insertions(+), 273 deletions(-) delete mode 100644 src/core/ext/filters/client_channel/status_util.cc delete mode 100644 src/core/ext/filters/client_channel/status_util.h create mode 100644 src/core/lib/channel/channel_trace.cc create mode 100644 src/core/lib/channel/channel_trace.h create mode 100644 src/core/lib/channel/channel_trace_registry.cc create mode 100644 src/core/lib/channel/channel_trace_registry.h create mode 100644 src/core/lib/channel/status_util.cc create mode 100644 src/core/lib/channel/status_util.h create mode 100644 src/proto/grpc/channelz/BUILD create mode 100644 src/proto/grpc/channelz/channelz.proto create mode 100644 test/core/channel/channel_trace_test.cc create mode 100644 test/core/channel/status_util_test.cc delete mode 100644 test/core/client_channel/status_util_test.cc create mode 100644 test/cpp/util/channel_trace_proto_helper.cc create mode 100644 test/cpp/util/channel_trace_proto_helper.h (limited to 'src/core/lib/surface') diff --git a/BUILD b/BUILD index 6c18ad94d7..d59d2ad63f 100644 --- a/BUILD +++ b/BUILD @@ -676,6 +676,9 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/channel_trace.cc", + "src/core/lib/channel/channel_trace_registry.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -820,6 +823,9 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -1016,7 +1022,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver.cc", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/retry_throttle.cc", - "src/core/ext/filters/client_channel/status_util.cc", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel_index.cc", "src/core/ext/filters/client_channel/uri_parser.cc", @@ -1039,7 +1044,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 77e84a0df8..56dcb4671b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -532,6 +532,7 @@ endif() add_dependencies(buildtests_cxx byte_stream_test) add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) +add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx check_gcp_environment_linux_test) add_dependencies(buildtests_cxx check_gcp_environment_windows_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) @@ -855,10 +856,13 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1107,7 +1111,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1241,10 +1244,13 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1431,7 +1437,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1618,10 +1623,13 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1777,7 +1785,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1918,10 +1925,13 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2077,7 +2087,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2198,10 +2207,13 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2390,7 +2402,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -3012,10 +3023,13 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -3176,7 +3190,6 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -3681,6 +3694,10 @@ if (gRPC_BUILD_TESTS) if (gRPC_BUILD_CODEGEN) add_library(grpc++_test_util + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.h @@ -3700,6 +3717,7 @@ add_library(grpc++_test_util ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h test/cpp/end2end/test_service_impl.cc test/cpp/util/byte_buffer_proto_helper.cc + test/cpp/util/channel_trace_proto_helper.cc test/cpp/util/create_test_channel.cc test/cpp/util/string_ref_helper.cc test/cpp/util/subprocess.cc @@ -3718,6 +3736,9 @@ if(WIN32 AND MSVC) endif() endif() +protobuf_generate_grpc_cpp( + src/proto/grpc/channelz/channelz.proto +) protobuf_generate_grpc_cpp( src/proto/grpc/health/v1/health.proto ) @@ -10128,6 +10149,51 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(channel_trace_test + test/core/channel/channel_trace_test.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +protobuf_generate_grpc_cpp( + src/proto/grpc/channelz/channelz.proto +) + +target_include_directories(channel_trace_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(channel_trace_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++_test_util + grpc++ + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(check_gcp_environment_linux_test test/core/security/check_gcp_environment_linux_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -13073,7 +13139,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(status_util_test - test/core/client_channel/status_util_test.cc + test/core/channel/status_util_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) diff --git a/Makefile b/Makefile index 3fa0f6617b..50889716bd 100644 --- a/Makefile +++ b/Makefile @@ -1129,6 +1129,7 @@ bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test +channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test check_gcp_environment_linux_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test check_gcp_environment_windows_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test @@ -1614,6 +1615,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ @@ -1780,6 +1782,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/byte_stream_test \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \ $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ @@ -2205,6 +2208,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_trace_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing check_gcp_environment_linux_test" $(Q) $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test || ( echo test check_gcp_environment_linux_test failed ; exit 1 ) $(E) "[RUN] Testing check_gcp_environment_windows_test" @@ -2443,6 +2448,22 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(Q) mkdir -p $(@D) $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@ +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: protoc_dep_error +else + +$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: src/proto/grpc/channelz/channelz.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: src/proto/grpc/channelz/channelz.proto $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/core/stats.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/core/stats.grpc.pb.cc: protoc_dep_error @@ -3160,10 +3181,13 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3412,7 +3436,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3548,10 +3571,13 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3738,7 +3764,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3926,10 +3951,13 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4085,7 +4113,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4219,10 +4246,13 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4378,7 +4408,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4479,10 +4508,13 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4671,7 +4703,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -5292,10 +5323,13 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5456,7 +5490,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -5984,12 +6017,14 @@ endif LIBGRPC++_TEST_UTIL_SRC = \ + $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc \ test/cpp/end2end/test_service_impl.cc \ test/cpp/util/byte_buffer_proto_helper.cc \ + test/cpp/util/channel_trace_proto_helper.cc \ test/cpp/util/create_test_channel.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ @@ -6125,13 +6160,14 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_TEST_UTIL_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc LIBGRPC++_TEST_UTIL_UNSECURE_SRC = \ @@ -15989,6 +16025,53 @@ endif endif +CHANNEL_TRACE_TEST_SRC = \ + test/core/channel/channel_trace_test.cc \ + $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ + +CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/channel_trace_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) +endif +endif +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc + + CHECK_GCP_ENVIRONMENT_LINUX_TEST_SRC = \ test/core/security/check_gcp_environment_linux_test.cc \ @@ -19111,7 +19194,7 @@ endif STATUS_UTIL_TEST_SRC = \ - test/core/client_channel/status_util_test.cc \ + test/core/channel/status_util_test.cc \ STATUS_UTIL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_UTIL_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -19142,7 +19225,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/core/client_channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a +$(OBJDIR)/$(CONFIG)/test/core/channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a deps_status_util_test: $(STATUS_UTIL_TEST_OBJS:.o=.dep) @@ -23554,6 +23637,7 @@ test/cpp/qps/server_async.cc: $(OPENSSL_DEP) test/cpp/qps/server_sync.cc: $(OPENSSL_DEP) test/cpp/qps/usage_timer.cc: $(OPENSSL_DEP) test/cpp/util/byte_buffer_proto_helper.cc: $(OPENSSL_DEP) +test/cpp/util/channel_trace_proto_helper.cc: $(OPENSSL_DEP) test/cpp/util/cli_call.cc: $(OPENSSL_DEP) test/cpp/util/cli_credentials.cc: $(OPENSSL_DEP) test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index a4875df9e5..0dd3d36d8c 100644 --- a/build.yaml +++ b/build.yaml @@ -232,10 +232,13 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc + - src/core/lib/channel/channel_trace.cc + - src/core/lib/channel/channel_trace_registry.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc + - src/core/lib/channel/status_util.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -399,11 +402,14 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h + - src/core/lib/channel/channel_trace.h + - src/core/lib/channel/channel_trace_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h + - src/core/lib/channel/status_util.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h @@ -547,7 +553,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver_factory.h - src/core/ext/filters/client_channel/resolver_registry.h - src/core/ext/filters/client_channel/retry_throttle.h - - src/core/ext/filters/client_channel/status_util.h - src/core/ext/filters/client_channel/subchannel.h - src/core/ext/filters/client_channel/subchannel_index.h - src/core/ext/filters/client_channel/uri_parser.h @@ -570,7 +575,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/retry_throttle.cc - - src/core/ext/filters/client_channel/status_util.cc - src/core/ext/filters/client_channel/subchannel.cc - src/core/ext/filters/client_channel/subchannel_index.cc - src/core/ext/filters/client_channel/uri_parser.cc @@ -1066,6 +1070,10 @@ filegroups: secure: true uses: - grpc_trace +- name: grpc++_channelz_proto + language: c++ + src: + - src/proto/grpc/channelz/channelz.proto - name: grpc++_codegen_base language: c++ public_headers: @@ -1614,17 +1622,20 @@ libs: headers: - test/cpp/end2end/test_service_impl.h - test/cpp/util/byte_buffer_proto_helper.h + - test/cpp/util/channel_trace_proto_helper.h - test/cpp/util/create_test_channel.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h src: + - src/proto/grpc/channelz/channelz.proto - src/proto/grpc/health/v1/health.proto - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo.proto - src/proto/grpc/testing/duplicate/echo_duplicate.proto - test/cpp/end2end/test_service_impl.cc - test/cpp/util/byte_buffer_proto_helper.cc + - test/cpp/util/channel_trace_proto_helper.cc - test/cpp/util/create_test_channel.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc @@ -4107,6 +4118,24 @@ targets: - grpc - gpr uses_polling: false +- name: channel_trace_test + gtest: true + build: test + language: c++ + src: + - test/core/channel/channel_trace_test.cc + deps: + - grpc_test_util + - grpc++_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr + filegroups: + - grpc++_channelz_proto + uses: + - grpc++_test + uses_polling: false - name: check_gcp_environment_linux_test build: test language: c++ @@ -5128,7 +5157,7 @@ targets: build: test language: c++ src: - - test/core/client_channel/status_util_test.cc + - test/core/channel/status_util_test.cc deps: - grpc uses_polling: false diff --git a/config.m4 b/config.m4 index 2f17d0c4b7..3a81f9d7f9 100644 --- a/config.m4 +++ b/config.m4 @@ -84,10 +84,13 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -336,7 +339,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ diff --git a/config.w32 b/config.w32 index 78f2fe079d..76be896e44 100644 --- a/config.w32 +++ b/config.w32 @@ -61,10 +61,13 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + + "src\\core\\lib\\channel\\channel_trace.cc " + + "src\\core\\lib\\channel\\channel_trace_registry.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + + "src\\core\\lib\\channel\\status_util.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + @@ -313,7 +316,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " + "src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " + - "src\\core\\ext\\filters\\client_channel\\status_util.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " + "src\\core\\ext\\filters\\client_channel\\uri_parser.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index e1282611b0..f42bd4f81c 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -326,7 +326,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -343,11 +342,14 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -524,11 +526,14 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 39433ff819..634bff2f06 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -337,7 +337,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -354,11 +353,14 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -500,10 +502,13 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -749,7 +754,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -904,7 +908,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -921,11 +924,14 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.def b/grpc.def index 2bafebbbd4..5ff3a1efe8 100644 --- a/grpc.def +++ b/grpc.def @@ -45,6 +45,8 @@ EXPORTS grpc_insecure_channel_create grpc_lame_client_channel_create grpc_channel_destroy + grpc_channel_get_trace + grpc_channel_get_uuid grpc_call_cancel grpc_call_cancel_with_status grpc_call_ref diff --git a/grpc.gemspec b/grpc.gemspec index 3a57829943..3b07dd6433 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -267,7 +267,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver_factory.h ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.h ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.h ) - s.files += %w( src/core/ext/filters/client_channel/status_util.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) @@ -284,11 +283,14 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) + s.files += %w( src/core/lib/channel/channel_trace.h ) + s.files += %w( src/core/lib/channel/channel_trace_registry.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) + s.files += %w( src/core/lib/channel/status_util.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -430,10 +432,13 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) + s.files += %w( src/core/lib/channel/channel_trace.cc ) + s.files += %w( src/core/lib/channel/channel_trace_registry.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) + s.files += %w( src/core/lib/channel/status_util.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) @@ -682,7 +687,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc ) - s.files += %w( src/core/ext/filters/client_channel/status_util.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc ) diff --git a/grpc.gyp b/grpc.gyp index 403d32831b..fc9a45d307 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -237,10 +237,13 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -489,7 +492,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -580,10 +582,13 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -739,7 +744,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -808,10 +812,13 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -967,7 +974,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -1015,10 +1021,13 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -1207,7 +1216,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -1388,12 +1396,14 @@ 'grpc', ], 'sources': [ + 'src/proto/grpc/channelz/channelz.proto', 'src/proto/grpc/health/v1/health.proto', 'src/proto/grpc/testing/echo_messages.proto', 'src/proto/grpc/testing/echo.proto', 'src/proto/grpc/testing/duplicate/echo_duplicate.proto', 'test/cpp/end2end/test_service_impl.cc', 'test/cpp/util/byte_buffer_proto_helper.cc', + 'test/cpp/util/channel_trace_proto_helper.cc', 'test/cpp/util/create_test_channel.cc', 'test/cpp/util/string_ref_helper.cc', 'test/cpp/util/subprocess.cc', diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index c129a66949..dd8a5d7d5f 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,6 +286,14 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); +/** Returns the JSON formatted channel trace for this channel. The caller + owns the returned string and is responsible for freeing it. */ +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel); + +/** Returns the channel uuid, which can be used to look up its trace at a + later time. */ +GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); + /** Error handling for grpc_call Most grpc_call functions return a grpc_error. If the error is not GRPC_OK then the operation failed due to some unsatisfied precondition. diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index dcce2e7f9a..b671ad653e 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -281,6 +281,10 @@ typedef struct { #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" /** The grpc_socket_factory instance to create and bind sockets. A pointer. */ #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" +/** The maximum number of trace events to keep in the tracer for each channel or + * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE \ + "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/package.xml b/package.xml index 8f0dc55dbf..0b3fc3a9a0 100644 --- a/package.xml +++ b/package.xml @@ -274,7 +274,6 @@ - @@ -291,11 +290,14 @@ + + + @@ -437,10 +439,13 @@ + + + @@ -689,7 +694,6 @@ - diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index bbc5160bec..bf3911e5ee 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -38,12 +38,12 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/retry_throttle.h" -#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/ext/filters/client_channel/method_params.cc b/src/core/ext/filters/client_channel/method_params.cc index 374b87e170..1f116bb67d 100644 --- a/src/core/ext/filters/client_channel/method_params.cc +++ b/src/core/ext/filters/client_channel/method_params.cc @@ -26,7 +26,7 @@ #include #include "src/core/ext/filters/client_channel/method_params.h" -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h index 48ece29867..099924edf3 100644 --- a/src/core/ext/filters/client_channel/method_params.h +++ b/src/core/ext/filters/client_channel/method_params.h @@ -21,7 +21,7 @@ #include -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis diff --git a/src/core/ext/filters/client_channel/status_util.cc b/src/core/ext/filters/client_channel/status_util.cc deleted file mode 100644 index 11f732ab44..0000000000 --- a/src/core/ext/filters/client_channel/status_util.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/ext/filters/client_channel/status_util.h" - -#include "src/core/lib/gpr/useful.h" - -typedef struct { - const char* str; - grpc_status_code status; -} status_string_entry; - -static const status_string_entry g_status_string_entries[] = { - {"OK", GRPC_STATUS_OK}, - {"CANCELLED", GRPC_STATUS_CANCELLED}, - {"UNKNOWN", GRPC_STATUS_UNKNOWN}, - {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, - {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, - {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, - {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, - {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, - {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, - {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, - {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, - {"ABORTED", GRPC_STATUS_ABORTED}, - {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, - {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, - {"INTERNAL", GRPC_STATUS_INTERNAL}, - {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, - {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, -}; - -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status) { - for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { - if (strcmp(status_str, g_status_string_entries[i].str) == 0) { - *status = g_status_string_entries[i].status; - return true; - } - } - return false; -} - -const char* grpc_status_code_to_string(grpc_status_code status) { - switch (status) { - case GRPC_STATUS_OK: - return "OK"; - case GRPC_STATUS_CANCELLED: - return "CANCELLED"; - case GRPC_STATUS_UNKNOWN: - return "UNKNOWN"; - case GRPC_STATUS_INVALID_ARGUMENT: - return "INVALID_ARGUMENT"; - case GRPC_STATUS_DEADLINE_EXCEEDED: - return "DEADLINE_EXCEEDED"; - case GRPC_STATUS_NOT_FOUND: - return "NOT_FOUND"; - case GRPC_STATUS_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case GRPC_STATUS_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - case GRPC_STATUS_UNAUTHENTICATED: - return "UNAUTHENTICATED"; - case GRPC_STATUS_RESOURCE_EXHAUSTED: - return "RESOURCE_EXHAUSTED"; - case GRPC_STATUS_FAILED_PRECONDITION: - return "FAILED_PRECONDITION"; - case GRPC_STATUS_ABORTED: - return "ABORTED"; - case GRPC_STATUS_OUT_OF_RANGE: - return "OUT_OF_RANGE"; - case GRPC_STATUS_UNIMPLEMENTED: - return "UNIMPLEMENTED"; - case GRPC_STATUS_INTERNAL: - return "INTERNAL"; - case GRPC_STATUS_UNAVAILABLE: - return "UNAVAILABLE"; - case GRPC_STATUS_DATA_LOSS: - return "DATA_LOSS"; - default: - return "UNKNOWN"; - } -} diff --git a/src/core/ext/filters/client_channel/status_util.h b/src/core/ext/filters/client_channel/status_util.h deleted file mode 100644 index e018709730..0000000000 --- a/src/core/ext/filters/client_channel/status_util.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H - -#include - -#include - -#include -#include - -/// If \a status_str is a valid status string, sets \a status to the -/// corresponding status value and returns true. -bool grpc_status_code_from_string(const char* status_str, - grpc_status_code* status); - -/// Returns the string form of \a status, or "UNKNOWN" if invalid. -const char* grpc_status_code_to_string(grpc_status_code status); - -namespace grpc_core { -namespace internal { - -/// A set of grpc_status_code values. -class StatusCodeSet { - public: - bool Empty() const { return status_code_mask_ == 0; } - - void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } - - bool Contains(grpc_status_code status) const { - return status_code_mask_ & (1 << status); - } - - private: - int status_code_mask_ = 0; // A bitfield of status codes in the set. -}; - -} // namespace internal -} // namespace grpc_core - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H */ diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index cae7cc35e3..d7815fb7e1 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -40,6 +40,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc new file mode 100644 index 0000000000..67d5fd364b --- /dev/null +++ b/src/core/lib/channel/channel_trace.cc @@ -0,0 +1,238 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/channel/channel_trace.h" + +#include +#include +#include +#include +#include +#include + +#include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/channel/status_util.h" +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/error_utils.h" + +namespace grpc_core { + +ChannelTrace::TraceEvent::TraceEvent( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, ReferencedType type) + : severity_(severity), + data_(data), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + next_(nullptr), + referenced_tracer_(std::move(referenced_tracer)), + referenced_type_(type) {} + +ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data) + : severity_(severity), + data_(data), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + next_(nullptr) {} + +ChannelTrace::TraceEvent::~TraceEvent() { grpc_slice_unref_internal(data_); } + +ChannelTrace::ChannelTrace(size_t max_events) + : channel_uuid_(-1), + num_events_logged_(0), + list_size_(0), + max_list_size_(max_events), + head_trace_(nullptr), + tail_trace_(nullptr) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + gpr_mu_init(&tracer_mu_); + channel_uuid_ = grpc_channel_trace_registry_register_channel_trace(this); + time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME); +} + +ChannelTrace::~ChannelTrace() { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + TraceEvent* it = head_trace_; + while (it != nullptr) { + TraceEvent* to_free = it; + it = it->next(); + Delete(to_free); + } + grpc_channel_trace_registry_unregister_channel_trace(channel_uuid_); + gpr_mu_destroy(&tracer_mu_); +} + +intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } + +void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { + ++num_events_logged_; + // first event case + if (head_trace_ == nullptr) { + head_trace_ = tail_trace_ = new_trace_event; + } + // regular event add case + else { + tail_trace_->set_next(new_trace_event); + tail_trace_ = tail_trace_->next(); + } + ++list_size_; + // maybe garbage collect the end + if (list_size_ > max_list_size_) { + TraceEvent* to_free = head_trace_; + head_trace_ = head_trace_->next(); + Delete(to_free); + --list_size_; + } +} + +void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + AddTraceEventHelper(New(severity, data)); +} + +void ChannelTrace::AddTraceEventReferencingChannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + // create and fill up the new event + AddTraceEventHelper( + New(severity, data, std::move(referenced_tracer), Channel)); +} + +void ChannelTrace::AddTraceEventReferencingSubchannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + // create and fill up the new event + AddTraceEventHelper(New( + severity, data, std::move(referenced_tracer), Subchannel)); +} + +namespace { + +// returns an allocated string that represents tm according to RFC-3339, and, +// more specifically, follows: +// https://developers.google.com/protocol-buffers/docs/proto3#json +// +// "Uses RFC 3339, where generated output will always be Z-normalized and uses +// 0, 3, 6 or 9 fractional digits." +char* fmt_time(gpr_timespec tm) { + char time_buffer[35]; + char ns_buffer[11]; // '.' + 9 digits of precision + struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); + strftime(time_buffer, sizeof(time_buffer), "%Y-%m-%dT%H:%M:%S", tm_info); + snprintf(ns_buffer, 11, ".%09d", tm.tv_nsec); + // This loop trims off trailing zeros by inserting a null character that the + // right point. We iterate in chunks of three because we want 0, 3, 6, or 9 + // fractional digits. + for (int i = 7; i >= 1; i -= 3) { + if (ns_buffer[i] == '0' && ns_buffer[i + 1] == '0' && + ns_buffer[i + 2] == '0') { + ns_buffer[i] = '\0'; + // Edge case in which all fractional digits were 0. + if (i == 1) { + ns_buffer[0] = '\0'; + } + } else { + break; + } + } + char* full_time_str; + gpr_asprintf(&full_time_str, "%s%sZ", time_buffer, ns_buffer); + return full_time_str; +} + +const char* severity_string(ChannelTrace::Severity severity) { + switch (severity) { + case ChannelTrace::Severity::Info: + return "CT_INFO"; + case ChannelTrace::Severity::Warning: + return "CT_WARNING"; + case ChannelTrace::Severity::Error: + return "CT_ERROR"; + default: + GPR_UNREACHABLE_CODE(return "CT_UNKNOWN"); + } +} + +} // anonymous namespace + +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { + grpc_json* json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "description", + grpc_slice_to_c_string(data_), + GRPC_JSON_STRING, true); + json_iterator = grpc_json_create_child(json_iterator, json, "severity", + severity_string(severity_), + GRPC_JSON_STRING, false); + json_iterator = + grpc_json_create_child(json_iterator, json, "timestamp", + fmt_time(timestamp_), GRPC_JSON_STRING, true); + if (referenced_tracer_ != nullptr) { + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); + grpc_json* child_ref = grpc_json_create_child( + json_iterator, json, + (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", nullptr, + GRPC_JSON_OBJECT, false); + json_iterator = grpc_json_create_child( + nullptr, child_ref, + (referenced_type_ == Channel) ? "channelId" : "subchannelId", uuid_str, + GRPC_JSON_STRING, true); + json_iterator = child_ref; + } +} + +char* ChannelTrace::RenderTrace() const { + if (!max_list_size_) + return nullptr; // tracing is disabled if max_events == 0 + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); + grpc_json* json_iterator = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "numEventsLogged", + num_events_logged_str, GRPC_JSON_STRING, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "creationTime", + fmt_time(time_created_), GRPC_JSON_STRING, true); + grpc_json* events = grpc_json_create_child(json_iterator, json, "events", + nullptr, GRPC_JSON_ARRAY, false); + json_iterator = nullptr; + TraceEvent* it = head_trace_; + while (it != nullptr) { + json_iterator = grpc_json_create_child(json_iterator, events, nullptr, + nullptr, GRPC_JSON_OBJECT, false); + it->RenderTraceEvent(json_iterator); + it = it->next(); + } + char* json_str = grpc_json_dump_to_string(json, 0); + grpc_json_destroy(json); + return json_str; +} + +} // namespace grpc_core diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h new file mode 100644 index 0000000000..1df1e585f2 --- /dev/null +++ b/src/core/lib/channel/channel_trace.h @@ -0,0 +1,133 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H + +#include + +#include +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/json/json.h" + +namespace grpc_core { + +// Object used to hold live data for a channel. This data is exposed via the +// channelz service: +// https://github.com/grpc/proposal/blob/master/A14-channelz.md +class ChannelTrace : public RefCounted { + public: + ChannelTrace(size_t max_events); + ~ChannelTrace(); + + // returns the tracer's uuid + intptr_t GetUuid() const; + + enum Severity { + Unset = 0, // never to be used + Info, // we start at 1 to avoid using proto default values + Warning, + Error + }; + + // Adds a new trace event to the tracing object + // + // TODO(ncteisen): as this call is used more and more throughout the gRPC + // stack, determine if it makes more sense to accept a char* instead of a + // slice. + void AddTraceEvent(Severity severity, grpc_slice data); + + // Adds a new trace event to the tracing object. This trace event refers to a + // an event on a child of the channel. For example, if this channel has + // created a new subchannel, then it would record that with a TraceEvent + // referencing the new subchannel. + // + // TODO(ncteisen): Once channelz is implemented, the events should reference + // the overall channelz object, not just the ChannelTrace object. + // TODO(ncteisen): as this call is used more and more throughout the gRPC + // stack, determine if it makes more sense to accept a char* instead of a + // slice. + void AddTraceEventReferencingChannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); + void AddTraceEventReferencingSubchannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); + + // Returns the tracing data rendered as a grpc json string. + // The string is owned by the caller and must be freed. + char* RenderTrace() const; + + private: + // Types of objects that can be references by trace events. + enum ReferencedType { Channel, Subchannel }; + // Private class to encapsulate all the data and bookkeeping needed for a + // a trace event. + class TraceEvent { + public: + // Constructor for a TraceEvent that references a different channel. + // TODO(ncteisen): once channelz is implemented, this should reference the + // overall channelz object, not just the ChannelTrace object + TraceEvent(Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, + ReferencedType type); + + // Constructor for a TraceEvent that does not reverence a different + // channel. + TraceEvent(Severity severity, grpc_slice data); + + ~TraceEvent(); + + // Renders the data inside of this TraceEvent into a json object. This is + // used by the ChannelTrace, when it is rendering itself. + void RenderTraceEvent(grpc_json* json) const; + + // set and get for the next_ pointer. + TraceEvent* next() const { return next_; } + void set_next(TraceEvent* next) { next_ = next; } + + private: + Severity severity_; + grpc_slice data_; + gpr_timespec timestamp_; + TraceEvent* next_; + // the tracer object for the (sub)channel that this trace event refers to. + RefCountedPtr referenced_tracer_; + // the type that the referenced tracer points to. Unused if this trace + // does not point to any channel or subchannel + ReferencedType referenced_type_; + }; // TraceEvent + + // Internal helper to add and link in a trace event + void AddTraceEventHelper(TraceEvent* new_trace_event); + + gpr_mu tracer_mu_; + intptr_t channel_uuid_; + uint64_t num_events_logged_; + size_t list_size_; + size_t max_list_size_; + TraceEvent* head_trace_; + TraceEvent* tail_trace_; + gpr_timespec time_created_; +}; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H */ diff --git a/src/core/lib/channel/channel_trace_registry.cc b/src/core/lib/channel/channel_trace_registry.cc new file mode 100644 index 0000000000..6c82431467 --- /dev/null +++ b/src/core/lib/channel/channel_trace_registry.cc @@ -0,0 +1,80 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/avl/avl.h" +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/gpr/useful.h" + +#include +#include + +// file global lock and avl. +static gpr_mu g_mu; +static grpc_avl g_avl; +static gpr_atm g_uuid = 0; + +// avl vtable for uuid (intptr_t) -> ChannelTrace +// this table is only looking, it does not own anything. +static void destroy_intptr(void* not_used, void* user_data) {} +static void* copy_intptr(void* key, void* user_data) { return key; } +static long compare_intptr(void* key1, void* key2, void* user_data) { + return GPR_ICMP(key1, key2); +} + +static void destroy_channel_trace(void* trace, void* user_data) {} +static void* copy_channel_trace(void* trace, void* user_data) { return trace; } +static const grpc_avl_vtable avl_vtable = { + destroy_intptr, copy_intptr, compare_intptr, destroy_channel_trace, + copy_channel_trace}; + +void grpc_channel_trace_registry_init() { + gpr_mu_init(&g_mu); + g_avl = grpc_avl_create(&avl_vtable); +} + +void grpc_channel_trace_registry_shutdown() { + grpc_avl_unref(g_avl, nullptr); + gpr_mu_destroy(&g_mu); +} + +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace) { + intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); + gpr_mu_lock(&g_mu); + g_avl = grpc_avl_add(g_avl, (void*)prior, channel_trace, nullptr); + gpr_mu_unlock(&g_mu); + return prior; +} + +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid) { + gpr_mu_lock(&g_mu); + g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr); + gpr_mu_unlock(&g_mu); +} + +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid) { + gpr_mu_lock(&g_mu); + grpc_core::ChannelTrace* ret = static_cast( + grpc_avl_get(g_avl, (void*)uuid, nullptr)); + gpr_mu_unlock(&g_mu); + return ret; +} diff --git a/src/core/lib/channel/channel_trace_registry.h b/src/core/lib/channel/channel_trace_registry.h new file mode 100644 index 0000000000..391ecba7de --- /dev/null +++ b/src/core/lib/channel/channel_trace_registry.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H + +#include + +#include "src/core/lib/channel/channel_trace.h" + +#include + +// TODO(ncteisen): convert this file to C++ + +void grpc_channel_trace_registry_init(); +void grpc_channel_trace_registry_shutdown(); + +// globally registers a ChannelTrace. Returns its unique uuid +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace); +// globally unregisters the ChannelTrace that is associated to uuid. +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid); +// if object with uuid has previously been registered, returns the ChannelTrace +// associated with that uuid. Else returns nullptr. +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid); + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H */ diff --git a/src/core/lib/channel/status_util.cc b/src/core/lib/channel/status_util.cc new file mode 100644 index 0000000000..563db40846 --- /dev/null +++ b/src/core/lib/channel/status_util.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include "src/core/lib/channel/status_util.h" + +#include "src/core/lib/gpr/useful.h" + +typedef struct { + const char* str; + grpc_status_code status; +} status_string_entry; + +static const status_string_entry g_status_string_entries[] = { + {"OK", GRPC_STATUS_OK}, + {"CANCELLED", GRPC_STATUS_CANCELLED}, + {"UNKNOWN", GRPC_STATUS_UNKNOWN}, + {"INVALID_ARGUMENT", GRPC_STATUS_INVALID_ARGUMENT}, + {"DEADLINE_EXCEEDED", GRPC_STATUS_DEADLINE_EXCEEDED}, + {"NOT_FOUND", GRPC_STATUS_NOT_FOUND}, + {"ALREADY_EXISTS", GRPC_STATUS_ALREADY_EXISTS}, + {"PERMISSION_DENIED", GRPC_STATUS_PERMISSION_DENIED}, + {"UNAUTHENTICATED", GRPC_STATUS_UNAUTHENTICATED}, + {"RESOURCE_EXHAUSTED", GRPC_STATUS_RESOURCE_EXHAUSTED}, + {"FAILED_PRECONDITION", GRPC_STATUS_FAILED_PRECONDITION}, + {"ABORTED", GRPC_STATUS_ABORTED}, + {"OUT_OF_RANGE", GRPC_STATUS_OUT_OF_RANGE}, + {"UNIMPLEMENTED", GRPC_STATUS_UNIMPLEMENTED}, + {"INTERNAL", GRPC_STATUS_INTERNAL}, + {"UNAVAILABLE", GRPC_STATUS_UNAVAILABLE}, + {"DATA_LOSS", GRPC_STATUS_DATA_LOSS}, +}; + +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status) { + for (size_t i = 0; i < GPR_ARRAY_SIZE(g_status_string_entries); ++i) { + if (strcmp(status_str, g_status_string_entries[i].str) == 0) { + *status = g_status_string_entries[i].status; + return true; + } + } + return false; +} + +const char* grpc_status_code_to_string(grpc_status_code status) { + switch (status) { + case GRPC_STATUS_OK: + return "OK"; + case GRPC_STATUS_CANCELLED: + return "CANCELLED"; + case GRPC_STATUS_UNKNOWN: + return "UNKNOWN"; + case GRPC_STATUS_INVALID_ARGUMENT: + return "INVALID_ARGUMENT"; + case GRPC_STATUS_DEADLINE_EXCEEDED: + return "DEADLINE_EXCEEDED"; + case GRPC_STATUS_NOT_FOUND: + return "NOT_FOUND"; + case GRPC_STATUS_ALREADY_EXISTS: + return "ALREADY_EXISTS"; + case GRPC_STATUS_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case GRPC_STATUS_UNAUTHENTICATED: + return "UNAUTHENTICATED"; + case GRPC_STATUS_RESOURCE_EXHAUSTED: + return "RESOURCE_EXHAUSTED"; + case GRPC_STATUS_FAILED_PRECONDITION: + return "FAILED_PRECONDITION"; + case GRPC_STATUS_ABORTED: + return "ABORTED"; + case GRPC_STATUS_OUT_OF_RANGE: + return "OUT_OF_RANGE"; + case GRPC_STATUS_UNIMPLEMENTED: + return "UNIMPLEMENTED"; + case GRPC_STATUS_INTERNAL: + return "INTERNAL"; + case GRPC_STATUS_UNAVAILABLE: + return "UNAVAILABLE"; + case GRPC_STATUS_DATA_LOSS: + return "DATA_LOSS"; + default: + return "UNKNOWN"; + } +} diff --git a/src/core/lib/channel/status_util.h b/src/core/lib/channel/status_util.h new file mode 100644 index 0000000000..5409de6b3c --- /dev/null +++ b/src/core/lib/channel/status_util.h @@ -0,0 +1,58 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H +#define GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H + +#include + +#include + +#include +#include + +/// If \a status_str is a valid status string, sets \a status to the +/// corresponding status value and returns true. +bool grpc_status_code_from_string(const char* status_str, + grpc_status_code* status); + +/// Returns the string form of \a status, or "UNKNOWN" if invalid. +const char* grpc_status_code_to_string(grpc_status_code status); + +namespace grpc_core { +namespace internal { + +/// A set of grpc_status_code values. +class StatusCodeSet { + public: + bool Empty() const { return status_code_mask_ == 0; } + + void Add(grpc_status_code status) { status_code_mask_ |= (1 << status); } + + bool Contains(grpc_status_code status) const { + return status_code_mask_ & (1 << status); + } + + private: + int status_code_mask_ = 0; // A bitfield of status codes in the set. +}; + +} // namespace internal +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */ diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 2141db4c5b..816241bbf0 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -21,6 +21,7 @@ #include #include +#include #include "src/core/lib/json/json.h" @@ -46,5 +47,40 @@ void grpc_json_destroy(grpc_json* json) { json->parent->child = json->next; } + if (json->owns_value) { + gpr_free((void*)json->value); + } + gpr_free(json); } + +grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, + grpc_json* sibling) { + // first child case. + if (parent->child == nullptr) { + GPR_ASSERT(sibling == nullptr); + parent->child = child; + return child; + } + if (sibling == nullptr) { + sibling = parent->child; + } + // always find the right most sibling. + while (sibling->next != nullptr) { + sibling = sibling->next; + } + sibling->next = child; + return child; +} + +grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, + const char* key, const char* value, + grpc_json_type type, bool owns_value) { + grpc_json* child = grpc_json_create(type); + grpc_json_link_child(parent, child, sibling); + child->owns_value = owns_value; + child->parent = parent; + child->value = value; + child->key = key; + return child; +} diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 3a62ef9cfb..f93b43048b 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -21,6 +21,7 @@ #include +#include #include #include "src/core/lib/json/json_common.h" @@ -37,6 +38,9 @@ typedef struct grpc_json { grpc_json_type type; const char* key; const char* value; + + /* if set, destructor will free value */ + bool owns_value; } grpc_json; /* The next two functions are going to parse the input string, and @@ -67,9 +71,24 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent); /* Use these to create or delete a grpc_json object. * Deletion is recursive. We will not attempt to free any of the strings - * in any of the objects of that tree. + * in any of the objects of that tree, unless the boolean, owns_value, + * is true. */ grpc_json* grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json* json); +/* Links the child json object into the parent's json tree. If the parent + * already has children, then passing in the most recently added child as the + * sibling parameter is an optimization. For if sibling is NULL, this function + * will manually traverse the tree in order to find the right most sibling. + */ +grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, + grpc_json* sibling); + +/* Creates a child json object into the parent's json tree then links it in + * as described above. */ +grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, + const char* key, const char* value, + grpc_json_type type, bool owns_value); + #endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 03353d6beb..cecc15b2df 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -21,6 +21,7 @@ #include "src/core/lib/surface/channel.h" #include +#include #include #include @@ -30,8 +31,12 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -62,6 +67,8 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; + grpc_core::RefCountedPtr tracer; + char* target; }; @@ -93,12 +100,14 @@ grpc_channel* grpc_channel_create_with_builder( grpc_error_string(error)); GRPC_ERROR_UNREF(error); gpr_free(target); - goto done; + grpc_channel_args_destroy(args); + return channel; } memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); + size_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -161,14 +170,33 @@ grpc_channel* grpc_channel_create_with_builder( channel->compression_options.enabled_algorithms_bitset = static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ + } else if (0 == strcmp(args->args[i].key, + GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { + GPR_ASSERT(channel_tracer_max_nodes == 0); + // max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX + const grpc_integer_options options = {0, 0, INT_MAX}; + channel_tracer_max_nodes = + (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } } -done: grpc_channel_args_destroy(args); + channel->tracer = grpc_core::MakeRefCounted( + channel_tracer_max_nodes); + channel->tracer->AddTraceEvent( + grpc_core::ChannelTrace::Severity::Info, + grpc_slice_from_static_string("Channel created")); return channel; } +char* grpc_channel_get_trace(grpc_channel* channel) { + return channel->tracer->RenderTrace(); +} + +intptr_t grpc_channel_get_uuid(grpc_channel* channel) { + return channel->tracer->GetUuid(); +} + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, @@ -377,6 +405,7 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } + channel->tracer.reset(); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index ac9f9e6066..bd436d6857 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,6 +27,7 @@ #include #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/debug/stats.h" @@ -128,6 +129,7 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); + grpc_channel_trace_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -176,6 +178,7 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); + grpc_channel_trace_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD new file mode 100644 index 0000000000..bdb03d5e2d --- /dev/null +++ b/src/proto/grpc/channelz/BUILD @@ -0,0 +1,26 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") + +grpc_package(name = "channelz", visibility = "public") + +grpc_proto_library( + name = "channelz_proto", + srcs = ["channelz.proto"], + has_services = True, + well_known_protos = True, +) diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto new file mode 100644 index 0000000000..14db66a654 --- /dev/null +++ b/src/proto/grpc/channelz/channelz.proto @@ -0,0 +1,456 @@ +// Copyright 2018 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package grpc.channelz; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +// See go/grpc-channelz. + +// Channel is a logical grouping of channels, subchannels, and sockets. +message Channel { + // The identifier for this channel. + ChannelRef ref = 1; + // Data specific to this channel. + ChannelData data = 2; + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + repeated ChannelRef channel_ref = 3; + + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + repeated SubchannelRef subchannel_ref = 4; + + // There are no ordering guarantees on the order of sockets. + repeated SocketRef socket = 5; +} + +// Subchannel is a logical grouping of channels, subchannels, and sockets. +// A subchannel is load balanced over by it's ancestor +message Subchannel { + // The identifier for this channel. + SubchannelRef ref = 1; + // Data specific to this channel. + ChannelData data = 2; + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + repeated ChannelRef channel_ref = 3; + + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + repeated SubchannelRef subchannel_ref = 4; + + // There are no ordering guarantees on the order of sockets. + repeated SocketRef socket = 5; +} + +// These come from the specified states in this document: +// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md +message ChannelConnectivityState { + enum State { + UNKNOWN = 0; + IDLE = 1; + CONNECTING = 2; + READY = 3; + TRANSIENT_FAILURE = 4; + SHUTDOWN = 5; + } + State state = 1; +} + +message ChannelData { + + ChannelConnectivityState state = 1; + + // The target this channel originally tried to connect to. May be absent + string target = 2; + + ChannelTrace trace = 3; + + // The number of calls started on the channel + int64 calls_started = 4; + // The number of calls that have completed with an OK status + int64 calls_succeeded = 5; + // The number of calls that have a completed with a non-OK status + int64 calls_failed = 6; + + // The last time a call was started on the channel. + google.protobuf.Timestamp last_call_started_timestamp = 7; +} + +// A trace event is an interesting thing that happened to a channel or +// subchannel, such as creation, address resolution, subchannel creation, etc. +message ChannelTraceEvent { + // High level description of the event. + string description = 1; + // The supported severity levels of trace events. + enum Severity { + CT_UNKNOWN = 0; + CT_INFO = 1; + CT_WARNING = 2; + CT_ERROR = 3; + } + // the severity of the trace event + Severity severity = 2; + // When this event occurred. + google.protobuf.Timestamp timestamp = 3; + // ref of referenced channel or subchannel. + // Optional, only present if this event refers to a child object. For example, + // this field would be filled if this trace event was for a subchannel being + // created. + oneof child_ref { + ChannelRef channel_ref = 4; + SubchannelRef subchannel_ref = 5; + } +} + +message ChannelTrace { + // Number of events ever logged in this tracing object. This can differ from + // events.size() because events can be overwritten or garbage collected by + // implementations. + int64 num_events_logged = 1; + // Time that this channel was created. + google.protobuf.Timestamp creation_time = 2; + // List of events that have occurred on this channel. + repeated ChannelTraceEvent events = 3; +} + +message ChannelRef { + // The globally unique id for this channel. Must be a positive number. + int64 channel_id = 1; + // An optional name associated with the channel. + string name = 2; + // Intentionally don't use field numbers from other refs. + reserved 3, 4, 5, 6; +} + +message SubchannelRef { + // The globally unique id for this subchannel. Must be a positive number. + int64 subchannel_id = 7; + // An optional name associated with the subchannel. + string name = 8; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 3, 4, 5, 6; +} + +message SocketRef { + int64 socket_id = 3; + // An optional name associated with the socket. + string name = 4; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 5, 6, 7, 8; +} + +message ServerRef { + // A globally unique identifier for this server. Must be a positive number. + int64 server_id = 5; + // An optional name associated with the server. + string name = 6; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 3, 4, 7, 8; +} + +message Server { + ServerRef ref = 1; + ServerData data = 2; + + // The sockets that the server is listening on. There are no ordering + // guarantees. + repeated SocketRef listen_socket = 3; +} + +message ServerData { + ChannelTrace trace = 1; + + // The number of incoming calls started on the server + int64 calls_started = 2; + // The number of incoming calls that have completed with an OK status + int64 calls_succeeded = 3; + // The number of incoming calls that have a completed with a non-OK status + int64 calls_failed = 4; + + // The last time a call was started on the server. + google.protobuf.Timestamp last_call_started_timestamp = 5; +} + +// Information about an actual connection. Pronounced "sock-ay". +message Socket { + SocketRef ref = 1; + + SocketData data = 2; + // The locally bound address. + Address local = 3; + // The remote bound address. May be absent. + Address remote = 4; + Security security = 5; + + // Optional, represents the name of the remote endpoint, if different than + // the original target name. + string remote_name = 6; +} + +message SocketData { + // The number of streams that have been started. + int64 streams_started = 1; + // The number of streams that have ended successfully with the EoS bit set for + // both end points + int64 streams_succeeded = 2; + // The number of incoming streams that have a completed with a non-OK status + int64 streams_failed = 3; + + // The number of messages successfully sent on this socket. + int64 messages_sent = 4; + int64 messages_received = 5; + + // The number of keep alives sent. This is typically implemented with HTTP/2 + // ping messages. + int64 keep_alives_sent = 6; + + // The last time a stream was created by this endpoint. Usually unset for + // servers. + google.protobuf.Timestamp last_local_stream_created_timestamp = 7; + // The last time a stream was created by the remote endpoint. Usually unset + // for clients. + google.protobuf.Timestamp last_remote_stream_created_timestamp = 8; + + // The last time a message was sent by this endpoint. + google.protobuf.Timestamp last_message_sent_timestamp = 9; + // The last time a message was received by this endpoint. + google.protobuf.Timestamp last_message_received_timestamp = 10; + + // The amount of window, granted to the local endpoint by the remote endpoint. + // This may be slightly out of date due to network latency. This does NOT + // include stream level or TCP level flow control info. + google.protobuf.Int64Value local_flow_control_window = 11; + + // The amount of window, granted to the remote endpoint by the local endpoint. + // This may be slightly out of date due to network latency. This does NOT + // include stream level or TCP level flow control info. + google.protobuf.Int64Value remote_flow_control_window = 12; + + repeated SocketOption option = 13; +} + +message Address { + message TcpIpAddress { + // Either the IPv4 or IPv6 address in bytes. Will either be 4 bytes or 16 + // bytes in length. + bytes ip_address = 1; + // 0-64k, or -1 if not appropriate. + int32 port = 2; + } + // A Unix Domain Socket address. + message UdsAddress { + string filename = 1; + } + // An address type not included above. + message OtherAddress { + // The human readable version of the value. + string name = 1; + // The actual address message. + google.protobuf.Any value = 2; + } + + oneof address { + TcpIpAddress tcpip_address = 1; + UdsAddress uds_address = 2; + OtherAddress other_address = 3; + } +} + +message Security { + message Tls { + // The key exchange used. e.g. X25519 + string key_exchange = 1; + // The cipher used. e.g. AES_128_GCM. + string cipher = 2; + // the certificate used by this endpoint. + bytes local_certificate = 3; + // the certificate used by the remote endpoint. + bytes remote_certificate = 4; + } + message OtherSecurity { + // The human readable version of the value. + string name = 1; + // The actual security details message. + google.protobuf.Any value = 2; + } + oneof model { + Tls tls = 1; + OtherSecurity other = 2; + } +} + +message SocketOption { + string name = 1; + // The human readable value of this socket option. At least one of value or + // additional will be set. + string value = 2; + // Additional data associated with the socket option. At least one of value + // or additional will be set. + google.protobuf.Any additional = 3; +} + +// For use with SocketOption's additional field. This is primarily used for +// SO_RCVTIMEO and SO_SNDTIMEO +message SocketOptionTimeout { + google.protobuf.Duration duration = 1; +} + +message SocketOptionLinger { + bool active = 1; + google.protobuf.Duration duration = 2; +} + +// Tcp info for SOL_TCP, TCP_INFO +message SocketOptionTcpInfo { + uint32 tcpi_state = 1; + + uint32 tcpi_ca_state = 2; + uint32 tcpi_retransmits = 3; + uint32 tcpi_probes = 4; + uint32 tcpi_backoff = 5; + uint32 tcpi_options = 6; + uint32 tcpi_snd_wscale = 7; + uint32 tcpi_rcv_wscale = 8; + + uint32 tcpi_rto = 9; + uint32 tcpi_ato = 10; + uint32 tcpi_snd_mss = 11; + uint32 tcpi_rcv_mss = 12; + + uint32 tcpi_unacked = 13; + uint32 tcpi_sacked = 14; + uint32 tcpi_lost = 15; + uint32 tcpi_retrans = 16; + uint32 tcpi_fackets = 17; + + uint32 tcpi_last_data_sent = 18; + uint32 tcpi_last_ack_sent = 19; + uint32 tcpi_last_data_recv = 20; + uint32 tcpi_last_ack_recv = 21; + + uint32 tcpi_pmtu = 22; + uint32 tcpi_rcv_ssthresh = 23; + uint32 tcpi_rtt = 24; + uint32 tcpi_rttvar = 25; + uint32 tcpi_snd_ssthresh = 26; + uint32 tcpi_snd_cwnd = 27; + uint32 tcpi_advmss = 28; + uint32 tcpi_reordering = 29; +} + +service Channelz { + // Gets all root channels (e.g. channels the application has directly + // created). This does not include subchannels nor non-top level channels. + rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse); + // Gets all servers that exist in the process. + rpc GetServers(GetServersRequest) returns (GetServersResponse); + // Gets all server sockets that exist in the process. + rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse); + // Returns a single Channel, or else a NOT_FOUND code. + rpc GetChannel(GetChannelRequest) returns (GetChannelResponse); + // Returns a single Subchannel, or else a NOT_FOUND code. + rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse); + // Returns a single Socket or else a NOT_FOUND code. + rpc GetSocket(GetSocketRequest) returns (GetSocketResponse); +} + +message GetServersRequest { + // start_server_id indicates that only servers at or above this id should be + // included in the results. + int64 start_server_id = 1; +} + +message GetServersResponse { + // list of servers that the connection detail service knows about. Sorted in + // ascending server_id order. + repeated Server server = 1; + // If set, indicates that the list of servers is the final list. Requesting + // more servers will only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetServerSocketsRequest { + int64 server_id = 1; + // start_socket_id indicates that only sockets at or above this id should be + // included in the results. + int64 start_socket_id = 2; +} + +message GetServerSocketsResponse { + // list of socket refs that the connection detail service knows about. Sorted in + // ascending socket_id order. + repeated SocketRef socket_ref = 1; + // If set, indicates that the list of sockets is the final list. Requesting + // more sockets will only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetTopChannelsRequest { + // start_channel_id indicates that only channels at or above this id should be + // included in the results. + int64 start_channel_id = 1; +} + +message GetTopChannelsResponse { + // list of channels that the connection detail service knows about. Sorted in + // ascending channel_id order. + repeated Channel channel = 1; + // If set, indicates that the list of channels is the final list. Requesting + // more channels can only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetChannelRequest { + int64 channel_id = 1; +} + +message GetChannelResponse { + Channel channel = 1; +} + +message GetSubchannelRequest { + int64 subchannel_id = 1; +} + +message GetSubchannelResponse { + Subchannel subchannel = 1; +} + +message GetSocketRequest { + int64 socket_id = 1; +} + +message GetSocketResponse { + Socket socket = 1; +} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index d96cbec292..9807300527 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,10 +60,13 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -312,7 +315,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index c045480ff4..1c042739a8 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -68,6 +68,8 @@ grpc_channel_get_info_type grpc_channel_get_info_import; grpc_insecure_channel_create_type grpc_insecure_channel_create_import; grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; grpc_channel_destroy_type grpc_channel_destroy_import; +grpc_channel_get_trace_type grpc_channel_get_trace_import; +grpc_channel_get_uuid_type grpc_channel_get_uuid_import; grpc_call_cancel_type grpc_call_cancel_import; grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; grpc_call_ref_type grpc_call_ref_import; @@ -304,6 +306,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); + grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace"); + grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid"); grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 4f07452c68..9a09321364 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -179,6 +179,12 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo typedef void(*grpc_channel_destroy_type)(grpc_channel* channel); extern grpc_channel_destroy_type grpc_channel_destroy_import; #define grpc_channel_destroy grpc_channel_destroy_import +typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel); +extern grpc_channel_get_trace_type grpc_channel_get_trace_import; +#define grpc_channel_get_trace grpc_channel_get_trace_import +typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel); +extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import; +#define grpc_channel_get_uuid grpc_channel_get_uuid_import typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved); extern grpc_call_cancel_type grpc_call_cancel_import; #define grpc_call_cancel grpc_call_cancel_import diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index c5dfd8ef37..6bf4fcdbb8 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -65,3 +65,32 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "channel_trace_test", + srcs = ["channel_trace_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + "//test/cpp/util:channel_trace_proto_helper", + ], + external_deps = [ + "gtest", + ], +) + +grpc_cc_test( + name = "status_util_test", + srcs = ["status_util_test.cc"], + language = "C++", + deps = [ + "//:grpc", + ], + external_deps = [ + "gtest", + ], +) diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc new file mode 100644 index 0000000000..3c73e33612 --- /dev/null +++ b/test/core/channel/channel_trace_test.cc @@ -0,0 +1,240 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include + +#include +#include + +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/json/json.h" + +#include "test/core/util/test_config.h" +#include "test/cpp/util/channel_trace_proto_helper.h" + +// remove me +#include +#include +#include + +namespace grpc_core { +namespace testing { +namespace { + +grpc_json* GetJsonChild(grpc_json* parent, const char* key) { + EXPECT_NE(parent, nullptr); + for (grpc_json* child = parent->child; child != nullptr; + child = child->next) { + if (child->key != nullptr && strcmp(child->key, key) == 0) return child; + } + return nullptr; +} + +void ValidateJsonArraySize(grpc_json* json, const char* key, + size_t expected_size) { + grpc_json* arr = GetJsonChild(json, key); + ASSERT_NE(arr, nullptr); + ASSERT_EQ(arr->type, GRPC_JSON_ARRAY); + size_t count = 0; + for (grpc_json* child = arr->child; child != nullptr; child = child->next) { + ++count; + } + ASSERT_EQ(count, expected_size); +} + +void ValidateChannelTraceData(grpc_json* json, + size_t num_events_logged_expected, + size_t actual_num_events_expected) { + ASSERT_NE(json, nullptr); + grpc_json* num_events_logged_json = GetJsonChild(json, "numEventsLogged"); + ASSERT_NE(num_events_logged_json, nullptr); + grpc_json* start_time = GetJsonChild(json, "creationTime"); + ASSERT_NE(start_time, nullptr); + size_t num_events_logged = + (size_t)strtol(num_events_logged_json->value, nullptr, 0); + ASSERT_EQ(num_events_logged, num_events_logged_expected); + ValidateJsonArraySize(json, "events", actual_num_events_expected); +} + +void AddSimpleTrace(RefCountedPtr tracer) { + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("simple trace")); +} + +// checks for the existence of all the required members of the tracer. +void ValidateChannelTrace(RefCountedPtr tracer, + size_t expected_num_event_logged, size_t max_nodes) { + if (!max_nodes) return; + char* json_str = tracer->RenderTrace(); + grpc::testing::ValidateChannelTraceProtoJsonTranslation(json_str); + grpc_json* json = grpc_json_parse_string(json_str); + ValidateChannelTraceData(json, expected_num_event_logged, + GPR_MIN(expected_num_event_logged, max_nodes)); + grpc_json_destroy(json); + gpr_free(json_str); +} + +void ValidateTraceDataMatchedUuidLookup(RefCountedPtr tracer) { + intptr_t uuid = tracer->GetUuid(); + if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled + char* tracer_json_str = tracer->RenderTrace(); + ChannelTrace* uuid_lookup = + grpc_channel_trace_registry_get_channel_trace(uuid); + char* uuid_lookup_json_str = uuid_lookup->RenderTrace(); + EXPECT_EQ(strcmp(tracer_json_str, uuid_lookup_json_str), 0); + gpr_free(tracer_json_str); + gpr_free(uuid_lookup_json_str); +} + +} // anonymous namespace + +class ChannelTracerTest : public ::testing::TestWithParam {}; + +// Tests basic ChannelTrace functionality like construction, adding trace, and +// lookups by uuid. +TEST_P(ChannelTracerTest, BasicTest) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateTraceDataMatchedUuidLookup(tracer); + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("trace three")); + tracer->AddTraceEvent(ChannelTrace::Severity::Error, + grpc_slice_from_static_string("trace four error")); + ValidateChannelTrace(tracer, 4, GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 6, GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 10, GetParam()); + ValidateTraceDataMatchedUuidLookup(tracer); + tracer.reset(nullptr); +} + +// Tests more complex functionality, like a parent channel tracking +// subchannles. This exercises the ref/unref patterns since the parent tracer +// and this function will both hold refs to the subchannel. +TEST_P(ChannelTracerTest, ComplexTest) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + RefCountedPtr sc1 = MakeRefCounted(GetParam()); + tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, + grpc_slice_from_static_string("subchannel one created"), sc1); + ValidateChannelTrace(tracer, 3, GetParam()); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + ValidateChannelTrace(sc1, 3, GetParam()); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + ValidateChannelTrace(sc1, 6, GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 5, GetParam()); + ValidateTraceDataMatchedUuidLookup(tracer); + RefCountedPtr sc2 = MakeRefCounted(GetParam()); + tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, + grpc_slice_from_static_string("LB channel two created"), sc2); + tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Warning, + grpc_slice_from_static_string("subchannel one inactive"), sc1); + ValidateChannelTrace(tracer, 7, GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateTraceDataMatchedUuidLookup(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); +} + +// Test a case in which the parent channel has subchannels and the subchannels +// have connections. Ensures that everything lives as long as it should then +// gets deleted. +TEST_P(ChannelTracerTest, TestNesting) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(GetParam()); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 2, GetParam()); + RefCountedPtr sc1 = MakeRefCounted(GetParam()); + tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, + grpc_slice_from_static_string("subchannel one created"), sc1); + ValidateChannelTrace(tracer, 3, GetParam()); + AddSimpleTrace(sc1); + RefCountedPtr conn1 = MakeRefCounted(GetParam()); + // nesting one level deeper. + sc1->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, + grpc_slice_from_static_string("connection one created"), conn1); + ValidateChannelTrace(tracer, 3, GetParam()); + AddSimpleTrace(conn1); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 5, GetParam()); + ValidateChannelTrace(conn1, 1, GetParam()); + RefCountedPtr sc2 = MakeRefCounted(GetParam()); + tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, + grpc_slice_from_static_string("subchannel two created"), sc2); + // this trace should not get added to the parents children since it is already + // present in the tracer. + tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Warning, + grpc_slice_from_static_string("subchannel one inactive"), sc1); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 8, GetParam()); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); + conn1.reset(nullptr); +} + +INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest, + ::testing::Values(0, 1, 2, 6, 10, 15)); + +} // namespace testing +} // namespace grpc_core + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; +} diff --git a/test/core/channel/status_util_test.cc b/test/core/channel/status_util_test.cc new file mode 100644 index 0000000000..1d64bf1995 --- /dev/null +++ b/test/core/channel/status_util_test.cc @@ -0,0 +1,49 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/channel/status_util.h" + +#include + +namespace grpc_core { +namespace internal { +namespace { + +TEST(StatusCodeSet, Basic) { + StatusCodeSet set; + EXPECT_TRUE(set.Empty()); + EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_OK); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); + set.Add(GRPC_STATUS_UNAVAILABLE); + EXPECT_FALSE(set.Empty()); + EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); + EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); +} + +} // namespace +} // namespace internal +} // namespace grpc_core + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index d430b722df..5148dc5f74 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -53,15 +53,3 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) - -grpc_cc_test( - name = "status_util_test", - srcs = ["status_util_test.cc"], - language = "C++", - deps = [ - "//:grpc", - ], - external_deps = [ - "gtest", - ], -) diff --git a/test/core/client_channel/status_util_test.cc b/test/core/client_channel/status_util_test.cc deleted file mode 100644 index f944990ad2..0000000000 --- a/test/core/client_channel/status_util_test.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/ext/filters/client_channel/status_util.h" - -#include - -namespace grpc_core { -namespace internal { -namespace { - -TEST(StatusCodeSet, Basic) { - StatusCodeSet set; - EXPECT_TRUE(set.Empty()); - EXPECT_FALSE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_OK); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_FALSE(set.Contains(GRPC_STATUS_UNAVAILABLE)); - set.Add(GRPC_STATUS_UNAVAILABLE); - EXPECT_FALSE(set.Empty()); - EXPECT_TRUE(set.Contains(GRPC_STATUS_OK)); - EXPECT_TRUE(set.Contains(GRPC_STATUS_UNAVAILABLE)); -} - -} // namespace -} // namespace internal -} // namespace grpc_core - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index bd4dc0b60e..d858603e47 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -106,6 +106,8 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_insecure_channel_create); printf("%lx", (unsigned long) grpc_lame_client_channel_create); printf("%lx", (unsigned long) grpc_channel_destroy); + printf("%lx", (unsigned long) grpc_channel_get_trace); + printf("%lx", (unsigned long) grpc_channel_get_uuid); printf("%lx", (unsigned long) grpc_call_cancel); printf("%lx", (unsigned long) grpc_call_cancel_with_status); printf("%lx", (unsigned long) grpc_call_ref); diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 4f84c73820..4ac8572072 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -84,6 +84,24 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "channel_trace_proto_helper", + srcs = [ + "channel_trace_proto_helper.cc", + ], + hdrs = [ + "channel_trace_proto_helper.h", + ], + deps = [ + "//:grpc++", + "//src/proto/grpc/channelz:channelz_proto", + ], + external_deps = [ + "gtest", + "protobuf", + ], +) + grpc_cc_library( name = "test_util_unsecure", srcs = GRPCXX_TESTUTIL_SRCS, diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc new file mode 100644 index 0000000000..fbc9f1501c --- /dev/null +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -0,0 +1,56 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test/cpp/util/channel_trace_proto_helper.h" + +#include +#include + +#include +#include +#include + +#include "src/proto/grpc/channelz/channelz.pb.h" + +namespace grpc { +namespace testing { + +void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) { + std::string tracer_json_str(tracer_json_c_str); + grpc::channelz::ChannelTrace channel_trace; + google::protobuf::util::JsonParseOptions parse_options; + // If the following line is failing, then uncomment the last line of the + // comment, and uncomment the lines that print the two strings. You can + // then compare the output, and determine what fields are missing. + // + // options.ignore_unknown_fields = true; + ASSERT_EQ(google::protobuf::util::JsonStringToMessage( + tracer_json_str, &channel_trace, parse_options), + google::protobuf::util::Status::OK); + std::string proto_json_str; + ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, + &proto_json_str), + google::protobuf::util::Status::OK); + // uncomment these to compare the the json strings. + // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str()); + // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); + ASSERT_EQ(tracer_json_str, proto_json_str); +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/util/channel_trace_proto_helper.h b/test/cpp/util/channel_trace_proto_helper.h new file mode 100644 index 0000000000..d7043d9f06 --- /dev/null +++ b/test/cpp/util/channel_trace_proto_helper.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H +#define GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H + +namespace grpc { +namespace testing { + +void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str); + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index c822d9b3cd..52a16d6e98 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,11 +1007,14 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 212e1d53dd..2757114b34 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -929,8 +929,6 @@ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/retry_throttle.h \ -src/core/ext/filters/client_channel/status_util.cc \ -src/core/ext/filters/client_channel/status_util.h \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel.h \ src/core/ext/filters/client_channel/subchannel_index.cc \ @@ -1034,6 +1032,10 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/channel_trace.cc \ +src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.cc \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1043,6 +1045,8 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.cc \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index f80cd9f2b5..08dc3fa9ea 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3034,6 +3034,27 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_channelz_proto", + "grpc++_test", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "channel_trace_test", + "src": [ + "test/core/channel/channel_trace_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -4482,7 +4503,7 @@ "language": "c++", "name": "status_util_test", "src": [ - "test/core/client_channel/status_util_test.cc" + "test/core/channel/status_util_test.cc" ], "third_party": false, "type": "target" @@ -6959,6 +6980,9 @@ "grpc_test_util" ], "headers": [ + "src/proto/grpc/channelz/channelz.grpc.pb.h", + "src/proto/grpc/channelz/channelz.pb.h", + "src/proto/grpc/channelz/channelz_mock.grpc.pb.h", "src/proto/grpc/health/v1/health.grpc.pb.h", "src/proto/grpc/health/v1/health.pb.h", "src/proto/grpc/health/v1/health_mock.grpc.pb.h", @@ -6973,6 +6997,7 @@ "src/proto/grpc/testing/echo_mock.grpc.pb.h", "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.h", + "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.h", @@ -6986,6 +7011,8 @@ "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.cc", "test/cpp/util/byte_buffer_proto_helper.h", + "test/cpp/util/channel_trace_proto_helper.cc", + "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.cc", @@ -8987,10 +9014,13 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/channel_trace.cc", + "src/core/lib/channel/channel_trace_registry.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -9155,11 +9185,14 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9301,11 +9334,14 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9453,7 +9489,6 @@ "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h" @@ -9497,8 +9532,6 @@ "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.cc", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.cc", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.cc", @@ -10437,6 +10470,20 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/proto/grpc/channelz/channelz.grpc.pb.h", + "src/proto/grpc/channelz/channelz.pb.h", + "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" + ], + "is_filegroup": true, + "language": "c++", + "name": "grpc++_channelz_proto", + "src": [], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "grpc_codegen" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 3d6b6caa2a..8a99792108 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3649,6 +3649,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "channel_trace_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, -- cgit v1.2.3 From 31e957632fc59457b061f72e98951e293c8c0851 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 21 Mar 2018 13:18:22 -0700 Subject: Moved assertion for GRPC_ARG_DEFAULT_AUTHORITY into the authority filter --- src/core/ext/filters/http/client_authority_filter.cc | 8 +++++++- src/core/lib/surface/channel.cc | 7 ------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 5294cfdcc5..f2b3e0fe7b 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -90,7 +90,13 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, channel_data* chand = static_cast(elem->channel_data); const grpc_arg* default_authority_arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_DEFAULT_AUTHORITY); - GPR_ASSERT(default_authority_arg != nullptr); + if (default_authority_arg == nullptr) { + gpr_log( + GPR_ERROR, + "GRPC_ARG_DEFAULT_AUTHORITY channel arg. not found. Note that direct " + "channels must explicity specify a value for this argument."); + abort(); + } chand->default_authority = grpc_slice_from_copied_string( grpc_channel_arg_get_string(default_authority_arg)); GPR_ASSERT(!args->is_last); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 9d38fe9c71..48bc69509f 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -155,13 +155,6 @@ static grpc_core::UniquePtr get_default_authority( if (!has_default_authority && ssl_override != nullptr) { default_authority.reset(gpr_strdup(ssl_override)); } - if (channel_stack_type == GRPC_CLIENT_DIRECT_CHANNEL && - !has_default_authority) { - gpr_log(GPR_ERROR, - "Direct channels must specify a value for the " - "GRPC_ARG_DEFAULT_AUTHORITY channel arg."); - abort(); - } return default_authority; } -- cgit v1.2.3 From 0c29f6a7037110f63c00263a57f365c00fe3dbec Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 22 Mar 2018 10:51:02 -0700 Subject: Added comment --- src/core/lib/surface/init_secure.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index 9700f43a55..28c6f7b121 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -67,6 +67,9 @@ static bool maybe_prepend_server_auth_filter( } void grpc_register_security_filters(void) { + // Register the auth client with a priority < INT_MAX to allow the authority + // filter -on which the auth filter depends- to be higher on the channel + // stack. grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX - 1, maybe_prepend_client_auth_filter, nullptr); grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX - 1, -- cgit v1.2.3 From 144f5559dabd2bd646acba1426647123d31c2323 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Fri, 23 Mar 2018 11:28:48 -0700 Subject: cache default SSL root cert store --- src/core/lib/http/httpcli_security_connector.cc | 14 ++- .../security_connector/security_connector.cc | 138 ++++++++++++--------- .../security_connector/security_connector.h | 51 +++++++- src/core/lib/surface/init.cc | 1 + src/core/lib/surface/init.h | 1 + src/core/lib/surface/init_secure.cc | 7 +- src/core/lib/surface/init_unsecure.cc | 2 + src/core/tsi/ssl_transport_security.cc | 94 +++++++++++--- src/core/tsi/ssl_transport_security.h | 40 ++++-- test/core/security/security_connector_test.cc | 27 +++- test/core/tsi/ssl_transport_security_test.cc | 38 +++++- 11 files changed, 308 insertions(+), 105 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 886357fc00..0b53d63e77 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -102,8 +102,8 @@ static grpc_security_connector_vtable httpcli_ssl_vtable = { httpcli_ssl_destroy, httpcli_ssl_check_peer, httpcli_ssl_cmp}; static grpc_security_status httpcli_ssl_channel_security_connector_create( - const char* pem_root_certs, const char* secure_peer_name, - grpc_channel_security_connector** sc) { + const char* pem_root_certs, const tsi_ssl_root_certs_store* root_store, + const char* secure_peer_name, grpc_channel_security_connector** sc) { tsi_result result = TSI_OK; grpc_httpcli_ssl_channel_security_connector* c; @@ -124,6 +124,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create( tsi_ssl_client_handshaker_options options; memset(&options, 0, sizeof(options)); options.pem_root_certs = pem_root_certs; + options.root_store = root_store; result = tsi_create_ssl_client_handshaker_factory_with_options( &options, &c->handshaker_factory); if (result != TSI_OK) { @@ -172,8 +173,11 @@ static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host, grpc_millis deadline, void (*on_done)(void* arg, grpc_endpoint* endpoint)) { on_done_closure* c = static_cast(gpr_malloc(sizeof(*c))); - const char* pem_root_certs = grpc_get_default_ssl_roots(); - if (pem_root_certs == nullptr) { + const char* pem_root_certs = + grpc_core::DefaultSslRootStore::GetPemRootCerts(); + const tsi_ssl_root_certs_store* root_store = + grpc_core::DefaultSslRootStore::GetRootStore(); + if (root_store == nullptr) { gpr_log(GPR_ERROR, "Could not get default pem root certs."); on_done(arg, nullptr); gpr_free(c); @@ -183,7 +187,7 @@ static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host, c->arg = arg; grpc_channel_security_connector* sc = nullptr; GPR_ASSERT(httpcli_ssl_channel_security_connector_create( - pem_root_certs, host, &sc) == GRPC_SECURITY_OK); + pem_root_certs, root_store, host, &sc) == GRPC_SECURITY_OK); grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base); grpc_channel_args args = {1, &channel_arg}; c->handshake_mgr = grpc_handshake_manager_create(); diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index cbe77d5a69..3967112bb8 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -965,63 +965,6 @@ static grpc_security_connector_vtable ssl_channel_vtable = { static grpc_security_connector_vtable ssl_server_vtable = { ssl_server_destroy, ssl_server_check_peer, ssl_server_cmp}; -/* returns a NULL terminated slice. */ -static grpc_slice compute_default_pem_root_certs_once(void) { - grpc_slice result = grpc_empty_slice(); - - /* First try to load the roots from the environment. */ - char* default_root_certs_path = - gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); - if (default_root_certs_path != nullptr) { - GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(default_root_certs_path, 1, &result)); - gpr_free(default_root_certs_path); - } - - /* Try overridden roots if needed. */ - grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; - if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != nullptr) { - char* pem_root_certs = nullptr; - ovrd_res = ssl_roots_override_cb(&pem_root_certs); - if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { - GPR_ASSERT(pem_root_certs != nullptr); - result = grpc_slice_from_copied_buffer( - pem_root_certs, - strlen(pem_root_certs) + 1); // NULL terminator. - } - gpr_free(pem_root_certs); - } - - /* Fall back to installed certs if needed. */ - if (GRPC_SLICE_IS_EMPTY(result) && - ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { - GRPC_LOG_IF_ERROR("load_file", - grpc_load_file(installed_roots_path, 1, &result)); - } - return result; -} - -static grpc_slice default_pem_root_certs; - -static void init_default_pem_root_certs(void) { - default_pem_root_certs = compute_default_pem_root_certs_once(); -} - -grpc_slice grpc_get_default_ssl_roots_for_testing(void) { - return compute_default_pem_root_certs_once(); -} - -const char* grpc_get_default_ssl_roots(void) { - /* TODO(jboeuf@google.com): Maybe revisit the approach which consists in - loading all the roots once for the lifetime of the process. */ - static gpr_once once = GPR_ONCE_INIT; - gpr_once_init(&once, init_default_pem_root_certs); - return GRPC_SLICE_IS_EMPTY(default_pem_root_certs) - ? nullptr - : reinterpret_cast - GRPC_SLICE_START_PTR(default_pem_root_certs); -} - grpc_security_status grpc_ssl_channel_security_connector_create( grpc_channel_credentials* channel_creds, grpc_call_credentials* request_metadata_creds, @@ -1043,7 +986,9 @@ grpc_security_status grpc_ssl_channel_security_connector_create( goto error; } if (config->pem_root_certs == nullptr) { - options.pem_root_certs = grpc_get_default_ssl_roots(); + // Use default root certificates. + options.pem_root_certs = grpc_core::DefaultSslRootStore::GetPemRootCerts(); + options.root_store = grpc_core::DefaultSslRootStore::GetRootStore(); if (options.pem_root_certs == nullptr) { gpr_log(GPR_ERROR, "Could not get default pem root certs."); goto error; @@ -1051,7 +996,6 @@ grpc_security_status grpc_ssl_channel_security_connector_create( } else { options.pem_root_certs = config->pem_root_certs; } - c = static_cast( gpr_zalloc(sizeof(grpc_ssl_channel_security_connector))); @@ -1157,3 +1101,79 @@ grpc_security_status grpc_ssl_server_security_connector_create( } return retval; } + +namespace grpc_core { + +tsi_ssl_root_certs_store* DefaultSslRootStore::default_root_store_; +grpc_slice DefaultSslRootStore::default_pem_root_certs_; + +const tsi_ssl_root_certs_store* DefaultSslRootStore::GetRootStore() { + InitRootStore(); + return default_root_store_; +} + +const char* DefaultSslRootStore::GetPemRootCerts() { + InitRootStore(); + return GRPC_SLICE_IS_EMPTY(default_pem_root_certs_) + ? nullptr + : reinterpret_cast + GRPC_SLICE_START_PTR(default_pem_root_certs_); +} + +void DefaultSslRootStore::Initialize() { + default_root_store_ = nullptr; + default_pem_root_certs_ = grpc_empty_slice(); +} + +void DefaultSslRootStore::Destroy() { + tsi_ssl_root_certs_store_destroy(default_root_store_); + grpc_slice_unref_internal(default_pem_root_certs_); +} + +grpc_slice DefaultSslRootStore::ComputePemRootCerts() { + grpc_slice result = grpc_empty_slice(); + // First try to load the roots from the environment. + char* default_root_certs_path = + gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); + if (default_root_certs_path != nullptr) { + GRPC_LOG_IF_ERROR("load_file", + grpc_load_file(default_root_certs_path, 1, &result)); + gpr_free(default_root_certs_path); + } + // Try overridden roots if needed. + grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; + if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != nullptr) { + char* pem_root_certs = nullptr; + ovrd_res = ssl_roots_override_cb(&pem_root_certs); + if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { + GPR_ASSERT(pem_root_certs != nullptr); + result = grpc_slice_from_copied_buffer( + pem_root_certs, + strlen(pem_root_certs) + 1); // nullptr terminator. + } + gpr_free(pem_root_certs); + } + // Fall back to installed certs if needed. + if (GRPC_SLICE_IS_EMPTY(result) && + ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { + GRPC_LOG_IF_ERROR("load_file", + grpc_load_file(installed_roots_path, 1, &result)); + } + return result; +} + +void DefaultSslRootStore::InitRootStore() { + static gpr_once once = GPR_ONCE_INIT; + gpr_once_init(&once, DefaultSslRootStore::InitRootStoreOnce); +} + +void DefaultSslRootStore::InitRootStoreOnce() { + default_pem_root_certs_ = ComputePemRootCerts(); + if (!GRPC_SLICE_IS_EMPTY(default_pem_root_certs_)) { + default_root_store_ = + tsi_ssl_root_certs_store_create(reinterpret_cast( + GRPC_SLICE_START_PTR(default_pem_root_certs_))); + } +} + +} // namespace grpc_core diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index dc847d94f9..5d3d1e0f44 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -216,12 +216,6 @@ grpc_security_status grpc_ssl_channel_security_connector_create( tsi_ssl_session_cache* ssl_session_cache, grpc_channel_security_connector** sc); -/* Gets the default ssl roots. Returns NULL if not found. */ -const char* grpc_get_default_ssl_roots(void); - -/* Exposed for TESTING ONLY!. */ -grpc_slice grpc_get_default_ssl_roots_for_testing(void); - /* Config for ssl servers. */ typedef struct { tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs; @@ -250,4 +244,49 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context( const grpc_auth_context* auth_context); void tsi_shallow_peer_destruct(tsi_peer* peer); +/* --- Default SSL Root Store. --- */ +namespace grpc_core { + +// The class implements default SSL root store. +class DefaultSslRootStore { + public: + // Gets the default SSL root store. Returns nullptr if not found. + static const tsi_ssl_root_certs_store* GetRootStore(); + + // Gets the default PEM root certificate. + static const char* GetPemRootCerts(); + + // Initializes the SSL root store's underlying data structure. It does not + // load default SSL root certificates. Should only be called by + // grpc_security_init(). + static void Initialize(); + + // Destroys the default SSL root store. Should only be called by + // grpc_security_shutdown(). + static void Destroy(); + + protected: + // Returns default PEM root certificates in nullptr terminated grpc_slice. + // This function is protected instead of private, so that it can be tested. + static grpc_slice ComputePemRootCerts(); + + private: + // Construct me not! + DefaultSslRootStore(); + + // Initialization of default SSL root store. + static void InitRootStore(); + + // One-time initialization of default SSL root store. + static void InitRootStoreOnce(); + + // SSL root store in tsi_ssl_root_certs_store object. + static tsi_ssl_root_certs_store* default_root_store_; + + // Default PEM root certificates. + static grpc_slice default_pem_root_certs_; +}; + +} // namespace grpc_core + #endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SECURITY_CONNECTOR_H */ diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index bd436d6857..52e0ee1c44 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -172,6 +172,7 @@ void grpc_shutdown(void) { } } } + grpc_security_shutdown(); grpc_iomgr_shutdown(); gpr_timers_global_destroy(); grpc_tracer_shutdown(); diff --git a/src/core/lib/surface/init.h b/src/core/lib/surface/init.h index 9353208332..d8282b475b 100644 --- a/src/core/lib/surface/init.h +++ b/src/core/lib/surface/init.h @@ -22,6 +22,7 @@ void grpc_register_security_filters(void); void grpc_security_pre_init(void); void grpc_security_init(void); +void grpc_security_shutdown(void); int grpc_is_initialized(void); #endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index 78e983e0cd..3e4f1a8829 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -75,4 +75,9 @@ void grpc_register_security_filters(void) { maybe_prepend_server_auth_filter, nullptr); } -void grpc_security_init() { grpc_security_register_handshaker_factories(); } +void grpc_security_init() { + grpc_security_register_handshaker_factories(); + grpc_core::DefaultSslRootStore::Initialize(); +} + +void grpc_security_shutdown() { grpc_core::DefaultSslRootStore::Destroy(); } diff --git a/src/core/lib/surface/init_unsecure.cc b/src/core/lib/surface/init_unsecure.cc index 2b3bc64382..1c8d07b38b 100644 --- a/src/core/lib/surface/init_unsecure.cc +++ b/src/core/lib/surface/init_unsecure.cc @@ -25,3 +25,5 @@ void grpc_security_pre_init(void) {} void grpc_register_security_filters(void) {} void grpc_security_init(void) {} + +void grpc_security_shutdown(void) {} diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 0fc2926cf6..0ba6587678 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -71,6 +71,10 @@ extern "C" { /* --- Structure definitions. ---*/ +struct tsi_ssl_root_certs_store { + X509_STORE* store; +}; + struct tsi_ssl_handshaker_factory { const tsi_ssl_handshaker_factory_vtable* vtable; gpr_refcount refcount; @@ -553,21 +557,18 @@ static tsi_result ssl_ctx_use_private_key(SSL_CTX* context, const char* pem_key, /* Loads in-memory PEM verification certs into the SSL context and optionally returns the verification cert names (root_names can be NULL). */ -static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context, - const char* pem_roots, - size_t pem_roots_size, - STACK_OF(X509_NAME) * - *root_names) { +static tsi_result x509_store_load_certs(X509_STORE* cert_store, + const char* pem_roots, + size_t pem_roots_size, + STACK_OF(X509_NAME) * *root_names) { tsi_result result = TSI_OK; size_t num_roots = 0; X509* root = nullptr; X509_NAME* root_name = nullptr; BIO* pem; - X509_STORE* root_store; GPR_ASSERT(pem_roots_size <= INT_MAX); pem = BIO_new_mem_buf((void*)pem_roots, static_cast(pem_roots_size)); - root_store = SSL_CTX_get_cert_store(context); - if (root_store == nullptr) return TSI_INVALID_ARGUMENT; + if (cert_store == nullptr) return TSI_INVALID_ARGUMENT; if (pem == nullptr) return TSI_OUT_OF_RESOURCES; if (root_names != nullptr) { *root_names = sk_X509_NAME_new_null(); @@ -595,7 +596,7 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context, sk_X509_NAME_push(*root_names, root_name); root_name = nullptr; } - if (!X509_STORE_add_cert(root_store, root)) { + if (!X509_STORE_add_cert(cert_store, root)) { gpr_log(GPR_ERROR, "Could not add root certificate to ssl context."); result = TSI_INTERNAL_ERROR; break; @@ -621,6 +622,16 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context, return result; } +static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context, + const char* pem_roots, + size_t pem_roots_size, + STACK_OF(X509_NAME) * + *root_name) { + X509_STORE* cert_store = SSL_CTX_get_cert_store(context); + return x509_store_load_certs(cert_store, pem_roots, pem_roots_size, + root_name); +} + /* Populates the SSL context with a private key and a cert chain, and sets the cipher list and the ephemeral ECDH key. */ static tsi_result populate_ssl_context( @@ -730,6 +741,43 @@ static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX* ctx) { return 1; } +/* --- tsi_ssl_root_certs_store methods implementation. ---*/ + +tsi_ssl_root_certs_store* tsi_ssl_root_certs_store_create( + const char* pem_roots) { + if (pem_roots == nullptr) { + gpr_log(GPR_ERROR, "The root certificates are empty."); + return nullptr; + } + tsi_ssl_root_certs_store* root_store = static_cast( + gpr_zalloc(sizeof(tsi_ssl_root_certs_store))); + if (root_store == nullptr) { + gpr_log(GPR_ERROR, "Could not allocate buffer for ssl_root_certs_store."); + return nullptr; + } + root_store->store = X509_STORE_new(); + if (root_store->store == nullptr) { + gpr_log(GPR_ERROR, "Could not allocate buffer for X509_STORE."); + gpr_free(root_store); + return nullptr; + } + tsi_result result = x509_store_load_certs(root_store->store, pem_roots, + strlen(pem_roots), nullptr); + if (result != TSI_OK) { + gpr_log(GPR_ERROR, "Could not load root certificates."); + X509_STORE_free(root_store->store); + gpr_free(root_store); + return nullptr; + } + return root_store; +} + +void tsi_ssl_root_certs_store_destroy(tsi_ssl_root_certs_store* self) { + if (self == nullptr) return; + X509_STORE_free(self->store); + gpr_free(self); +} + /* --- tsi_ssl_session_cache methods implementation. ---*/ tsi_ssl_session_cache* tsi_ssl_session_cache_create_lru(size_t capacity) { @@ -1468,7 +1516,9 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options( if (factory == nullptr) return TSI_INVALID_ARGUMENT; *factory = nullptr; - if (options->pem_root_certs == nullptr) return TSI_INVALID_ARGUMENT; + if (options->pem_root_certs == nullptr && options->root_store == nullptr) { + return TSI_INVALID_ARGUMENT; + } ssl_context = SSL_CTX_new(TLSv1_2_method()); if (ssl_context == nullptr) { @@ -1480,9 +1530,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options( gpr_zalloc(sizeof(*impl))); tsi_ssl_handshaker_factory_init(&impl->base); impl->base.vtable = &client_handshaker_factory_vtable; - impl->ssl_context = ssl_context; - if (options->session_cache != nullptr) { // Unref is called manually on factory destruction. impl->session_cache = @@ -1498,12 +1546,22 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options( result = populate_ssl_context(ssl_context, options->pem_key_cert_pair, options->cipher_suites); if (result != TSI_OK) break; - result = ssl_ctx_load_verification_certs( - ssl_context, options->pem_root_certs, strlen(options->pem_root_certs), - nullptr); - if (result != TSI_OK) { - gpr_log(GPR_ERROR, "Cannot load server root certificates."); - break; + +#if OPENSSL_VERSION_NUMBER >= 0x10100000 + // X509_STORE_up_ref is only available since OpenSSL 1.1. + if (options->root_store != nullptr) { + X509_STORE_up_ref(options->root_store->store); + SSL_CTX_set_cert_store(ssl_context, options->root_store->store); + } +#endif + if (OPENSSL_VERSION_NUMBER < 0x10100000 || options->root_store == nullptr) { + result = ssl_ctx_load_verification_certs( + ssl_context, options->pem_root_certs, strlen(options->pem_root_certs), + nullptr); + if (result != TSI_OK) { + gpr_log(GPR_ERROR, "Cannot load server root certificates."); + break; + } } if (options->num_alpn_protocols != 0) { diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index 29d209b8f5..cabf583098 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -36,6 +36,20 @@ #define TSI_SSL_ALPN_SELECTED_PROTOCOL "ssl_alpn_selected_protocol" +/* --- tsi_ssl_root_certs_store object --- + + This object stores SSL root certificates. It can be shared by multiple SSL + context. */ +typedef struct tsi_ssl_root_certs_store tsi_ssl_root_certs_store; + +/* Given a NULL-terminated string containing the PEM encoding of the root + certificates, creates a tsi_ssl_root_certs_store object. */ +tsi_ssl_root_certs_store* tsi_ssl_root_certs_store_create( + const char* pem_roots); + +/* Destroys the tsi_ssl_root_certs_store object. */ +void tsi_ssl_root_certs_store_destroy(tsi_ssl_root_certs_store* self); + /* --- tsi_ssl_session_cache object --- Cache for SSL sessions for sessions resumption. */ @@ -70,13 +84,13 @@ typedef struct { const char* cert_chain; } tsi_ssl_pem_key_cert_pair; -/* Creates a client handshaker factory. +/* TO BE DEPRECATED. + Creates a client handshaker factory. - pem_key_cert_pair is a pointer to the object containing client's private key and certificate chain. This parameter can be NULL if the client does not have such a key/cert pair. - pem_roots_cert is the NULL-terminated string containing the PEM encoding of - the client root certificates. This parameter may be NULL if the server does - not want the client to be authenticated with SSL. + the server root certificates. - cipher_suites contains an optional list of the ciphers that the client supports. The format of this string is described in: https://www.openssl.org/docs/apps/ciphers.html. @@ -103,9 +117,13 @@ typedef struct { not have such a key/cert pair. */ const tsi_ssl_pem_key_cert_pair* pem_key_cert_pair; /* pem_roots_cert is the NULL-terminated string containing the PEM encoding of - the client root certificates. This parameter may be NULL if the server does - not want the client to be authenticated with SSL. */ + the client root certificates. */ const char* pem_root_certs; + /* root_store is a pointer to the ssl_root_certs_store object. If root_store + is not nullptr and SSL implementation permits, root_store will be used as + root certificates. Otherwise, pem_roots_cert will be used to load server + root certificates. */ + const tsi_ssl_root_certs_store* root_store; /* cipher_suites contains an optional list of the ciphers that the client supports. The format of this string is described in: https://www.openssl.org/docs/apps/ciphers.html. @@ -160,12 +178,14 @@ void tsi_ssl_client_handshaker_factory_unref( typedef struct tsi_ssl_server_handshaker_factory tsi_ssl_server_handshaker_factory; -/* Creates a server handshaker factory. +/* TO BE DEPRECATED. + Creates a server handshaker factory. - pem_key_cert_pairs is an array private key / certificate chains of the server. - num_key_cert_pairs is the number of items in the pem_key_cert_pairs array. - pem_root_certs is the NULL-terminated string containing the PEM encoding - of the server root certificates. + of the client root certificates. This parameter may be NULL if the server + does not want the client to be authenticated with SSL. - cipher_suites contains an optional list of the ciphers that the server supports. The format of this string is described in: https://www.openssl.org/docs/apps/ciphers.html. @@ -187,7 +207,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory( const char** alpn_protocols, uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory); -/* Same as tsi_create_ssl_server_handshaker_factory method except uses +/* TO BE DEPRECATED. + Same as tsi_create_ssl_server_handshaker_factory method except uses tsi_client_certificate_request_type to support more ways to handle client certificate authentication. - client_certificate_request, if set to non-zero will force the client to @@ -208,7 +229,8 @@ typedef struct { array. */ size_t num_key_cert_pairs; /* pem_root_certs is the NULL-terminated string containing the PEM encoding - of the server root certificates. */ + of the server root certificates. This parameter may be NULL if the server + does not want the client to be authenticated with SSL. */ const char* pem_client_root_certs; /* client_certificate_request, if set to non-zero will force the client to authenticate with an SSL cert. Note that this option is ignored if diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index ed3849bfc8..f03f4ccdbd 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -340,6 +340,21 @@ static grpc_ssl_roots_override_result override_roots_permanent_failure( return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY; } +namespace grpc_core { +namespace { + +class TestDefafaultSllRootStore : public DefaultSslRootStore { + public: + static grpc_slice ComputePemRootCertsForTesting() { + return ComputePemRootCerts(); + } +}; + +} // namespace +} // namespace grpc_core + +// TODO: Convert this test to C++ test when security_connector implementation +// is converted to C++. static void test_default_ssl_roots(void) { const char* roots_for_env_var = "roots for env var"; @@ -353,7 +368,8 @@ static void test_default_ssl_roots(void) { value. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); grpc_set_ssl_roots_override_callback(override_roots_success); - grpc_slice roots = grpc_get_default_ssl_roots_for_testing(); + grpc_slice roots = + grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting(); char* roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); @@ -362,7 +378,7 @@ static void test_default_ssl_roots(void) { /* Now let's set the env var: We should get the contents pointed value instead. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); - roots = grpc_get_default_ssl_roots_for_testing(); + roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_env_var) == 0); @@ -371,7 +387,7 @@ static void test_default_ssl_roots(void) { /* Now reset the env var. We should fall back to the value overridden using the api. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); - roots = grpc_get_default_ssl_roots_for_testing(); + roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting(); roots_contents = grpc_slice_to_c_string(roots); grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); @@ -380,8 +396,11 @@ static void test_default_ssl_roots(void) { /* Now setup a permanent failure for the overridden roots and we should get an empty slice. */ grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); - roots = grpc_get_default_ssl_roots_for_testing(); + roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting(); GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots)); + const tsi_ssl_root_certs_store* root_store = + grpc_core::TestDefafaultSllRootStore::GetRootStore(); + GPR_ASSERT(root_store == nullptr); /* Cleanup. */ remove(roots_env_var_file_path); diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 0878c57931..88f1abc18c 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -61,7 +61,9 @@ typedef struct ssl_alpn_lib { typedef struct ssl_key_cert_lib { bool use_bad_server_cert; bool use_bad_client_cert; + bool use_root_store; char* root_cert; + tsi_ssl_root_certs_store* root_store; tsi_ssl_pem_key_cert_pair* server_pem_key_cert_pairs; tsi_ssl_pem_key_cert_pair* bad_server_pem_key_cert_pairs; tsi_ssl_pem_key_cert_pair client_pem_key_cert_pair; @@ -108,6 +110,8 @@ static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) { client_options.alpn_protocols = alpn_lib->client_alpn_protocols; client_options.num_alpn_protocols = alpn_lib->num_client_alpn_protocols; } + client_options.root_store = + key_cert_lib->use_root_store ? key_cert_lib->root_store : nullptr; if (ssl_fixture->session_cache != nullptr) { client_options.session_cache = ssl_fixture->session_cache; } @@ -345,6 +349,7 @@ static void ssl_test_destruct(tsi_test_fixture* fixture) { ssl_test_pem_key_cert_pair_destroy( key_cert_lib->bad_client_pem_key_cert_pair); gpr_free(key_cert_lib->root_cert); + tsi_ssl_root_certs_store_destroy(key_cert_lib->root_store); gpr_free(key_cert_lib); if (ssl_fixture->session_cache != nullptr) { tsi_ssl_session_cache_unref(ssl_fixture->session_cache); @@ -384,6 +389,7 @@ static tsi_test_fixture* ssl_tsi_test_fixture_create() { static_cast(gpr_zalloc(sizeof(*key_cert_lib))); key_cert_lib->use_bad_server_cert = false; key_cert_lib->use_bad_client_cert = false; + key_cert_lib->use_root_store = false; key_cert_lib->server_num_key_cert_pairs = SSL_TSI_TEST_SERVER_KEY_CERT_PAIRS_NUM; key_cert_lib->bad_server_num_key_cert_pairs = @@ -417,6 +423,9 @@ static tsi_test_fixture* ssl_tsi_test_fixture_create() { key_cert_lib->bad_client_pem_key_cert_pair.cert_chain = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "badclient.pem"); key_cert_lib->root_cert = load_file(SSL_TSI_TEST_CREDENTIALS_DIR, "ca.pem"); + key_cert_lib->root_store = + tsi_ssl_root_certs_store_create(key_cert_lib->root_cert); + GPR_ASSERT(key_cert_lib->root_store != nullptr); ssl_fixture->key_cert_lib = key_cert_lib; /* Create ssl_alpn_lib. */ ssl_alpn_lib* alpn_lib = @@ -462,6 +471,15 @@ void ssl_tsi_test_do_handshake() { tsi_test_fixture_destroy(fixture); } +void ssl_tsi_test_do_handshake_with_root_store() { + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = + reinterpret_cast(fixture); + ssl_fixture->key_cert_lib->use_root_store = true; + tsi_test_do_handshake(fixture); + tsi_test_fixture_destroy(fixture); +} + void ssl_tsi_test_do_handshake_with_client_authentication() { tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); ssl_tsi_test_fixture* ssl_fixture = @@ -471,6 +489,16 @@ void ssl_tsi_test_do_handshake_with_client_authentication() { tsi_test_fixture_destroy(fixture); } +void ssl_tsi_test_do_handshake_with_client_authentication_and_root_store() { + tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); + ssl_tsi_test_fixture* ssl_fixture = + reinterpret_cast(fixture); + ssl_fixture->force_client_auth = true; + ssl_fixture->key_cert_lib->use_root_store = true; + tsi_test_do_handshake(fixture); + tsi_test_fixture_destroy(fixture); +} + void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() { /* server1 cert contains "waterzooi.test.google.be" in SAN. */ tsi_test_fixture* fixture = ssl_tsi_test_fixture_create(); @@ -727,9 +755,11 @@ void test_tsi_ssl_client_handshaker_factory_bad_params() { const char* cert_chain = "This is not a valid PEM file."; tsi_ssl_client_handshaker_factory* client_handshaker_factory; - GPR_ASSERT(tsi_create_ssl_client_handshaker_factory( - nullptr, cert_chain, nullptr, nullptr, 0, - &client_handshaker_factory) == TSI_INVALID_ARGUMENT); + tsi_ssl_client_handshaker_options options; + memset(&options, 0, sizeof(options)); + options.pem_root_certs = cert_chain; + GPR_ASSERT(tsi_create_ssl_client_handshaker_factory_with_options( + &options, &client_handshaker_factory) == TSI_INVALID_ARGUMENT); tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory); } @@ -746,7 +776,9 @@ int main(int argc, char** argv) { ssl_tsi_test_do_handshake_tiny_handshake_buffer(); ssl_tsi_test_do_handshake_small_handshake_buffer(); ssl_tsi_test_do_handshake(); + ssl_tsi_test_do_handshake_with_root_store(); ssl_tsi_test_do_handshake_with_client_authentication(); + ssl_tsi_test_do_handshake_with_client_authentication_and_root_store(); ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain(); ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain(); ssl_tsi_test_do_handshake_with_bad_server_cert(); -- cgit v1.2.3 From d043fa06bcc896a12b4563bbf61fe99fdd0bb9d4 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 23 Mar 2018 13:58:27 -0700 Subject: PR comments --- .../security_connector/security_connector.cc | 19 +++++++++++----- src/core/lib/surface/channel.cc | 5 ++--- test/core/end2end/fixtures/h2_fakesec.cc | 1 - test/core/end2end/tests/default_host.cc | 26 +++++++++++----------- test/cpp/end2end/end2end_test.cc | 2 +- test/cpp/end2end/shutdown_test.cc | 1 - 6 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index 8040ec99c4..a0e05a3fbd 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -474,14 +474,21 @@ static bool fake_channel_check_call_host(grpc_channel_security_connector* sc, gpr_split_host_port(host, &authority_hostname, &authority_ignored_port); gpr_split_host_port(c->target, &target_hostname, &target_ignored_port); if (c->ssl_target_name_override != nullptr) { - abort(); - if (strcmp(authority_hostname, target_hostname) != 0) { + char* ssl_target_name_override_hostname = nullptr; + char* ssl_target_name_override_ignored_port = nullptr; + gpr_split_host_port(c->ssl_target_name_override, + &ssl_target_name_override_hostname, + &ssl_target_name_override_ignored_port); + if (strcmp(authority_hostname, ssl_target_name_override_hostname) != 0) { gpr_log(GPR_ERROR, "Authority (host) '%s' != SSL Target override '%s'", - host, c->ssl_target_name_override); + host, ssl_target_name_override_hostname); + abort(); } - } - if (strcmp(authority_hostname, target_hostname) != 0) { - gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host, c->target); + gpr_free(ssl_target_name_override_hostname); + gpr_free(ssl_target_name_override_ignored_port); + } else if (strcmp(authority_hostname, target_hostname) != 0) { + gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", + authority_hostname, target_hostname); abort(); } gpr_free(authority_hostname); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 1eb5ef0c0c..807e28eef1 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -157,8 +157,7 @@ grpc_channel* grpc_channel_create_with_builder( } static grpc_core::UniquePtr get_default_authority( - const char* target, const grpc_channel_args* input_args, - grpc_channel_stack_type channel_stack_type) { + const grpc_channel_args* input_args) { bool has_default_authority = false; char* ssl_override = nullptr; grpc_core::UniquePtr default_authority; @@ -202,7 +201,7 @@ grpc_channel* grpc_channel_create(const char* target, grpc_transport* optional_transport) { grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); const grpc_core::UniquePtr default_authority = - get_default_authority(target, input_args, channel_stack_type); + get_default_authority(input_args); grpc_channel_args* args = build_channel_args(input_args, default_authority.get()); grpc_channel_stack_builder_set_channel_arguments(builder, args); diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index bbf65fcd24..8b326befd3 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -132,7 +132,6 @@ static void chttp2_init_server_fake_secure_fullstack( static grpc_end2end_test_config configs[] = { {"chttp2/fake_secure_fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_secure_fullstack, diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc index cda716a259..5984e522f6 100644 --- a/test/core/end2end/tests/default_host.cc +++ b/test/core/end2end/tests/default_host.cc @@ -85,7 +85,13 @@ static void end_test(grpc_end2end_test_fixture* f) { grpc_completion_queue_destroy(f->shutdown_cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void test_invoke_simple_request(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_simple_request", nullptr, nullptr); + const bool override_host_for_call_creds_use = + (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) != 0; + const char* expected_host = + override_host_for_call_creds_use ? "foo.test.google.fr" : "localhost"; grpc_call* c; grpc_call* s; cq_verifier* cqv = cq_verifier_create(f.cq); @@ -191,9 +197,12 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); - char* target = grpc_channel_get_target(f.client); - GPR_ASSERT(grpc_slice_buf_start_eq(call_details.host, target, 9)); - gpr_free(target); + if (override_host_for_call_creds_use) { + validate_host_override_string("foo.test.google.fr", call_details.host, + config); + } + GPR_ASSERT(grpc_slice_buf_start_eq(call_details.host, expected_host, + strlen(expected_host))); GPR_ASSERT(was_cancelled == 1); grpc_slice_unref(details); @@ -206,21 +215,12 @@ static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call_unref(s); cq_verifier_destroy(cqv); -} -static void test_invoke_simple_request(grpc_end2end_test_config config) { - grpc_end2end_test_fixture f; - - f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr); - simple_request_body(f); end_test(&f); config.tear_down_data(&f); } void default_host(grpc_end2end_test_config config) { - if ((config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) != 0) { - return; - } test_invoke_simple_request(config); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5efea4a58d..60238e930d 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -290,7 +290,7 @@ class End2endTest : public ::testing::TestWithParam { args.SetUserAgentPrefix(user_agent_prefix_); } args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test"); - args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test-authority"); + if (!GetParam().inproc) { channel_ = CreateCustomChannel(server_address_.str(), channel_creds, args); diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index dd916da5c4..a53de691bc 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -86,7 +86,6 @@ class ShutdownTest : public ::testing::TestWithParam { ChannelArguments args; auto channel_creds = GetCredentialsProvider()->GetChannelCredentials(GetParam(), &args); - args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test-authority"); channel_ = CreateCustomChannel(target, channel_creds, args); stub_ = grpc::testing::EchoTestService::NewStub(channel_); } -- cgit v1.2.3 From 4fe2cd255544b8cbeff7b340760791d8d1fad93e Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Wed, 28 Mar 2018 20:16:17 -0700 Subject: Init default root certs store once --- src/core/lib/security/security_connector/security_connector.cc | 10 ---------- src/core/lib/security/security_connector/security_connector.h | 9 --------- src/core/lib/surface/init.cc | 1 - src/core/lib/surface/init.h | 1 - src/core/lib/surface/init_secure.cc | 7 +------ src/core/lib/surface/init_unsecure.cc | 2 -- 6 files changed, 1 insertion(+), 29 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/security/security_connector/security_connector.cc b/src/core/lib/security/security_connector/security_connector.cc index d7d5a8c4de..3551061aa4 100644 --- a/src/core/lib/security/security_connector/security_connector.cc +++ b/src/core/lib/security/security_connector/security_connector.cc @@ -1151,16 +1151,6 @@ const char* DefaultSslRootStore::GetPemRootCerts() { GRPC_SLICE_START_PTR(default_pem_root_certs_); } -void DefaultSslRootStore::Initialize() { - default_root_store_ = nullptr; - default_pem_root_certs_ = grpc_empty_slice(); -} - -void DefaultSslRootStore::Destroy() { - tsi_ssl_root_certs_store_destroy(default_root_store_); - grpc_slice_unref_internal(default_pem_root_certs_); -} - grpc_slice DefaultSslRootStore::ComputePemRootCerts() { grpc_slice result = grpc_empty_slice(); // First try to load the roots from the environment. diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index 5d3d1e0f44..c4cc19db81 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -256,15 +256,6 @@ class DefaultSslRootStore { // Gets the default PEM root certificate. static const char* GetPemRootCerts(); - // Initializes the SSL root store's underlying data structure. It does not - // load default SSL root certificates. Should only be called by - // grpc_security_init(). - static void Initialize(); - - // Destroys the default SSL root store. Should only be called by - // grpc_security_shutdown(). - static void Destroy(); - protected: // Returns default PEM root certificates in nullptr terminated grpc_slice. // This function is protected instead of private, so that it can be tested. diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 52e0ee1c44..bd436d6857 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -172,7 +172,6 @@ void grpc_shutdown(void) { } } } - grpc_security_shutdown(); grpc_iomgr_shutdown(); gpr_timers_global_destroy(); grpc_tracer_shutdown(); diff --git a/src/core/lib/surface/init.h b/src/core/lib/surface/init.h index d8282b475b..9353208332 100644 --- a/src/core/lib/surface/init.h +++ b/src/core/lib/surface/init.h @@ -22,7 +22,6 @@ void grpc_register_security_filters(void); void grpc_security_pre_init(void); void grpc_security_init(void); -void grpc_security_shutdown(void); int grpc_is_initialized(void); #endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index caa67c2512..28c6f7b121 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -78,9 +78,4 @@ void grpc_register_security_filters(void) { maybe_prepend_server_auth_filter, nullptr); } -void grpc_security_init() { - grpc_security_register_handshaker_factories(); - grpc_core::DefaultSslRootStore::Initialize(); -} - -void grpc_security_shutdown() { grpc_core::DefaultSslRootStore::Destroy(); } +void grpc_security_init() { grpc_security_register_handshaker_factories(); } diff --git a/src/core/lib/surface/init_unsecure.cc b/src/core/lib/surface/init_unsecure.cc index 1c8d07b38b..2b3bc64382 100644 --- a/src/core/lib/surface/init_unsecure.cc +++ b/src/core/lib/surface/init_unsecure.cc @@ -25,5 +25,3 @@ void grpc_security_pre_init(void) {} void grpc_register_security_filters(void) {} void grpc_security_init(void) {} - -void grpc_security_shutdown(void) {} -- cgit v1.2.3 From d3ace6cf29778e26c97d0de138dcdd30afac07e5 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 29 Mar 2018 10:13:14 -0700 Subject: Fix authority fuzzing failures --- .../ext/filters/http/client_authority_filter.cc | 11 +++- src/core/lib/surface/channel.cc | 2 +- ...lusterfuzz-testcase-api_fuzzer-5406804084260864 | Bin 0 -> 44 bytes ...lusterfuzz-testcase-api_fuzzer-5471994809155584 | Bin 0 -> 287 bytes ...lusterfuzz-testcase-api_fuzzer-6609852341157888 | Bin 0 -> 1125 bytes tools/run_tests/generated/tests.json | 69 +++++++++++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5406804084260864 create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5471994809155584 create mode 100644 test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-6609852341157888 (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index f2b3e0fe7b..6d68ffcd21 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -97,8 +97,15 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, "channels must explicity specify a value for this argument."); abort(); } - chand->default_authority = grpc_slice_from_copied_string( - grpc_channel_arg_get_string(default_authority_arg)); + const char* default_authority_str = + grpc_channel_arg_get_string(default_authority_arg); + if (default_authority_str == nullptr) { + gpr_log(GPR_ERROR, + "GRPC_ARG_DEFAULT_AUTHORITY channel arg. must be a string."); + abort(); + } + chand->default_authority = + grpc_slice_from_copied_string(default_authority_str); GPR_ASSERT(!args->is_last); return GRPC_ERROR_NONE; } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 807e28eef1..d740ebd411 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -167,7 +167,7 @@ static grpc_core::UniquePtr get_default_authority( has_default_authority = true; } else if (0 == strcmp(input_args->args[i].key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) { - ssl_override = input_args->args[i].value.string; + ssl_override = grpc_channel_arg_get_string(&input_args->args[i]); } } if (!has_default_authority && ssl_override != nullptr) { diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5406804084260864 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5406804084260864 new file mode 100644 index 0000000000..121aac7ec8 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5406804084260864 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5471994809155584 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5471994809155584 new file mode 100644 index 0000000000..e5d3d38e96 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5471994809155584 differ diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-6609852341157888 b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-6609852341157888 new file mode 100644 index 0000000000..b7debabf19 Binary files /dev/null and b/test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-6609852341157888 differ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index c5d3143924..d8c1a125a1 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -104488,6 +104488,75 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5406804084260864" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "mac", + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-5471994809155584" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "mac", + "linux" + ], + "uses_polling": false + }, + { + "args": [ + "test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-api_fuzzer-6609852341157888" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "api_fuzzer_one_entry", + "platforms": [ + "mac", + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/api_fuzzer_corpus/clusterfuzz-testcase-minimized-4688823906729984" -- cgit v1.2.3 From 1fd44337fc117429955a84b53f2efdee89a15c60 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 30 Mar 2018 15:41:14 -0700 Subject: Shutdown documentation --- src/core/lib/surface/server.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index f7505c888e..cb34def740 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1161,6 +1161,22 @@ static void listener_destroy_done(void* s, grpc_error* error) { gpr_mu_unlock(&server->mu_global); } +/* + - Kills all pending requests-for-incoming-RPC-calls (i.e the requests made via + grpc_server_request_call and grpc_server_request_registered call will now be + cancelled). See 'kill_pending_work_locked()' + + - Shuts down the listeners (i.e the server will no longer listen on the port + for new incoming channels). + + - Iterates through all channels on the server and sends shutdown msg (see + 'channel_broadcaster_shutdown()' for details) to the clients via the + transport layer. The transport layer then guarantees the following: + -- Sends shutdown to the client (for eg: HTTP2 transport sends GOAWAY) + -- If the server has outstanding calls that are in the process, the + connection is NOT closed until the server is done with all those calls + -- Once, there are no more calls in progress, the channel is closed + */ void grpc_server_shutdown_and_notify(grpc_server* server, grpc_completion_queue* cq, void* tag) { listener* l; -- cgit v1.2.3 From 90cfc8ed5727680e1f67f3789285d1d04b390548 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Wed, 4 Apr 2018 14:04:11 -0700 Subject: Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core/Version.csproj.include | 2 +- src/csharp/Grpc.Core/VersionInfo.cs | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/core/lib/surface') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fd9826e99..d94422f741 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.11.0-dev") +set(PACKAGE_VERSION "1.12.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 64195ee6ff..77ef1b3cbc 100644 --- a/Makefile +++ b/Makefile @@ -421,8 +421,8 @@ Q = @ endif CORE_VERSION = 6.0.0-dev -CPP_VERSION = 1.11.0-dev -CSHARP_VERSION = 1.11.0-dev +CPP_VERSION = 1.12.0-dev +CSHARP_VERSION = 1.12.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 9d4d15a9a1..c5a4e50cd3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.11.0-dev' + # version = '1.12.0-dev' version = '0.0.2' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.11.0-dev' + grpc_version = '1.12.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 0eadbb5147..bd192b43ca 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.11.0-dev' + version = '1.12.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 149687e5b4..e98dee4a3c 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.11.0-dev' + version = '1.12.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 2497174417..3bba14b695 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.11.0-dev' + version = '1.12.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 68e06b5536..bf73ffd22e 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.11.0-dev' + version = '1.12.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index fd43006836..0777ee0050 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.11.0dev - 1.11.0dev + 1.12.0dev + 1.12.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index be196a78bc..a712e10037 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "6.0.0-dev"; } -const char* grpc_g_stands_for(void) { return "gorgeous"; } +const char* grpc_g_stands_for(void) { return "glorious"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index fb1723c816..d669ea21a9 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.11.0-dev"; } +grpc::string Version() { return "1.12.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include index 9b55f2469a..f7a7a5cbe9 100755 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ b/src/csharp/Grpc.Core/Version.csproj.include @@ -1,7 +1,7 @@ - 1.11.0-dev + 1.12.0-dev 3.3.0 diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 2902aee8d9..06a0396c34 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.11.0.0"; + public const string CurrentAssemblyFileVersion = "1.12.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.11.0-dev"; + public const string CurrentVersion = "1.12.0-dev"; } } diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 76391738ff..0d65748697 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.11.0-dev +set VERSION=1.12.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 1b73614b91..66aba36089 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -45,7 +45,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts -nuget pack Grpc.nuspec -Version "1.11.0-dev" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.11.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 954beed8e1..f06312bea9 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.11.0-dev' + v = '1.12.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 405c2fff9f..a99eb289c3 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -23,4 +23,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.12.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 6f6cd25007..15fe1a59f3 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -23,5 +23,5 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.12.0-dev" #define GRPC_C_VERSION_STRING @"6.0.0-dev" diff --git a/src/php/composer.json b/src/php/composer.json index dbf0cc35fd..57d911db79 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.11.0", + "version": "1.12.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index dd2a701ada..37df2768bf 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.11.0dev" +#define PHP_GRPC_VERSION "1.12.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index 4a69d859fc..cb5da72f1f 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.11.0.dev0""" +__version__ = """1.12.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 32e82493f3..de5a780abd 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index ad4c85cc12..afcd316e5c 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 6322d847b1..824b73201d 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 1e75fea12e..5b1f4c4cc0 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 0cd7bd257f..382f95018e 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 256a543a9f..2cb7c4be53 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.11.0.dev' + VERSION = '1.12.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 8dc1623d6f..822f70eb0a 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.11.0.dev' + VERSION = '1.12.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index e8ca6851eb..e71f836f6d 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.11.0.dev0' +VERSION = '1.12.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index eb6700d529..047b27ea57 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.11.0-dev +PROJECT_NUMBER = 1.12.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 52a16d6e98..3e2c192864 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.11.0-dev +PROJECT_NUMBER = 1.12.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From a9c6ad95677023bb37638233d8d1b7376eb427ef Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Apr 2018 14:36:55 -0700 Subject: No dump error for unknown value in accept-encoding --- src/core/lib/surface/call.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index c683cc02de..9a9113643d 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -878,8 +878,8 @@ static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel, } else { char* accept_encoding_entry_str = grpc_slice_to_c_string(accept_encoding_entry_slice); - gpr_log(GPR_ERROR, - "Invalid entry in accept encoding metadata: '%s'. Ignoring.", + gpr_log(GPR_DEBUG, + "Unknown entry in accept encoding metadata: '%s'. Ignoring.", accept_encoding_entry_str); gpr_free(accept_encoding_entry_str); } -- cgit v1.2.3 From 48854d20614108cf1ee9b4f0141c4b9f4eb5b233 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 25 Apr 2018 13:05:26 -0700 Subject: Change trace logging to use GPR_INFO instead of GPR_DEBUG. --- .../ext/filters/client_channel/client_channel.cc | 151 ++++++++++----------- src/core/ext/filters/client_channel/lb_policy.cc | 4 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 17 ++- .../lb_policy/pick_first/pick_first.cc | 10 +- .../lb_policy/round_robin/round_robin.cc | 31 ++--- .../client_channel/lb_policy/subchannel_list.cc | 22 +-- .../message_compress/message_compress_filter.cc | 4 +- .../transport/chttp2/transport/chttp2_transport.cc | 25 ++-- .../transport/chttp2/transport/frame_settings.cc | 6 +- .../transport/chttp2/transport/hpack_encoder.cc | 4 +- .../ext/transport/chttp2/transport/hpack_parser.cc | 2 +- .../ext/transport/chttp2/transport/hpack_table.cc | 4 +- .../ext/transport/chttp2/transport/stream_lists.cc | 6 +- src/core/ext/transport/chttp2/transport/writing.cc | 10 +- src/core/ext/transport/inproc/inproc_transport.cc | 84 ++++++------ src/core/lib/channel/handshaker.cc | 8 +- src/core/lib/gprpp/orphanable.h | 4 +- src/core/lib/gprpp/ref_counted.h | 4 +- src/core/lib/iomgr/call_combiner.cc | 26 ++-- src/core/lib/iomgr/combiner.cc | 22 +-- src/core/lib/iomgr/ev_epoll1_linux.cc | 48 +++---- src/core/lib/iomgr/ev_epollex_linux.cc | 54 ++++---- src/core/lib/iomgr/ev_epollsig_linux.cc | 4 +- src/core/lib/iomgr/ev_poll_posix.cc | 6 +- src/core/lib/iomgr/ev_posix.cc | 6 +- src/core/lib/iomgr/executor.cc | 12 +- src/core/lib/iomgr/resource_quota.cc | 21 ++- src/core/lib/iomgr/tcp_client_custom.cc | 4 +- src/core/lib/iomgr/tcp_client_posix.cc | 8 +- src/core/lib/iomgr/tcp_custom.cc | 20 +-- src/core/lib/iomgr/tcp_posix.cc | 48 +++---- src/core/lib/iomgr/tcp_server_custom.cc | 10 +- src/core/lib/iomgr/tcp_server_posix.cc | 2 +- src/core/lib/iomgr/timer_generic.cc | 34 ++--- src/core/lib/iomgr/timer_manager.cc | 23 ++-- src/core/lib/security/transport/secure_endpoint.cc | 4 +- src/core/lib/surface/call.cc | 4 +- src/core/lib/transport/bdp_estimator.cc | 6 +- src/core/lib/transport/bdp_estimator.h | 4 +- src/core/lib/transport/connectivity_state.cc | 13 +- 40 files changed, 383 insertions(+), 392 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 33cf56519e..875af66168 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -174,7 +174,7 @@ static void set_channel_connectivity_state_locked(channel_data* chand, } } if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand, + gpr_log(GPR_INFO, "chand=%p: setting connectivity state to %s", chand, grpc_connectivity_state_name(state)); } grpc_connectivity_state_set(&chand->state_tracker, state, error, reason); @@ -186,7 +186,7 @@ static void on_lb_policy_state_changed_locked(void* arg, grpc_error* error) { /* check if the notification is for the latest policy */ if (w->lb_policy == w->chand->lb_policy.get()) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand, + gpr_log(GPR_INFO, "chand=%p: lb_policy=%p state changed to %s", w->chand, w->lb_policy, grpc_connectivity_state_name(w->state)); } set_channel_connectivity_state_locked(w->chand, w->state, @@ -215,7 +215,7 @@ static void watch_lb_policy_locked(channel_data* chand, static void start_resolving_locked(channel_data* chand) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand); + gpr_log(GPR_INFO, "chand=%p: starting name resolution", chand); } GPR_ASSERT(!chand->started_resolving); chand->started_resolving = true; @@ -297,7 +297,7 @@ static void request_reresolution_locked(void* arg, grpc_error* error) { return; } if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: started name re-resolving", chand); + gpr_log(GPR_INFO, "chand=%p: started name re-resolving", chand); } chand->resolver->RequestReresolutionLocked(); // Give back the closure to the LB policy. @@ -311,7 +311,7 @@ static void request_reresolution_locked(void* arg, grpc_error* error) { static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { channel_data* chand = static_cast(arg); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p: got resolver result: resolver_result=%p error=%s", chand, chand->resolver_result, grpc_error_string(error)); } @@ -431,7 +431,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { } } if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p: resolver result: lb_policy_name=\"%s\"%s, " "service_config=\"%s\"", chand, lb_policy_name_dup, @@ -466,7 +466,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { chand->resolver == nullptr) { if (chand->lb_policy != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand, + gpr_log(GPR_INFO, "chand=%p: unreffing lb_policy=%p", chand, chand->lb_policy.get()); } grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties(), @@ -480,11 +480,11 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { // error or shutdown. if (error != GRPC_ERROR_NONE || chand->resolver == nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: shutting down", chand); + gpr_log(GPR_INFO, "chand=%p: shutting down", chand); } if (chand->resolver != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand); + gpr_log(GPR_INFO, "chand=%p: shutting down resolver", chand); } chand->resolver.reset(); } @@ -506,7 +506,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy"); if (lb_policy_created) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand); + gpr_log(GPR_INFO, "chand=%p: initializing new LB policy", chand); } GRPC_ERROR_UNREF(state_error); state = chand->lb_policy->CheckConnectivityLocked(&state_error); @@ -999,7 +999,7 @@ static void maybe_cache_send_ops_for_batch(call_data* calld, static void free_cached_send_initial_metadata(channel_data* chand, call_data* calld) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: destroying calld->send_initial_metadata", chand, calld); } @@ -1010,7 +1010,7 @@ static void free_cached_send_initial_metadata(channel_data* chand, static void free_cached_send_message(channel_data* chand, call_data* calld, size_t idx) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: destroying calld->send_messages[%" PRIuPTR "]", chand, calld, idx); } @@ -1021,7 +1021,7 @@ static void free_cached_send_message(channel_data* chand, call_data* calld, static void free_cached_send_trailing_metadata(channel_data* chand, call_data* calld) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: destroying calld->send_trailing_metadata", chand, calld); } @@ -1088,7 +1088,7 @@ static void pending_batches_add(grpc_call_element* elem, call_data* calld = static_cast(elem->call_data); const size_t idx = get_batch_index(batch); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: adding pending batch at index %" PRIuPTR, chand, calld, idx); } @@ -1116,7 +1116,7 @@ static void pending_batches_add(grpc_call_element* elem, } if (calld->bytes_buffered_for_retry > chand->per_rpc_retry_buffer_size) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: exceeded retry buffer size, committing", chand, calld); } @@ -1131,7 +1131,7 @@ static void pending_batches_add(grpc_call_element* elem, // retries are disabled so that we don't bother with retry overhead. if (calld->num_attempts_completed == 0) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: disabling retries before first attempt", chand, calld); } @@ -1178,7 +1178,7 @@ static void pending_batches_fail(grpc_call_element* elem, grpc_error* error, for (size_t i = 0; i < GPR_ARRAY_SIZE(calld->pending_batches); ++i) { if (calld->pending_batches[i].batch != nullptr) ++num_batches; } - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s", elem->channel_data, calld, num_batches, grpc_error_string(error)); } @@ -1240,7 +1240,7 @@ static void pending_batches_resume(grpc_call_element* elem) { for (size_t i = 0; i < GPR_ARRAY_SIZE(calld->pending_batches); ++i) { if (calld->pending_batches[i].batch != nullptr) ++num_batches; } - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: starting %" PRIuPTR " pending batches on subchannel_call=%p", chand, calld, num_batches, calld->subchannel_call); @@ -1285,7 +1285,7 @@ static void maybe_clear_pending_batch(grpc_call_element* elem, (!batch->recv_message || batch->payload->recv_message.recv_message_ready == nullptr)) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: clearing pending batch", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: clearing pending batch", chand, calld); } pending_batch_clear(calld, pending); @@ -1375,7 +1375,7 @@ static void retry_commit(grpc_call_element* elem, if (calld->retry_committed) return; calld->retry_committed = true; if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: committing retries", chand, calld); + gpr_log(GPR_INFO, "chand=%p calld=%p: committing retries", chand, calld); } if (retry_state != nullptr) { free_cached_send_op_data_after_commit(elem, retry_state); @@ -1420,7 +1420,7 @@ static void do_retry(grpc_call_element* elem, next_attempt_time = calld->retry_backoff->NextAttemptTime(); } if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: retrying failed call in %" PRIuPTR " ms", chand, calld, next_attempt_time - grpc_core::ExecCtx::Get()->Now()); } @@ -1454,7 +1454,7 @@ static bool maybe_retry(grpc_call_element* elem, batch_data->subchannel_call)); if (retry_state->retry_dispatched) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: retry already dispatched", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: retry already dispatched", chand, calld); } return true; @@ -1466,14 +1466,14 @@ static bool maybe_retry(grpc_call_element* elem, calld->retry_throttle_data->RecordSuccess(); } if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: call succeeded", chand, calld); + gpr_log(GPR_INFO, "chand=%p calld=%p: call succeeded", chand, calld); } return false; } // Status is not OK. Check whether the status is retryable. if (!retry_policy->retryable_status_codes.Contains(status)) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: status %s not configured as retryable", chand, calld, grpc_status_code_to_string(status)); } @@ -1489,14 +1489,14 @@ static bool maybe_retry(grpc_call_element* elem, if (calld->retry_throttle_data != nullptr && !calld->retry_throttle_data->RecordFailure()) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: retries throttled", chand, calld); + gpr_log(GPR_INFO, "chand=%p calld=%p: retries throttled", chand, calld); } return false; } // Check whether the call is committed. if (calld->retry_committed) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: retries already committed", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: retries already committed", chand, calld); } return false; @@ -1505,7 +1505,7 @@ static bool maybe_retry(grpc_call_element* elem, ++calld->num_attempts_completed; if (calld->num_attempts_completed >= retry_policy->max_attempts) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: exceeded %d retry attempts", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: exceeded %d retry attempts", chand, calld, retry_policy->max_attempts); } return false; @@ -1513,7 +1513,7 @@ static bool maybe_retry(grpc_call_element* elem, // If the call was cancelled from the surface, don't retry. if (calld->cancel_error != GRPC_ERROR_NONE) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: call cancelled from surface, not retrying", chand, calld); } @@ -1526,16 +1526,15 @@ static bool maybe_retry(grpc_call_element* elem, uint32_t ms; if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(*server_pushback_md), &ms)) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: not retrying due to server push-back", chand, calld); } return false; } else { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, - "chand=%p calld=%p: server push-back: retry in %u ms", chand, - calld, ms); + gpr_log(GPR_INFO, "chand=%p calld=%p: server push-back: retry in %u ms", + chand, calld, ms); } server_pushback_ms = (grpc_millis)ms; } @@ -1608,7 +1607,7 @@ static void invoke_recv_initial_metadata_callback(void* arg, batch->payload->recv_initial_metadata.recv_initial_metadata_ready != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: invoking recv_initial_metadata_ready for " "pending batch at index %" PRIuPTR, chand, calld, i); @@ -1644,7 +1643,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_initial_metadata_ready, error=%s", chand, calld, grpc_error_string(error)); } @@ -1659,7 +1658,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { if ((batch_data->trailing_metadata_available || error != GRPC_ERROR_NONE) && !retry_state->completed_recv_trailing_metadata) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: deferring recv_initial_metadata_ready " "(Trailers-Only)", chand, calld); @@ -1701,7 +1700,7 @@ static void invoke_recv_message_callback(void* arg, grpc_error* error) { if (batch != nullptr && batch->recv_message && batch->payload->recv_message.recv_message_ready != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: invoking recv_message_ready for " "pending batch at index %" PRIuPTR, chand, calld, i); @@ -1734,7 +1733,7 @@ static void recv_message_ready(void* arg, grpc_error* error) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: got recv_message_ready, error=%s", + gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_message_ready, error=%s", chand, calld, grpc_error_string(error)); } subchannel_call_retry_state* retry_state = @@ -1748,7 +1747,7 @@ static void recv_message_ready(void* arg, grpc_error* error) { if ((batch_data->recv_message == nullptr || error != GRPC_ERROR_NONE) && !retry_state->completed_recv_trailing_metadata) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: deferring recv_message_ready (nullptr " "message and recv_trailing_metadata pending)", chand, calld); @@ -1796,7 +1795,7 @@ static void execute_closures_in_call_combiner(grpc_call_element* elem, // have to re-enter the call combiner. if (num_closures > 0) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: %s starting closure: %s", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: %s starting closure: %s", chand, calld, caller, closures[0].reason); } GRPC_CLOSURE_SCHED(closures[0].closure, closures[0].error); @@ -1805,7 +1804,7 @@ static void execute_closures_in_call_combiner(grpc_call_element* elem, } for (size_t i = 1; i < num_closures; ++i) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: %s starting closure in call combiner: %s", chand, calld, caller, closures[i].reason); } @@ -1817,7 +1816,7 @@ static void execute_closures_in_call_combiner(grpc_call_element* elem, } } else { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: no closures to run for %s", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: no closures to run for %s", chand, calld, caller); } GRPC_CALL_COMBINER_STOP(calld->call_combiner, "no closures to run"); @@ -1912,7 +1911,7 @@ static void add_closures_for_replay_or_pending_send_ops( } if (have_pending_send_message_ops || have_pending_send_trailing_metadata_op) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: starting next batch for pending send op(s)", chand, calld); } @@ -1937,7 +1936,7 @@ static void add_closures_for_completed_pending_batches( pending_batch* pending = &calld->pending_batches[i]; if (pending_batch_is_completed(pending, calld, retry_state)) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: pending batch completed at index %" PRIuPTR, chand, calld, i); } @@ -1970,7 +1969,7 @@ static void add_closures_to_fail_unstarted_pending_batches( pending_batch* pending = &calld->pending_batches[i]; if (pending_batch_is_unstarted(pending, calld, retry_state)) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: failing unstarted pending batch at index " "%" PRIuPTR, chand, calld, i); @@ -2014,7 +2013,7 @@ static void on_complete(void* arg, grpc_error* error) { call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { char* batch_str = grpc_transport_stream_op_batch_string(&batch_data->batch); - gpr_log(GPR_DEBUG, "chand=%p calld=%p: got on_complete, error=%s, batch=%s", + gpr_log(GPR_INFO, "chand=%p calld=%p: got on_complete, error=%s, batch=%s", chand, calld, grpc_error_string(error), batch_str); gpr_free(batch_str); } @@ -2031,7 +2030,7 @@ static void on_complete(void* arg, grpc_error* error) { update_retry_state_for_completed_batch(batch_data, retry_state); if (call_finished) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: call already finished", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: call already finished", chand, calld); } } else { @@ -2059,7 +2058,7 @@ static void on_complete(void* arg, grpc_error* error) { // If the call just finished, check if we should retry. if (call_finished) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: call finished, status=%s", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: call finished, status=%s", chand, calld, grpc_status_code_to_string(status)); } if (maybe_retry(elem, batch_data, status, server_pushback_md)) { @@ -2224,7 +2223,7 @@ static void add_retriable_send_message_op( channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: starting calld->send_messages[%" PRIuPTR "]", chand, calld, retry_state->started_send_message_count); } @@ -2311,7 +2310,7 @@ static void start_internal_recv_trailing_metadata(grpc_call_element* elem) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: call failed but recv_trailing_metadata not " "started; starting it internally", chand, calld); @@ -2343,7 +2342,7 @@ static subchannel_batch_data* maybe_create_subchannel_batch_for_replay( !retry_state->started_send_initial_metadata && !calld->pending_send_initial_metadata) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: replaying previously completed " "send_initial_metadata op", chand, calld); @@ -2359,7 +2358,7 @@ static subchannel_batch_data* maybe_create_subchannel_batch_for_replay( retry_state->completed_send_message_count && !calld->pending_send_message) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: replaying previously completed " "send_message op", chand, calld); @@ -2378,7 +2377,7 @@ static subchannel_batch_data* maybe_create_subchannel_batch_for_replay( !retry_state->started_send_trailing_metadata && !calld->pending_send_trailing_metadata) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: replaying previously completed " "send_trailing_metadata op", chand, calld); @@ -2518,7 +2517,7 @@ static void start_retriable_subchannel_batches(void* arg, grpc_error* ignored) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: constructing retriable batches", + gpr_log(GPR_INFO, "chand=%p calld=%p: constructing retriable batches", chand, calld); } subchannel_call_retry_state* retry_state = @@ -2541,7 +2540,7 @@ static void start_retriable_subchannel_batches(void* arg, grpc_error* ignored) { &num_closures); // Start batches on subchannel call. if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: starting %" PRIuPTR " retriable batches on subchannel_call=%p", chand, calld, num_closures, calld->subchannel_call); @@ -2572,7 +2571,7 @@ static void create_subchannel_call(grpc_call_element* elem, grpc_error* error) { grpc_error* new_error = calld->pick.connected_subchannel->CreateCall( call_args, &calld->subchannel_call); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s", + gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s", chand, calld, calld->subchannel_call, grpc_error_string(new_error)); } if (new_error != GRPC_ERROR_NONE) { @@ -2613,7 +2612,7 @@ static void pick_done(void* arg, grpc_error* error) { : GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Failed to create subchannel", &error, 1); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: failed to create subchannel: error=%s", chand, calld, grpc_error_string(new_error)); } @@ -2657,7 +2656,7 @@ static void pick_callback_cancel_locked(void* arg, grpc_error* error) { // the one we started it on. However, this will just be a no-op. if (error != GRPC_ERROR_NONE && chand->lb_policy != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p", + gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling pick from LB policy %p", chand, calld, chand->lb_policy.get()); } chand->lb_policy->CancelPickLocked(&calld->pick, GRPC_ERROR_REF(error)); @@ -2672,8 +2671,8 @@ static void pick_callback_done_locked(void* arg, grpc_error* error) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously", - chand, calld); + gpr_log(GPR_INFO, "chand=%p calld=%p: pick completed asynchronously", chand, + calld); } async_pick_done_locked(elem, GRPC_ERROR_REF(error)); GRPC_CALL_STACK_UNREF(calld->owning_call, "pick_callback"); @@ -2685,7 +2684,7 @@ static void apply_service_config_to_call_locked(grpc_call_element* elem) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call", + gpr_log(GPR_INFO, "chand=%p calld=%p: applying service config to call", chand, calld); } if (chand->retry_throttle_data != nullptr) { @@ -2723,8 +2722,8 @@ static bool pick_callback_start_locked(grpc_call_element* elem) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p", - chand, calld, chand->lb_policy.get()); + gpr_log(GPR_INFO, "chand=%p calld=%p: starting pick on lb_policy=%p", chand, + calld, chand->lb_policy.get()); } // Only get service config data on the first attempt. if (calld->num_attempts_completed == 0) { @@ -2771,7 +2770,7 @@ static bool pick_callback_start_locked(grpc_call_element* elem) { if (pick_done) { // Pick completed synchronously. if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously", + gpr_log(GPR_INFO, "chand=%p calld=%p: pick completed synchronously", chand, calld); } GRPC_CALL_STACK_UNREF(calld->owning_call, "pick_callback"); @@ -2815,7 +2814,7 @@ static void pick_after_resolver_result_cancel_locked(void* arg, channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling pick waiting for resolver result", chand, calld); } @@ -2835,7 +2834,7 @@ static void pick_after_resolver_result_done_locked(void* arg, if (args->finished) { /* cancelled, do nothing */ if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "call cancelled before resolver result"); + gpr_log(GPR_INFO, "call cancelled before resolver result"); } gpr_free(args); return; @@ -2846,14 +2845,14 @@ static void pick_after_resolver_result_done_locked(void* arg, call_data* calld = static_cast(elem->call_data); if (error != GRPC_ERROR_NONE) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data", + gpr_log(GPR_INFO, "chand=%p calld=%p: resolver failed to return data", chand, calld); } async_pick_done_locked(elem, GRPC_ERROR_REF(error)); } else if (chand->resolver == nullptr) { // Shutting down. if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: resolver disconnected", chand, calld); } async_pick_done_locked( @@ -2869,7 +2868,7 @@ static void pick_after_resolver_result_done_locked(void* arg, .send_initial_metadata_flags; if (send_initial_metadata_flags & GRPC_INITIAL_METADATA_WAIT_FOR_READY) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: resolver returned but no LB policy; " "wait_for_ready=true; trying again", chand, calld); @@ -2877,7 +2876,7 @@ static void pick_after_resolver_result_done_locked(void* arg, pick_after_resolver_result_start_locked(elem); } else { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: resolver returned but no LB policy; " "wait_for_ready=false; failing", chand, calld); @@ -2890,7 +2889,7 @@ static void pick_after_resolver_result_done_locked(void* arg, } } else { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick", + gpr_log(GPR_INFO, "chand=%p calld=%p: resolver returned, doing pick", chand, calld); } if (pick_callback_start_locked(elem)) { @@ -2908,7 +2907,7 @@ static void pick_after_resolver_result_start_locked(grpc_call_element* elem) { channel_data* chand = static_cast(elem->channel_data); call_data* calld = static_cast(elem->call_data); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: deferring pick pending resolver result", chand, calld); } @@ -2975,7 +2974,7 @@ static void cc_start_transport_stream_op_batch( // If we've previously been cancelled, immediately fail any new batches. if (calld->cancel_error != GRPC_ERROR_NONE) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: failing batch with error: %s", + gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s", chand, calld, grpc_error_string(calld->cancel_error)); } // Note: This will release the call combiner. @@ -2994,7 +2993,7 @@ static void cc_start_transport_stream_op_batch( calld->cancel_error = GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error); if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: recording cancel_error=%s", chand, + gpr_log(GPR_INFO, "chand=%p calld=%p: recording cancel_error=%s", chand, calld, grpc_error_string(calld->cancel_error)); } // If we do not have a subchannel call (i.e., a pick has not yet @@ -3020,7 +3019,7 @@ static void cc_start_transport_stream_op_batch( // streaming calls). if (calld->subchannel_call != nullptr) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: starting batch on subchannel_call=%p", chand, calld, calld->subchannel_call); } @@ -3032,7 +3031,7 @@ static void cc_start_transport_stream_op_batch( // combiner to start a pick. if (batch->send_initial_metadata) { if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, "chand=%p calld=%p: entering client_channel combiner", + gpr_log(GPR_INFO, "chand=%p calld=%p: entering client_channel combiner", chand, calld); } GRPC_CLOSURE_SCHED( @@ -3042,7 +3041,7 @@ static void cc_start_transport_stream_op_batch( } else { // For all other batches, release the call combiner. if (grpc_client_channel_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "chand=%p calld=%p: saved batch, yeilding call combiner", chand, calld); } diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index fa63dd75b5..e065f45639 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -44,13 +44,13 @@ void LoadBalancingPolicy::TryReresolutionLocked( GRPC_CLOSURE_SCHED(request_reresolution_, error); request_reresolution_ = nullptr; if (grpc_lb_trace->enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "%s %p: scheduling re-resolution closure with error=%s.", grpc_lb_trace->name(), this, grpc_error_string(error)); } } else { if (grpc_lb_trace->enabled()) { - gpr_log(GPR_DEBUG, "%s %p: no available re-resolution closure.", + gpr_log(GPR_INFO, "%s %p: no available re-resolution closure.", grpc_lb_trace->name(), this); } } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 097ff112f9..1a675476f0 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1247,7 +1247,7 @@ bool GrpcLb::PickLocked(PickState* pick) { } } else { // rr_policy_ == NULL if (grpc_lb_glb_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[grpclb %p] No RR policy. Adding to grpclb's pending picks", this); } @@ -1413,14 +1413,13 @@ void GrpcLb::OnFallbackTimerLocked(void* arg, grpc_error* error) { void GrpcLb::StartBalancerCallRetryTimerLocked() { grpc_millis next_try = lb_call_backoff_.NextAttemptTime(); if (grpc_lb_glb_trace.enabled()) { - gpr_log(GPR_DEBUG, "[grpclb %p] Connection to LB server lost...", this); + gpr_log(GPR_INFO, "[grpclb %p] Connection to LB server lost...", this); grpc_millis timeout = next_try - ExecCtx::Get()->Now(); if (timeout > 0) { - gpr_log(GPR_DEBUG, - "[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.", this, - timeout); + gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.", + this, timeout); } else { - gpr_log(GPR_DEBUG, "[grpclb %p] ... retry_timer_active immediately.", + gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active immediately.", this); } } @@ -1728,7 +1727,7 @@ void GrpcLb::CreateOrUpdateRoundRobinPolicyLocked() { GPR_ASSERT(args != nullptr); if (rr_policy_ != nullptr) { if (grpc_lb_glb_trace.enabled()) { - gpr_log(GPR_DEBUG, "[grpclb %p] Updating RR policy %p", this, + gpr_log(GPR_INFO, "[grpclb %p] Updating RR policy %p", this, rr_policy_.get()); } rr_policy_->UpdateLocked(*args); @@ -1739,7 +1738,7 @@ void GrpcLb::CreateOrUpdateRoundRobinPolicyLocked() { lb_policy_args.args = args; CreateRoundRobinPolicyLocked(lb_policy_args); if (grpc_lb_glb_trace.enabled()) { - gpr_log(GPR_DEBUG, "[grpclb %p] Created new RR policy %p", this, + gpr_log(GPR_INFO, "[grpclb %p] Created new RR policy %p", this, rr_policy_.get()); } } @@ -1755,7 +1754,7 @@ void GrpcLb::OnRoundRobinRequestReresolutionLocked(void* arg, } if (grpc_lb_glb_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "[grpclb %p] Re-resolution requested from the internal RR policy (%p).", grpclb_policy, grpclb_policy->rr_policy_.get()); } diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 9090c34412..a07e90322c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -95,7 +95,7 @@ PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) { grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE, "pick_first"); if (grpc_lb_pick_first_trace.enabled()) { - gpr_log(GPR_DEBUG, "Pick First %p created.", this); + gpr_log(GPR_INFO, "Pick First %p created.", this); } UpdateLocked(*args.args); grpc_subchannel_index_ref(); @@ -103,7 +103,7 @@ PickFirst::PickFirst(const Args& args) : LoadBalancingPolicy(args) { PickFirst::~PickFirst() { if (grpc_lb_pick_first_trace.enabled()) { - gpr_log(GPR_DEBUG, "Destroying Pick First %p", this); + gpr_log(GPR_INFO, "Destroying Pick First %p", this); } GPR_ASSERT(subchannel_list_ == nullptr); GPR_ASSERT(latest_pending_subchannel_list_ == nullptr); @@ -126,7 +126,7 @@ void PickFirst::HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) { void PickFirst::ShutdownLocked() { grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown"); if (grpc_lb_pick_first_trace.enabled()) { - gpr_log(GPR_DEBUG, "Pick First %p Shutting down", this); + gpr_log(GPR_INFO, "Pick First %p Shutting down", this); } shutdown_ = true; PickState* pick; @@ -372,7 +372,7 @@ void PickFirst::UpdateLocked(const grpc_channel_args& args) { // subchannel list. if (latest_pending_subchannel_list_ != nullptr) { if (grpc_lb_pick_first_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Pick First %p Shutting down latest pending subchannel list " "%p, about to be replaced by newer latest %p", this, latest_pending_subchannel_list_, subchannel_list); @@ -396,7 +396,7 @@ void PickFirst::OnConnectivityChangedLocked(void* arg, grpc_error* error) { grpc_lb_subchannel_data* sd = static_cast(arg); PickFirst* p = static_cast(sd->subchannel_list->policy); if (grpc_lb_pick_first_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Pick First %p connectivity changed for subchannel %p (%" PRIuPTR " of %" PRIuPTR "), subchannel_list %p: state=%s p->shutdown_=%d " diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index e534131c02..b470016bd9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -114,7 +114,7 @@ RoundRobin::RoundRobin(const Args& args) : LoadBalancingPolicy(args) { "round_robin"); UpdateLocked(*args.args); if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] Created with %" PRIuPTR " subchannels", this, + gpr_log(GPR_INFO, "[RR %p] Created with %" PRIuPTR " subchannels", this, subchannel_list_->num_subchannels); } grpc_subchannel_index_ref(); @@ -122,7 +122,7 @@ RoundRobin::RoundRobin(const Args& args) : LoadBalancingPolicy(args) { RoundRobin::~RoundRobin() { if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy", this); + gpr_log(GPR_INFO, "[RR %p] Destroying Round Robin policy", this); } GPR_ASSERT(subchannel_list_ == nullptr); GPR_ASSERT(latest_pending_subchannel_list_ == nullptr); @@ -152,7 +152,7 @@ size_t RoundRobin::GetNextReadySubchannelIndexLocked() { subchannel_list_->num_subchannels; if (grpc_lb_round_robin_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "[RR %p] checking subchannel %p, subchannel_list %p, index %" PRIuPTR ": state=%s", this, subchannel_list_->subchannels[index].subchannel, @@ -163,7 +163,7 @@ size_t RoundRobin::GetNextReadySubchannelIndexLocked() { if (subchannel_list_->subchannels[index].curr_connectivity_state == GRPC_CHANNEL_READY) { if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] found next ready subchannel (%p) at index %" PRIuPTR " of subchannel_list %p", this, subchannel_list_->subchannels[index].subchannel, index, @@ -173,7 +173,7 @@ size_t RoundRobin::GetNextReadySubchannelIndexLocked() { } } if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] no subchannels in ready state", this); + gpr_log(GPR_INFO, "[RR %p] no subchannels in ready state", this); } return subchannel_list_->num_subchannels; } @@ -183,7 +183,7 @@ void RoundRobin::UpdateLastReadySubchannelIndexLocked(size_t last_ready_index) { GPR_ASSERT(last_ready_index < subchannel_list_->num_subchannels); last_ready_subchannel_index_ = last_ready_index; if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] setting last_ready_subchannel_index=%" PRIuPTR " (SC %p, CSC %p)", this, last_ready_index, @@ -207,7 +207,7 @@ void RoundRobin::HandOffPendingPicksLocked(LoadBalancingPolicy* new_policy) { void RoundRobin::ShutdownLocked() { grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown"); if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] Shutting down", this); + gpr_log(GPR_INFO, "[RR %p] Shutting down", this); } shutdown_ = true; PickState* pick; @@ -311,8 +311,7 @@ void RoundRobin::ExitIdleLocked() { bool RoundRobin::PickLocked(PickState* pick) { if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] Trying to pick (shutdown: %d)", this, - shutdown_); + gpr_log(GPR_INFO, "[RR %p] Trying to pick (shutdown: %d)", this, shutdown_); } GPR_ASSERT(!shutdown_); if (subchannel_list_ != nullptr) { @@ -327,7 +326,7 @@ bool RoundRobin::PickLocked(PickState* pick) { } if (grpc_lb_round_robin_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, " "index %" PRIuPTR ")", this, sd->subchannel, pick->connected_subchannel.get(), @@ -416,7 +415,7 @@ void RoundRobin::OnConnectivityChangedLocked(void* arg, grpc_error* error) { RoundRobin* p = static_cast(sd->subchannel_list->policy); if (grpc_lb_round_robin_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "[RR %p] connectivity changed for subchannel %p, subchannel_list %p: " "prev_state=%s new_state=%s p->shutdown=%d " "sd->subchannel_list->shutting_down=%d error=%s", @@ -458,7 +457,7 @@ void RoundRobin::OnConnectivityChangedLocked(void* arg, grpc_error* error) { case GRPC_CHANNEL_TRANSIENT_FAILURE: { sd->connected_subchannel.reset(); if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] Subchannel %p has gone into TRANSIENT_FAILURE. " "Requesting re-resolution", p, sd->subchannel); @@ -483,7 +482,7 @@ void RoundRobin::OnConnectivityChangedLocked(void* arg, grpc_error* error) { p->subchannel_list_ != nullptr ? p->subchannel_list_->num_subchannels : 0; - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] phasing out subchannel list %p (size %" PRIuPTR ") in favor of %p (size %" PRIuPTR ")", p, p->subchannel_list_, num_subchannels, sd->subchannel_list, @@ -517,7 +516,7 @@ void RoundRobin::OnConnectivityChangedLocked(void* arg, grpc_error* error) { *pick->user_data = selected->user_data; } if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] Fulfilling pending pick. Target <-- subchannel %p " "(subchannel_list %p, index %" PRIuPTR ")", p, selected->subchannel, p->subchannel_list_, @@ -584,7 +583,7 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args) { } grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p; if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, "[RR %p] received update with %" PRIuPTR " addresses", + gpr_log(GPR_INFO, "[RR %p] received update with %" PRIuPTR " addresses", this, addresses->num_addresses); } grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create( @@ -629,7 +628,7 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args) { } if (latest_pending_subchannel_list_ != nullptr) { if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[RR %p] Shutting down latest pending subchannel list %p, " "about to be replaced by newer latest %p", this, latest_pending_subchannel_list_, subchannel_list); diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc index 79cb64c6c6..257db57575 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc @@ -34,7 +34,7 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd, const char* reason) { if (sd->subchannel != nullptr) { if (sd->subchannel_list->tracer->enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): unreffing subchannel", sd->subchannel_list->tracer->name(), sd->subchannel_list->policy, @@ -57,7 +57,7 @@ void grpc_lb_subchannel_data_start_connectivity_watch( grpc_lb_subchannel_data* sd) { if (sd->subchannel_list->tracer->enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): requesting connectivity change " "notification (from %s)", @@ -77,7 +77,7 @@ void grpc_lb_subchannel_data_start_connectivity_watch( void grpc_lb_subchannel_data_stop_connectivity_watch( grpc_lb_subchannel_data* sd) { if (sd->subchannel_list->tracer->enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): stopping connectivity watch", sd->subchannel_list->tracer->name(), sd->subchannel_list->policy, @@ -98,7 +98,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( static_cast( gpr_zalloc(sizeof(*subchannel_list))); if (tracer->enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels", tracer->name(), p, subchannel_list, addresses->num_addresses); } @@ -132,7 +132,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( if (tracer->enabled()) { char* address_uri = grpc_sockaddr_to_uri(&addresses->addresses[i].address); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] could not create subchannel for address uri %s, " "ignoring", tracer->name(), subchannel_list->policy, address_uri); @@ -143,7 +143,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( if (tracer->enabled()) { char* address_uri = grpc_sockaddr_to_uri(&addresses->addresses[i].address); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR ": Created subchannel %p for address uri %s", tracer->name(), p, subchannel_list, subchannel_index, subchannel, @@ -175,7 +175,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( static void subchannel_list_destroy(grpc_lb_subchannel_list* subchannel_list) { if (subchannel_list->tracer->enabled()) { - gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p", + gpr_log(GPR_INFO, "[%s %p] Destroying subchannel_list %p", subchannel_list->tracer->name(), subchannel_list->policy, subchannel_list); } @@ -192,7 +192,7 @@ void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list, gpr_ref_non_zero(&subchannel_list->refcount); if (subchannel_list->tracer->enabled()) { const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count); - gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p REF %lu->%lu (%s)", + gpr_log(GPR_INFO, "[%s %p] subchannel_list %p REF %lu->%lu (%s)", subchannel_list->tracer->name(), subchannel_list->policy, subchannel_list, static_cast(count - 1), static_cast(count), reason); @@ -204,7 +204,7 @@ void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list, const bool done = gpr_unref(&subchannel_list->refcount); if (subchannel_list->tracer->enabled()) { const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count); - gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p UNREF %lu->%lu (%s)", + gpr_log(GPR_INFO, "[%s %p] subchannel_list %p UNREF %lu->%lu (%s)", subchannel_list->tracer->name(), subchannel_list->policy, subchannel_list, static_cast(count + 1), static_cast(count), reason); @@ -217,7 +217,7 @@ void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list, static void subchannel_data_cancel_connectivity_watch( grpc_lb_subchannel_data* sd, const char* reason) { if (sd->subchannel_list->tracer->enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): canceling connectivity watch (%s)", sd->subchannel_list->tracer->name(), sd->subchannel_list->policy, @@ -232,7 +232,7 @@ static void subchannel_data_cancel_connectivity_watch( void grpc_lb_subchannel_list_shutdown_and_unref( grpc_lb_subchannel_list* subchannel_list, const char* reason) { if (subchannel_list->tracer->enabled()) { - gpr_log(GPR_DEBUG, "[%s %p] Shutting down subchannel_list %p (%s)", + gpr_log(GPR_INFO, "[%s %p] Shutting down subchannel_list %p (%s)", subchannel_list->tracer->name(), subchannel_list->policy, subchannel_list, reason); } diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index e7d9949386..f8f478b6c0 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -234,7 +234,7 @@ static void finish_send_message(grpc_call_element* elem) { static_cast(before_size); GPR_ASSERT(grpc_message_compression_algorithm_name( calld->message_compression_algorithm, &algo_name)); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR " bytes (%.2f%% savings)", algo_name, before_size, after_size, 100 * savings_ratio); @@ -246,7 +246,7 @@ static void finish_send_message(grpc_call_element* elem) { const char* algo_name; GPR_ASSERT(grpc_message_compression_algorithm_name( calld->message_compression_algorithm, &algo_name)); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Algorithm '%s' enabled but decided not to compress. Input size: " "%" PRIuPTR, algo_name, calld->slices.length); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 6980b8671e..0ef73961a5 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -807,7 +807,7 @@ static const char* write_state_name(grpc_chttp2_write_state st) { static void set_write_state(grpc_chttp2_transport* t, grpc_chttp2_write_state st, const char* reason) { - GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "W:%p %s state %s -> %s [%s]", t, + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "W:%p %s state %s -> %s [%s]", t, t->is_client ? "CLIENT" : "SERVER", write_state_name(t->write_state), write_state_name(st), reason)); @@ -1072,7 +1072,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, uint32_t goaway_error, grpc_slice goaway_text) { // GRPC_CHTTP2_IF_TRACING( - // gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg)); + // gpr_log(GPR_INFO, "got goaway [%d]: %s", goaway_error, msg)); // Discard the error from a previous goaway frame (if any) if (t->goaway_error != GRPC_ERROR_NONE) { @@ -1118,7 +1118,7 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) { grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) { /* safe since we can't (legally) be parsing this stream yet */ GRPC_CHTTP2_IF_TRACING(gpr_log( - GPR_DEBUG, "HTTP:%s: Allocating new grpc_chttp2_stream %p to id %d", + GPR_INFO, "HTTP:%s: Allocating new grpc_chttp2_stream %p to id %d", t->is_client ? "CLI" : "SVR", s, t->next_stream_id)); GPR_ASSERT(s->id == 0); @@ -1183,7 +1183,7 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, if (grpc_http_trace.enabled()) { const char* errstr = grpc_error_string(error); gpr_log( - GPR_DEBUG, + GPR_INFO, "complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s " "write_state=%s", t, closure, @@ -1336,7 +1336,7 @@ static void perform_stream_op_locked(void* stream_op, if (grpc_http_trace.enabled()) { char* str = grpc_transport_stream_op_batch_string(op); - gpr_log(GPR_DEBUG, "perform_stream_op_locked: %s; on_complete = %p", str, + gpr_log(GPR_INFO, "perform_stream_op_locked: %s; on_complete = %p", str, op->on_complete); gpr_free(str); if (op->send_initial_metadata) { @@ -1638,7 +1638,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, if (grpc_http_trace.enabled()) { char* str = grpc_transport_stream_op_batch_string(op); - gpr_log(GPR_DEBUG, "perform_stream_op[s=%p]: %s", s, str); + gpr_log(GPR_INFO, "perform_stream_op[s=%p]: %s", s, str); gpr_free(str); } @@ -2529,7 +2529,7 @@ static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) { static void start_bdp_ping_locked(void* tp, grpc_error* error) { grpc_chttp2_transport* t = static_cast(tp); if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string, + gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string, grpc_error_string(error)); } /* Reset the keepalive ping timer */ @@ -2542,7 +2542,7 @@ static void start_bdp_ping_locked(void* tp, grpc_error* error) { static void finish_bdp_ping_locked(void* tp, grpc_error* error) { grpc_chttp2_transport* t = static_cast(tp); if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string, + gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string, grpc_error_string(error)); } if (error != GRPC_ERROR_NONE) { @@ -2716,8 +2716,7 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) { static void connectivity_state_set(grpc_chttp2_transport* t, grpc_connectivity_state state, grpc_error* error, const char* reason) { - GRPC_CHTTP2_IF_TRACING( - gpr_log(GPR_DEBUG, "set connectivity_state=%d", state)); + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "set connectivity_state=%d", state)); grpc_connectivity_state_set(&t->channel_callback.state_tracker, state, error, reason); } @@ -2984,7 +2983,7 @@ static void benign_reclaimer_locked(void* arg, grpc_error* error) { /* Channel with no active streams: send a goaway to try and make it * disconnect cleanly */ if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "HTTP2: %s - send goaway to free memory", + gpr_log(GPR_INFO, "HTTP2: %s - send goaway to free memory", t->peer_string); } send_goaway(t, @@ -2992,7 +2991,7 @@ static void benign_reclaimer_locked(void* arg, grpc_error* error) { GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR " streams", t->peer_string, grpc_chttp2_stream_map_size(&t->stream_map)); @@ -3013,7 +3012,7 @@ static void destructive_reclaimer_locked(void* arg, grpc_error* error) { grpc_chttp2_stream* s = static_cast( grpc_chttp2_stream_map_rand(&t->stream_map)); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string, + gpr_log(GPR_INFO, "HTTP2: %s - abandon stream id %d", t->peer_string, s->id); } grpc_chttp2_cancel_stream( diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index 9ea27dcd47..987ac0e79d 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -217,14 +217,14 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t, t->initial_window_update += static_cast(parser->value) - parser->incoming_settings[id]; if (grpc_http_trace.enabled() || grpc_flowctl_trace.enabled()) { - gpr_log(GPR_DEBUG, "%p[%s] adding %d for initial_window change", - t, t->is_client ? "cli" : "svr", + gpr_log(GPR_INFO, "%p[%s] adding %d for initial_window change", t, + t->is_client ? "cli" : "svr", static_cast(t->initial_window_update)); } } parser->incoming_settings[id] = parser->value; if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %s = %d", + gpr_log(GPR_INFO, "CHTTP2:%s:%s: got setting %s = %d", t->is_client ? "CLI" : "SVR", t->peer_string, sp->name, parser->value); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index e4f3c1b81e..d5ef063883 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -470,7 +470,7 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem, v = grpc_slice_to_c_string(GRPC_MDVALUE(elem)); } gpr_log( - GPR_DEBUG, + GPR_INFO, "Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem), grpc_slice_is_interned(GRPC_MDKEY(elem)), @@ -654,7 +654,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( } c->advertise_table_size_change = 1; if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size); + gpr_log(GPR_INFO, "set max table size from encoder to %d", max_table_size); } } diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index fc96a8b3e4..907ba71178 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -633,7 +633,7 @@ static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md, v = grpc_slice_to_c_string(GRPC_MDVALUE(md)); } gpr_log( - GPR_DEBUG, + GPR_INFO, "Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d", k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md), grpc_slice_is_interned(GRPC_MDKEY(md)), diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index f050f502f5..7929258356 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -247,7 +247,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl, return; } if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes); + gpr_log(GPR_INFO, "Update hpack parser max size to %d", max_bytes); } while (tbl->mem_used > max_bytes) { evict1(tbl); @@ -270,7 +270,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, return err; } if (grpc_http_trace.enabled()) { - gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes); + gpr_log(GPR_INFO, "Update hpack parser table size to %d", bytes); } while (tbl->mem_used > bytes) { evict1(tbl); diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc index 5d3ec4b53b..6626170a7e 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -68,7 +68,7 @@ static bool stream_list_pop(grpc_chttp2_transport* t, } *stream = s; if (s && grpc_trace_http2_stream_state.enabled()) { - gpr_log(GPR_DEBUG, "%p[%d][%s]: pop from %s", t, s->id, + gpr_log(GPR_INFO, "%p[%d][%s]: pop from %s", t, s->id, t->is_client ? "cli" : "svr", stream_list_id_string(id)); } return s != nullptr; @@ -90,7 +90,7 @@ static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s, t->lists[id].tail = s->links[id].prev; } if (grpc_trace_http2_stream_state.enabled()) { - gpr_log(GPR_DEBUG, "%p[%d][%s]: remove from %s", t, s->id, + gpr_log(GPR_INFO, "%p[%d][%s]: remove from %s", t, s->id, t->is_client ? "cli" : "svr", stream_list_id_string(id)); } } @@ -122,7 +122,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t, t->lists[id].tail = s; s->included[id] = 1; if (grpc_trace_http2_stream_state.enabled()) { - gpr_log(GPR_DEBUG, "%p[%d][%s]: add to %s", t, s->id, + gpr_log(GPR_INFO, "%p[%d][%s]: add to %s", t, s->id, t->is_client ? "cli" : "svr", stream_list_id_string(id)); } } diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 6f32397a3a..85efe27080 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -52,7 +52,7 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { /* ping already in-flight: wait */ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: already pinging", + gpr_log(GPR_INFO, "%s: Ping delayed [%p]: already pinging", t->is_client ? "CLIENT" : "SERVER", t->peer_string); } return; @@ -61,7 +61,7 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { t->ping_policy.max_pings_without_data != 0) { /* need to receive something of substance before sending a ping again */ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: too many recent pings: %d/%d", + gpr_log(GPR_INFO, "%s: Ping delayed [%p]: too many recent pings: %d/%d", t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, t->ping_policy.max_pings_without_data); @@ -81,7 +81,7 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { if (next_allowed_ping > now) { /* not enough elapsed time between successive pings */ if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "%s: Ping delayed [%p]: not enough time elapsed since last ping. " " Last ping %f: Next ping %f: Now %f", t->is_client ? "CLIENT" : "SERVER", t->peer_string, @@ -107,7 +107,7 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { GRPC_STATS_INC_HTTP2_PINGS_SENT(); t->ping_state.last_ping_sent_time = now; if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d", + gpr_log(GPR_INFO, "%s: Ping sent [%p]: %d/%d", t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, t->ping_policy.max_pings_without_data); @@ -401,7 +401,7 @@ class StreamWriteContext { StreamWriteContext(WriteContext* write_context, grpc_chttp2_stream* s) : write_context_(write_context), t_(write_context->transport()), s_(s) { GRPC_CHTTP2_IF_TRACING( - gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_, + gpr_log(GPR_INFO, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_, t_->is_client ? "CLIENT" : "SERVER", s->id, s->sent_initial_metadata, s->send_initial_metadata != nullptr, (int)(s->flow_control->local_window_delta() - diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 67a380077b..2c3bff5c1e 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -125,12 +125,12 @@ static bool cancel_stream_locked(inproc_stream* s, grpc_error* error); static void op_state_machine(void* arg, grpc_error* error); static void ref_transport(inproc_transport* t) { - INPROC_LOG(GPR_DEBUG, "ref_transport %p", t); + INPROC_LOG(GPR_INFO, "ref_transport %p", t); gpr_ref(&t->refs); } static void really_destroy_transport(inproc_transport* t) { - INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t); + INPROC_LOG(GPR_INFO, "really_destroy_transport %p", t); grpc_connectivity_state_destroy(&t->connectivity); if (gpr_unref(&t->mu->refs)) { gpr_free(t->mu); @@ -139,7 +139,7 @@ static void really_destroy_transport(inproc_transport* t) { } static void unref_transport(inproc_transport* t) { - INPROC_LOG(GPR_DEBUG, "unref_transport %p", t); + INPROC_LOG(GPR_INFO, "unref_transport %p", t); if (gpr_unref(&t->refs)) { really_destroy_transport(t); } @@ -154,17 +154,17 @@ static void unref_transport(inproc_transport* t) { #endif static void ref_stream(inproc_stream* s, const char* reason) { - INPROC_LOG(GPR_DEBUG, "ref_stream %p %s", s, reason); + INPROC_LOG(GPR_INFO, "ref_stream %p %s", s, reason); STREAM_REF(s->refs, reason); } static void unref_stream(inproc_stream* s, const char* reason) { - INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason); + INPROC_LOG(GPR_INFO, "unref_stream %p %s", s, reason); STREAM_UNREF(s->refs, reason); } static void really_destroy_stream(inproc_stream* s) { - INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s); + INPROC_LOG(GPR_INFO, "really_destroy_stream %p", s); GRPC_ERROR_UNREF(s->write_buffer_cancel_error); GRPC_ERROR_UNREF(s->cancel_self_error); @@ -225,7 +225,7 @@ static grpc_error* fill_in_metadata(inproc_stream* s, static int init_stream(grpc_transport* gt, grpc_stream* gs, grpc_stream_refcount* refcount, const void* server_data, gpr_arena* arena) { - INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data); + INPROC_LOG(GPR_INFO, "init_stream %p %p %p", gt, gs, server_data); inproc_transport* t = reinterpret_cast(gt); inproc_stream* s = reinterpret_cast(gs); s->arena = arena; @@ -282,8 +282,8 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs, // Pass the client-side stream address to the server-side for a ref ref_stream(s, "inproc_init_stream:clt"); // ref it now on behalf of server // side to avoid destruction - INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p", - st->accept_stream_cb, st->accept_stream_data); + INPROC_LOG(GPR_INFO, "calling accept stream cb %p %p", st->accept_stream_cb, + st->accept_stream_data); (*st->accept_stream_cb)(st->accept_stream_data, &st->base, (void*)s); } else { // This is the server-side and is being called through accept_stream_cb @@ -378,7 +378,7 @@ static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error, int is_rtm = static_cast(op == s->recv_trailing_md_op); if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) { - INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error); + INPROC_LOG(GPR_INFO, "%s %p %p %p", msg, s, op, error); GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_REF(error)); } } @@ -393,7 +393,7 @@ static void maybe_schedule_op_closure_locked(inproc_stream* s, } static void fail_helper_locked(inproc_stream* s, grpc_error* error) { - INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s); + INPROC_LOG(GPR_INFO, "op_state_machine %p fail_helper", s); // If we're failing this side, we need to make sure that // we also send or have already sent trailing metadata if (!s->trailing_md_sent) { @@ -458,7 +458,7 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) { *s->recv_initial_md_op->payload->recv_initial_metadata .trailing_metadata_available = true; } - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "fail_helper %p scheduling initial-metadata-ready %p %p", s, error, err); GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata @@ -472,7 +472,7 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) { s->recv_initial_md_op = nullptr; } if (s->recv_message_op) { - INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s, + INPROC_LOG(GPR_INFO, "fail_helper %p scheduling message-ready %p", s, error); GRPC_CLOSURE_SCHED( s->recv_message_op->payload->recv_message.recv_message_ready, @@ -496,9 +496,8 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) { s->send_trailing_md_op = nullptr; } if (s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "fail_helper %p scheduling trailing-md-on-complete %p", s, - error); + INPROC_LOG(GPR_INFO, "fail_helper %p scheduling trailing-md-on-complete %p", + s, error); complete_if_batch_end_locked( s, error, s->recv_trailing_md_op, "fail_helper scheduling recv-trailing-metadata-on-complete"); @@ -549,7 +548,7 @@ static void message_transfer_locked(inproc_stream* sender, receiver->recv_stream.Init(&receiver->recv_message, 0); receiver->recv_message_op->payload->recv_message.recv_message->reset( receiver->recv_stream.get()); - INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready", + INPROC_LOG(GPR_INFO, "message_transfer_locked %p scheduling message-ready", receiver); GRPC_CLOSURE_SCHED( receiver->recv_message_op->payload->recv_message.recv_message_ready, @@ -577,7 +576,7 @@ static void op_state_machine(void* arg, grpc_error* error) { bool needs_close = false; - INPROC_LOG(GPR_DEBUG, "op_state_machine %p", arg); + INPROC_LOG(GPR_INFO, "op_state_machine %p", arg); inproc_stream* s = static_cast(arg); gpr_mu* mu = &s->t->mu->mu; // keep aside in case s gets closed gpr_mu_lock(mu); @@ -626,7 +625,7 @@ static void op_state_machine(void* arg, grpc_error* error) { : &other->to_read_trailing_md_filled; if (*destfilled || s->trailing_md_sent) { // The buffer is already in use; that's an error! - INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s); + INPROC_LOG(GPR_INFO, "Extra trailing metadata %p", s); new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata"); fail_helper_locked(s, GRPC_ERROR_REF(new_err)); goto done; @@ -639,7 +638,7 @@ static void op_state_machine(void* arg, grpc_error* error) { } s->trailing_md_sent = true; if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling trailing-md-on-complete", s); GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete, GRPC_ERROR_NONE); @@ -658,7 +657,7 @@ static void op_state_machine(void* arg, grpc_error* error) { new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd initial md"); INPROC_LOG( - GPR_DEBUG, + GPR_INFO, "op_state_machine %p scheduling on_complete errors for already " "recvd initial md %p", s, new_err); @@ -684,7 +683,7 @@ static void op_state_machine(void* arg, grpc_error* error) { } grpc_metadata_batch_clear(&s->to_read_initial_md); s->to_read_initial_md_filled = false; - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling initial-metadata-ready %p", s, new_err); GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata @@ -696,7 +695,7 @@ static void op_state_machine(void* arg, grpc_error* error) { s->recv_initial_md_op = nullptr; if (new_err != GRPC_ERROR_NONE) { - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling on_complete errors2 %p", s, new_err); fail_helper_locked(s, GRPC_ERROR_REF(new_err)); @@ -719,7 +718,7 @@ static void op_state_machine(void* arg, grpc_error* error) { new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd trailing md"); INPROC_LOG( - GPR_DEBUG, + GPR_INFO, "op_state_machine %p scheduling on_complete errors for already " "recvd trailing md %p", s, new_err); @@ -729,7 +728,7 @@ static void op_state_machine(void* arg, grpc_error* error) { if (s->recv_message_op != nullptr) { // This message needs to be wrapped up because it will never be // satisfied - INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s); + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling message-ready", s); GRPC_CLOSURE_SCHED( s->recv_message_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); @@ -764,7 +763,7 @@ static void op_state_machine(void* arg, grpc_error* error) { // (If the server hasn't already sent its trailing md, it doesn't have // a final status, so don't mark this op complete) if (s->t->is_client || s->trailing_md_sent) { - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling trailing-md-on-complete %p", s, new_err); GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete, @@ -772,21 +771,21 @@ static void op_state_machine(void* arg, grpc_error* error) { s->recv_trailing_md_op = nullptr; needs_close = true; } else { - INPROC_LOG(GPR_DEBUG, + INPROC_LOG(GPR_INFO, "op_state_machine %p server needs to delay handling " "trailing-md-on-complete %p", s, new_err); } } else { INPROC_LOG( - GPR_DEBUG, + GPR_INFO, "op_state_machine %p has trailing md but not yet waiting for it", s); } } if (s->trailing_md_recvd && s->recv_message_op) { // No further message will come on this stream, so finish off the // recv_message_op - INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s); + INPROC_LOG(GPR_INFO, "op_state_machine %p scheduling message-ready", s); GRPC_CLOSURE_SCHED( s->recv_message_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); @@ -810,7 +809,7 @@ static void op_state_machine(void* arg, grpc_error* error) { // Didn't get the item we wanted so we still need to get // rescheduled INPROC_LOG( - GPR_DEBUG, "op_state_machine %p still needs closure %p %p %p %p %p", s, + GPR_INFO, "op_state_machine %p still needs closure %p %p %p %p %p", s, s->send_message_op, s->send_trailing_md_op, s->recv_initial_md_op, s->recv_message_op, s->recv_trailing_md_op); s->ops_needed = true; @@ -826,8 +825,7 @@ done: static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) { bool ret = false; // was the cancel accepted - INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s, - grpc_error_string(error)); + INPROC_LOG(GPR_INFO, "cancel_stream %p with %s", s, grpc_error_string(error)); if (s->cancel_self_error == GRPC_ERROR_NONE) { ret = true; s->cancel_self_error = GRPC_ERROR_REF(error); @@ -877,7 +875,7 @@ static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) { static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, grpc_transport_stream_op_batch* op) { - INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op); + INPROC_LOG(GPR_INFO, "perform_stream_op %p %p %p", gt, gs, op); inproc_stream* s = reinterpret_cast(gs); gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed gpr_mu_lock(mu); @@ -907,7 +905,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, // already self-canceled so still give it an error error = GRPC_ERROR_REF(s->cancel_self_error); } else { - INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %s%s%s%s%s%s%s", s, + INPROC_LOG(GPR_INFO, "perform_stream_op %p %s%s%s%s%s%s%s", s, s->t->is_client ? "client" : "server", op->send_initial_metadata ? " send_initial_metadata" : "", op->send_message ? " send_message" : "", @@ -936,7 +934,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, : &other->to_read_initial_md_filled; if (*destfilled || s->initial_md_sent) { // The buffer is already in use; that's an error! - INPROC_LOG(GPR_DEBUG, "Extra initial metadata %p", s); + INPROC_LOG(GPR_INFO, "Extra initial metadata %p", s); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra initial metadata"); } else { if (!other || !other->closed) { @@ -1013,7 +1011,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, true; } INPROC_LOG( - GPR_DEBUG, + GPR_INFO, "perform_stream_op error %p scheduling initial-metadata-ready %p", s, error); GRPC_CLOSURE_SCHED( @@ -1022,14 +1020,14 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, } if (op->recv_message) { INPROC_LOG( - GPR_DEBUG, + GPR_INFO, "perform_stream_op error %p scheduling recv message-ready %p", s, error); GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready, GRPC_ERROR_REF(error)); } } - INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s, + INPROC_LOG(GPR_INFO, "perform_stream_op %p scheduling on_complete %p", s, error); GRPC_CLOSURE_SCHED(on_complete, GRPC_ERROR_REF(error)); } @@ -1042,7 +1040,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs, } static void close_transport_locked(inproc_transport* t) { - INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed); + INPROC_LOG(GPR_INFO, "close_transport %p %d", t, t->is_closed); grpc_connectivity_state_set( &t->connectivity, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."), @@ -1063,7 +1061,7 @@ static void close_transport_locked(inproc_transport* t) { static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) { inproc_transport* t = reinterpret_cast(gt); - INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op); + INPROC_LOG(GPR_INFO, "perform_transport_op %p %p", t, op); gpr_mu_lock(&t->mu->mu); if (op->on_connectivity_state_change) { grpc_connectivity_state_notify_on_state_change( @@ -1096,7 +1094,7 @@ static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) { static void destroy_stream(grpc_transport* gt, grpc_stream* gs, grpc_closure* then_schedule_closure) { - INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure); + INPROC_LOG(GPR_INFO, "destroy_stream %p %p", gs, then_schedule_closure); inproc_stream* s = reinterpret_cast(gs); s->closure_at_destroy = then_schedule_closure; really_destroy_stream(s); @@ -1104,7 +1102,7 @@ static void destroy_stream(grpc_transport* gt, grpc_stream* gs, static void destroy_transport(grpc_transport* gt) { inproc_transport* t = reinterpret_cast(gt); - INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t); + INPROC_LOG(GPR_INFO, "destroy_transport %p", t); gpr_mu_lock(&t->mu->mu); close_transport_locked(t); gpr_mu_unlock(&t->mu->mu); @@ -1165,7 +1163,7 @@ static void inproc_transports_create(grpc_transport** server_transport, const grpc_channel_args* server_args, grpc_transport** client_transport, const grpc_channel_args* client_args) { - INPROC_LOG(GPR_DEBUG, "inproc_transports_create"); + INPROC_LOG(GPR_INFO, "inproc_transports_create"); inproc_transport* st = static_cast(gpr_zalloc(sizeof(*st))); inproc_transport* ct = diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc index 9cd97823d4..2faeb64cb6 100644 --- a/src/core/lib/channel/handshaker.cc +++ b/src/core/lib/channel/handshaker.cc @@ -137,7 +137,7 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr, grpc_handshaker* handshaker) { if (grpc_handshaker_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "handshake_manager %p: adding handshaker %s [%p] at index %" PRIuPTR, mgr, grpc_handshaker_name(handshaker), handshaker, mgr->count); } @@ -208,7 +208,7 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr, grpc_error* error) { if (grpc_handshaker_trace.enabled()) { char* args_str = handshaker_args_string(&mgr->args); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR ", args=%s", mgr, grpc_error_string(error), mgr->shutdown, mgr->index, args_str); @@ -221,7 +221,7 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr, if (error != GRPC_ERROR_NONE || mgr->shutdown || mgr->args.exit_early || mgr->index == mgr->count) { if (grpc_handshaker_trace.enabled()) { - gpr_log(GPR_DEBUG, "handshake_manager %p: handshaking complete", mgr); + gpr_log(GPR_INFO, "handshake_manager %p: handshaking complete", mgr); } // Cancel deadline timer, since we're invoking the on_handshake_done // callback now. @@ -231,7 +231,7 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr, } else { if (grpc_handshaker_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "handshake_manager %p: calling handshaker %s [%p] at index %" PRIuPTR, mgr, grpc_handshaker_name(mgr->handshakers[mgr->index]), mgr->handshakers[mgr->index], mgr->index); diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index b50f8c247c..73a73995c7 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -159,7 +159,7 @@ class InternallyRefCountedWithTracing : public Orphanable { const char* reason) GRPC_MUST_USE_RESULT { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); - gpr_log(GPR_DEBUG, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", + gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs + 1, reason); } @@ -180,7 +180,7 @@ class InternallyRefCountedWithTracing : public Orphanable { void Unref(const DebugLocation& location, const char* reason) { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); - gpr_log(GPR_DEBUG, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", + gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs - 1, reason); } diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index bd6874f3db..c67e3f315c 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -100,7 +100,7 @@ class RefCountedWithTracing { const char* reason) GRPC_MUST_USE_RESULT { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); - gpr_log(GPR_DEBUG, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", + gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs + 1, reason); } @@ -121,7 +121,7 @@ class RefCountedWithTracing { void Unref(const DebugLocation& location, const char* reason) { if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) { gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count); - gpr_log(GPR_DEBUG, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", + gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", trace_flag_->name(), this, location.file(), location.line(), old_refs, old_refs - 1, reason); } diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index 24e11b687b..00a839b64c 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -64,7 +64,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner, const char* reason) { GPR_TIMER_SCOPE("call_combiner_start", 0); if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "==> grpc_call_combiner_start() [%p] closure=%p [" DEBUG_FMT_STR "%s] error=%s", call_combiner, closure DEBUG_FMT_ARGS, reason, @@ -73,7 +73,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner, size_t prev_size = static_cast( gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1)); if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size, + gpr_log(GPR_INFO, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size, prev_size + 1); } GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS(); @@ -82,7 +82,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner, GPR_TIMER_MARK("call_combiner_initiate", 0); if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " EXECUTING IMMEDIATELY"); + gpr_log(GPR_INFO, " EXECUTING IMMEDIATELY"); } // Queue was empty, so execute this closure immediately. GRPC_CLOSURE_SCHED(closure, error); @@ -101,21 +101,21 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS, const char* reason) { GPR_TIMER_SCOPE("call_combiner_stop", 0); if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "==> grpc_call_combiner_stop() [%p] [" DEBUG_FMT_STR "%s]", call_combiner DEBUG_FMT_ARGS, reason); } size_t prev_size = static_cast( gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1)); if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size, + gpr_log(GPR_INFO, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size, prev_size - 1); } GPR_ASSERT(prev_size >= 1); if (prev_size > 1) { while (true) { if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " checking queue"); + gpr_log(GPR_INFO, " checking queue"); } bool empty; grpc_closure* closure = reinterpret_cast( @@ -124,19 +124,19 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS, // This can happen either due to a race condition within the mpscq // code or because of a race with grpc_call_combiner_start(). if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " queue returned no result; checking again"); + gpr_log(GPR_INFO, " queue returned no result; checking again"); } continue; } if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " EXECUTING FROM QUEUE: closure=%p error=%s", + gpr_log(GPR_INFO, " EXECUTING FROM QUEUE: closure=%p error=%s", closure, grpc_error_string(closure->error_data.error)); } GRPC_CLOSURE_SCHED(closure, closure->error_data.error); break; } } else if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, " queue empty"); + gpr_log(GPR_INFO, " queue empty"); } } @@ -151,7 +151,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner, // Otherwise, store the new closure. if (original_error != GRPC_ERROR_NONE) { if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "call_combiner=%p: scheduling notify_on_cancel callback=%p " "for pre-existing cancellation", call_combiner, closure); @@ -162,7 +162,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner, if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state, (gpr_atm)closure)) { if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, "call_combiner=%p: setting notify_on_cancel=%p", + gpr_log(GPR_INFO, "call_combiner=%p: setting notify_on_cancel=%p", call_combiner, closure); } // If we replaced an earlier closure, invoke the original @@ -171,7 +171,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner, if (original_state != 0) { closure = (grpc_closure*)original_state; if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "call_combiner=%p: scheduling old cancel callback=%p", call_combiner, closure); } @@ -199,7 +199,7 @@ void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner, if (original_state != 0) { grpc_closure* notify_on_cancel = (grpc_closure*)original_state; if (grpc_call_combiner_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "call_combiner=%p: scheduling notify_on_cancel callback=%p", call_combiner, notify_on_cancel); } diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index e66df03182..9429842eb8 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -83,12 +83,12 @@ grpc_combiner* grpc_combiner_create(void) { grpc_closure_list_init(&lock->final_list); GRPC_CLOSURE_INIT(&lock->offload, offload, lock, grpc_executor_scheduler(GRPC_EXECUTOR_SHORT)); - GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p create", lock)); + GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p create", lock)); return lock; } static void really_destroy(grpc_combiner* lock) { - GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p really_destroy", lock)); + GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p really_destroy", lock)); GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0); gpr_mpscq_destroy(&lock->queue); gpr_free(lock); @@ -97,7 +97,7 @@ static void really_destroy(grpc_combiner* lock) { static void start_destroy(grpc_combiner* lock) { gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED); GRPC_COMBINER_TRACE(gpr_log( - GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state)); + GPR_INFO, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state)); if (old_state == 1) { really_destroy(lock); } @@ -159,7 +159,7 @@ static void combiner_exec(grpc_closure* cl, grpc_error* error) { GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS(); grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(cl, scheduler); gpr_atm last = gpr_atm_full_fetch_add(&lock->state, STATE_ELEM_COUNT_LOW_BIT); - GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, + GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p grpc_combiner_execute c=%p last=%" PRIdPTR, lock, cl, last)); if (last == 1) { @@ -203,7 +203,7 @@ static void offload(void* arg, grpc_error* error) { static void queue_offload(grpc_combiner* lock) { GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED(); move_next(); - GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p queue_offload", lock)); + GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p queue_offload", lock)); GRPC_CLOSURE_SCHED(&lock->offload, GRPC_ERROR_NONE); } @@ -218,7 +218,7 @@ bool grpc_combiner_continue_exec_ctx() { bool contended = gpr_atm_no_barrier_load(&lock->initiating_exec_ctx_or_null) == 0; - GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, + GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p grpc_combiner_continue_exec_ctx " "contended=%d " "exec_ctx_ready_to_finish=%d " @@ -242,7 +242,7 @@ bool grpc_combiner_continue_exec_ctx() { (gpr_atm_acq_load(&lock->state) >> 1) > 1) { gpr_mpscq_node* n = gpr_mpscq_pop(&lock->queue); GRPC_COMBINER_TRACE( - gpr_log(GPR_DEBUG, "C:%p maybe_finish_one n=%p", lock, n)); + gpr_log(GPR_INFO, "C:%p maybe_finish_one n=%p", lock, n)); if (n == nullptr) { // queue is in an inconsistent state: use this as a cue that we should // go off and do something else for a while (and come back later) @@ -266,7 +266,7 @@ bool grpc_combiner_continue_exec_ctx() { while (c != nullptr) { GPR_TIMER_SCOPE("combiner.exec_1final", 0); GRPC_COMBINER_TRACE( - gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c)); + gpr_log(GPR_INFO, "C:%p execute_final[%d] c=%p", lock, loops, c)); grpc_closure* next = c->next_data.next; grpc_error* error = c->error_data.error; #ifndef NDEBUG @@ -284,7 +284,7 @@ bool grpc_combiner_continue_exec_ctx() { gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_ELEM_COUNT_LOW_BIT); GRPC_COMBINER_TRACE( - gpr_log(GPR_DEBUG, "C:%p finish old_state=%" PRIdPTR, lock, old_state)); + gpr_log(GPR_INFO, "C:%p finish old_state=%" PRIdPTR, lock, old_state)); // Define a macro to ease readability of the following switch statement. #define OLD_STATE_WAS(orphaned, elem_count) \ (((orphaned) ? 0 : STATE_UNORPHANED) | \ @@ -327,8 +327,8 @@ static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) { grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(closure, finally_scheduler); GRPC_COMBINER_TRACE(gpr_log( - GPR_DEBUG, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock, - closure, grpc_core::ExecCtx::Get()->combiner_data()->active_combiner)); + GPR_INFO, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock, closure, + grpc_core::ExecCtx::Get()->combiner_data()->active_combiner)); if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner != lock) { GPR_TIMER_MARK("slowpath", 0); GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(enqueue_finally, closure, diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 3ebaf181c1..e5db1be0e0 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -658,7 +658,7 @@ static grpc_error* do_epoll_wait(grpc_pollset* ps, grpc_millis deadline) { GRPC_STATS_INC_POLL_EVENTS_RETURNED(r); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "ps: %p poll got %d events", ps, r); + gpr_log(GPR_INFO, "ps: %p poll got %d events", ps, r); } gpr_atm_rel_store(&g_epoll_set.num_events, r); @@ -678,7 +678,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, pollset->begin_refs++; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p BEGIN_STARTS:%p", pollset, worker); + gpr_log(GPR_INFO, "PS:%p BEGIN_STARTS:%p", pollset, worker); } if (pollset->seen_inactive) { @@ -697,7 +697,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, gpr_mu_lock(&neighborhood->mu); gpr_mu_lock(&pollset->mu); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p BEGIN_REORG:%p kick_state=%s is_reassigning=%d", + gpr_log(GPR_INFO, "PS:%p BEGIN_REORG:%p kick_state=%s is_reassigning=%d", pollset, worker, kick_state_string(worker->state), is_reassigning); } @@ -749,7 +749,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, gpr_cv_init(&worker->cv); while (worker->state == UNKICKED && !pollset->shutting_down) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p BEGIN_WAIT:%p kick_state=%s shutdown=%d", + gpr_log(GPR_INFO, "PS:%p BEGIN_WAIT:%p kick_state=%s shutdown=%d", pollset, worker, kick_state_string(worker->state), pollset->shutting_down); } @@ -766,7 +766,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, } if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p BEGIN_DONE:%p kick_state=%s shutdown=%d " "kicked_without_poller: %d", pollset, worker, kick_state_string(worker->state), @@ -809,7 +809,7 @@ static bool check_neighborhood_for_available_poller( if (gpr_atm_no_barrier_cas(&g_active_poller, 0, (gpr_atm)inspect_worker)) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. choose next poller to be %p", + gpr_log(GPR_INFO, " .. choose next poller to be %p", inspect_worker); } SET_KICK_STATE(inspect_worker, DESIGNATED_POLLER); @@ -820,7 +820,7 @@ static bool check_neighborhood_for_available_poller( } } else { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. beaten to choose next poller"); + gpr_log(GPR_INFO, " .. beaten to choose next poller"); } } // even if we didn't win the cas, there's a worker, we can stop @@ -838,7 +838,7 @@ static bool check_neighborhood_for_available_poller( } if (!found_worker) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. mark pollset %p inactive", inspect); + gpr_log(GPR_INFO, " .. mark pollset %p inactive", inspect); } inspect->seen_inactive = true; if (inspect == neighborhood->active_root) { @@ -858,7 +858,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, grpc_pollset_worker** worker_hdl) { GPR_TIMER_SCOPE("end_worker", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p END_WORKER:%p", pollset, worker); + gpr_log(GPR_INFO, "PS:%p END_WORKER:%p", pollset, worker); } if (worker_hdl != nullptr) *worker_hdl = nullptr; /* Make sure we appear kicked */ @@ -868,7 +868,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, if (gpr_atm_no_barrier_load(&g_active_poller) == (gpr_atm)worker) { if (worker->next != worker && worker->next->state == UNKICKED) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. choose next poller to be peer %p", worker); + gpr_log(GPR_INFO, " .. choose next poller to be peer %p", worker); } GPR_ASSERT(worker->next->initialized_cv); gpr_atm_no_barrier_store(&g_active_poller, (gpr_atm)worker->next); @@ -920,7 +920,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, gpr_cv_destroy(&worker->cv); } if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. remove worker"); + gpr_log(GPR_INFO, " .. remove worker"); } if (EMPTIED == worker_remove(pollset, worker)) { pollset_maybe_finish_shutdown(pollset); @@ -1022,7 +1022,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(); pollset->kicked_without_poller = true; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kicked_without_poller"); + gpr_log(GPR_INFO, " .. kicked_without_poller"); } goto done; } @@ -1030,14 +1030,14 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, if (root_worker->state == KICKED) { GRPC_STATS_INC_POLLSET_KICKED_AGAIN(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. already kicked %p", root_worker); + gpr_log(GPR_INFO, " .. already kicked %p", root_worker); } SET_KICK_STATE(root_worker, KICKED); goto done; } else if (next_worker->state == KICKED) { GRPC_STATS_INC_POLLSET_KICKED_AGAIN(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. already kicked %p", next_worker); + gpr_log(GPR_INFO, " .. already kicked %p", next_worker); } SET_KICK_STATE(next_worker, KICKED); goto done; @@ -1048,7 +1048,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, &g_active_poller)) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kicked %p", root_worker); + gpr_log(GPR_INFO, " .. kicked %p", root_worker); } SET_KICK_STATE(root_worker, KICKED); ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd); @@ -1056,7 +1056,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } else if (next_worker->state == UNKICKED) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kicked %p", next_worker); + gpr_log(GPR_INFO, " .. kicked %p", next_worker); } GPR_ASSERT(next_worker->initialized_cv); SET_KICK_STATE(next_worker, KICKED); @@ -1066,7 +1066,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, if (root_worker->state != DESIGNATED_POLLER) { if (grpc_polling_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, " .. kicked root non-poller %p (initialized_cv=%d) (poller=%p)", root_worker, root_worker->initialized_cv, next_worker); } @@ -1079,7 +1079,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } else { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. non-root poller %p (root=%p)", next_worker, + gpr_log(GPR_INFO, " .. non-root poller %p (root=%p)", next_worker, root_worker); } SET_KICK_STATE(next_worker, KICKED); @@ -1095,7 +1095,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } else { GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kicked while waking up"); + gpr_log(GPR_INFO, " .. kicked while waking up"); } goto done; } @@ -1105,14 +1105,14 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, if (specific_worker->state == KICKED) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. specific worker already kicked"); + gpr_log(GPR_INFO, " .. specific worker already kicked"); } goto done; } else if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) { GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. mark %p kicked", specific_worker); + gpr_log(GPR_INFO, " .. mark %p kicked", specific_worker); } SET_KICK_STATE(specific_worker, KICKED); goto done; @@ -1120,7 +1120,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, (grpc_pollset_worker*)gpr_atm_no_barrier_load(&g_active_poller)) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kick active poller"); + gpr_log(GPR_INFO, " .. kick active poller"); } SET_KICK_STATE(specific_worker, KICKED); ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd); @@ -1128,7 +1128,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } else if (specific_worker->initialized_cv) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kick waiting worker"); + gpr_log(GPR_INFO, " .. kick waiting worker"); } SET_KICK_STATE(specific_worker, KICKED); gpr_cv_signal(&specific_worker->cv); @@ -1136,7 +1136,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } else { GRPC_STATS_INC_POLLSET_KICKED_AGAIN(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. kick non-waiting worker"); + gpr_log(GPR_INFO, " .. kick non-waiting worker"); } SET_KICK_STATE(specific_worker, KICKED); goto done; diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 44d8cf2b1e..65f1c912af 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -518,7 +518,7 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) { const int epfd = p->epfd; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "add fd %p (%d) to pollable %p", fd, fd->fd, p); + gpr_log(GPR_INFO, "add fd %p (%d) to pollable %p", fd, fd->fd, p); } struct epoll_event ev_fd; @@ -560,7 +560,7 @@ static void pollset_global_shutdown(void) { /* pollset->mu must be held while calling this function */ static void pollset_maybe_finish_shutdown(grpc_pollset* pollset) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p (pollable:%p) maybe_finish_shutdown sc=%p (target:!NULL) " "rw=%p (target:NULL) cpsc=%d (target:0)", pollset, pollset->active_pollable, pollset->shutdown_closure, @@ -585,14 +585,14 @@ static grpc_error* kick_one_worker(grpc_pollset_worker* specific_worker) { GPR_ASSERT(specific_worker != nullptr); if (specific_worker->kicked) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p); + gpr_log(GPR_INFO, "PS:%p kicked_specific_but_already_kicked", p); } GRPC_STATS_INC_POLLSET_KICKED_AGAIN(); return GRPC_ERROR_NONE; } if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_awake", p); + gpr_log(GPR_INFO, "PS:%p kicked_specific_but_awake", p); } GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(); specific_worker->kicked = true; @@ -601,7 +601,7 @@ static grpc_error* kick_one_worker(grpc_pollset_worker* specific_worker) { if (specific_worker == p->root_worker) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_wakeup_fd", p); + gpr_log(GPR_INFO, "PS:%p kicked_specific_via_wakeup_fd", p); } specific_worker->kicked = true; grpc_error* error = grpc_wakeup_fd_wakeup(&p->wakeup); @@ -610,7 +610,7 @@ static grpc_error* kick_one_worker(grpc_pollset_worker* specific_worker) { if (specific_worker->initialized_cv) { GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p); + gpr_log(GPR_INFO, "PS:%p kicked_specific_via_cv", p); } specific_worker->kicked = true; gpr_cv_signal(&specific_worker->cv); @@ -626,7 +626,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, GPR_TIMER_SCOPE("pollset_kick", 0); GRPC_STATS_INC_POLLSET_KICK(); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p kick %p tls_pollset=%p tls_worker=%p pollset.root_worker=%p", pollset, specific_worker, (void*)gpr_tls_get(&g_current_thread_pollset), @@ -636,7 +636,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) { if (pollset->root_worker == nullptr) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset); + gpr_log(GPR_INFO, "PS:%p kicked_any_without_poller", pollset); } GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(); pollset->kicked_without_poller = true; @@ -662,7 +662,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset, } } else { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", pollset); + gpr_log(GPR_INFO, "PS:%p kicked_any_but_awake", pollset); } GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(); return GRPC_ERROR_NONE; @@ -784,7 +784,7 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset, void* data_ptr = ev->data.ptr; if (1 & (intptr_t)data_ptr) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr); + gpr_log(GPR_INFO, "PS:%p got pollset_wakeup %p", pollset, data_ptr); } append_error(&error, grpc_wakeup_fd_consume_wakeup( @@ -797,7 +797,7 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset, bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0; bool write_ev = (ev->events & EPOLLOUT) != 0; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p got fd %p: cancel=%d read=%d " "write=%d", pollset, fd, cancel, read_ev, write_ev); @@ -827,7 +827,7 @@ static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) { if (grpc_polling_trace.enabled()) { char* desc = pollable_desc(p); - gpr_log(GPR_DEBUG, "POLLABLE:%p[%s] poll for %dms", p, desc, timeout); + gpr_log(GPR_INFO, "POLLABLE:%p[%s] poll for %dms", p, desc, timeout); gpr_free(desc); } @@ -846,7 +846,7 @@ static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) { if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait"); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "POLLABLE:%p got %d events", p, r); + gpr_log(GPR_INFO, "POLLABLE:%p got %d events", p, r); } p->event_cursor = 0; @@ -917,7 +917,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, gpr_mu_unlock(&pollset->mu); if (grpc_polling_trace.enabled() && worker->pollable_obj->root_worker != worker) { - gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset, + gpr_log(GPR_INFO, "PS:%p wait %p w=%p for %dms", pollset, worker->pollable_obj, worker, poll_deadline_to_millis_timeout(deadline)); } @@ -925,19 +925,19 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, if (gpr_cv_wait(&worker->cv, &worker->pollable_obj->mu, grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p timeout_wait %p w=%p", pollset, + gpr_log(GPR_INFO, "PS:%p timeout_wait %p w=%p", pollset, worker->pollable_obj, worker); } do_poll = false; } else if (worker->kicked) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PS:%p wakeup %p w=%p", pollset, + gpr_log(GPR_INFO, "PS:%p wakeup %p w=%p", pollset, worker->pollable_obj, worker); } do_poll = false; } else if (grpc_polling_trace.enabled() && worker->pollable_obj->root_worker != worker) { - gpr_log(GPR_DEBUG, "PS:%p spurious_wakeup %p w=%p", pollset, + gpr_log(GPR_INFO, "PS:%p spurious_wakeup %p w=%p", pollset, worker->pollable_obj, worker); } } @@ -1009,7 +1009,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, WORKER_PTR->originator = gettid(); #endif if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p work hdl=%p worker=%p now=%" PRIdPTR " deadline=%" PRIdPTR " kwp=%d pollable=%p", pollset, worker_hdl, WORKER_PTR, grpc_core::ExecCtx::Get()->Now(), @@ -1050,7 +1050,7 @@ static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked( static const char* err_desc = "pollset_transition_pollable_from_empty_to_fd"; grpc_error* error = GRPC_ERROR_NONE; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p add fd %p (%d); transition pollable from empty to fd", pollset, fd, fd->fd); } @@ -1067,7 +1067,7 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked( grpc_error* error = GRPC_ERROR_NONE; if (grpc_polling_trace.enabled()) { gpr_log( - GPR_DEBUG, + GPR_INFO, "PS:%p add fd %p (%d); transition pollable from fd %p to multipoller", pollset, and_add_fd, and_add_fd ? and_add_fd->fd : -1, pollset->active_pollable->owner_fd); @@ -1137,7 +1137,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_pollset* pollset, /* Any workers currently polling on this pollset must now be woked up so * that they can pick up the new active_pollable */ if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "PS:%p active pollable transition from empty to multi", pollset); } @@ -1224,7 +1224,7 @@ static void pollset_set_unref(grpc_pollset_set* pss) { static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) { GPR_TIMER_SCOPE("pollset_set_add_fd", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS:%p: add fd %p (%d)", pss, fd, fd->fd); + gpr_log(GPR_INFO, "PSS:%p: add fd %p (%d)", pss, fd, fd->fd); } grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollset_set_add_fd"; @@ -1248,7 +1248,7 @@ static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) { static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) { GPR_TIMER_SCOPE("pollset_set_del_fd", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS:%p: del fd %p", pss, fd); + gpr_log(GPR_INFO, "PSS:%p: del fd %p", pss, fd); } pss = pss_lock_adam(pss); size_t i; @@ -1269,7 +1269,7 @@ static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) { static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) { GPR_TIMER_SCOPE("pollset_set_del_pollset", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS:%p: del pollset %p", pss, ps); + gpr_log(GPR_INFO, "PSS:%p: del pollset %p", pss, ps); } pss = pss_lock_adam(pss); size_t i; @@ -1321,7 +1321,7 @@ static grpc_error* add_fds_to_pollsets(grpc_fd** fds, size_t fd_count, static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) { GPR_TIMER_SCOPE("pollset_set_add_pollset", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS:%p: add pollset %p", pss, ps); + gpr_log(GPR_INFO, "PSS:%p: add pollset %p", pss, ps); } grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollset_set_add_pollset"; @@ -1358,7 +1358,7 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* a, grpc_pollset_set* b) { GPR_TIMER_SCOPE("pollset_set_add_pollset_set", 0); if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS: merge (%p, %p)", a, b); + gpr_log(GPR_INFO, "PSS: merge (%p, %p)", a, b); } grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollset_set_add_fd"; @@ -1392,7 +1392,7 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* a, GPR_SWAP(grpc_pollset_set*, a, b); } if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "PSS: parent %p to %p", b, a); + gpr_log(GPR_INFO, "PSS: parent %p to %p", b, a); } gpr_ref(&a->refs); b->parent = a; diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 1e30f6637b..494bc71c1d 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -292,7 +292,7 @@ static void pi_add_ref_dbg(polling_island* pi, const char* reason, const char* file, int line) { if (grpc_polling_trace.enabled()) { gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Add ref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR " (%s) - (%s, %d)", pi, old_cnt, old_cnt + 1, reason, file, line); @@ -304,7 +304,7 @@ static void pi_unref_dbg(polling_island* pi, const char* reason, const char* file, int line) { if (grpc_polling_trace.enabled()) { gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count); - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "Unref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR " (%s) - (%s, %d)", pi, old_cnt, (old_cnt - 1), reason, file, line); diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index d9aba9b6a3..504787e659 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -983,7 +983,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, GRPC_SCHEDULING_END_BLOCKING_REGION; if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r); + gpr_log(GPR_INFO, "%p poll=%d", pollset, r); } if (r < 0) { @@ -1007,7 +1007,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, } else { if (pfds[0].revents & POLLIN_CHECK) { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "%p: got_wakeup", pollset); + gpr_log(GPR_INFO, "%p: got_wakeup", pollset); } work_combine_error( &error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd)); @@ -1017,7 +1017,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, fd_end_poll(&watchers[i], 0, 0, nullptr); } else { if (grpc_polling_trace.enabled()) { - gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset, + gpr_log(GPR_INFO, "%p got_event: %d r:%d w:%d [%d]", pollset, pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0, (pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents); } diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 8b80070265..4ea63fc6e8 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -46,9 +46,9 @@ grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api"); #ifndef NDEBUG // Polling API trace only enabled in debug builds -#define GRPC_POLLING_API_TRACE(format, ...) \ - if (grpc_polling_api_trace.enabled()) { \ - gpr_log(GPR_DEBUG, "(polling-api) " format, __VA_ARGS__); \ +#define GRPC_POLLING_API_TRACE(format, ...) \ + if (grpc_polling_api_trace.enabled()) { \ + gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \ } #else #define GRPC_POLLING_API_TRACE(...) diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index b017db53f8..f19f8cf20d 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -69,7 +69,7 @@ static size_t run_closures(grpc_closure_list list) { gpr_log(GPR_DEBUG, "EXECUTOR: run %p [created by %s:%d]", c, c->file_created, c->line_created); #else - gpr_log(GPR_DEBUG, "EXECUTOR: run %p", c); + gpr_log(GPR_INFO, "EXECUTOR: run %p", c); #endif } #ifndef NDEBUG @@ -150,7 +150,7 @@ static void executor_thread(void* arg) { size_t subtract_depth = 0; for (;;) { if (executor_trace.enabled()) { - gpr_log(GPR_DEBUG, "EXECUTOR[%d]: step (sub_depth=%" PRIdPTR ")", + gpr_log(GPR_INFO, "EXECUTOR[%d]: step (sub_depth=%" PRIdPTR ")", static_cast(ts - g_thread_state), subtract_depth); } gpr_mu_lock(&ts->mu); @@ -161,7 +161,7 @@ static void executor_thread(void* arg) { } if (ts->shutdown) { if (executor_trace.enabled()) { - gpr_log(GPR_DEBUG, "EXECUTOR[%d]: shutdown", + gpr_log(GPR_INFO, "EXECUTOR[%d]: shutdown", static_cast(ts - g_thread_state)); } gpr_mu_unlock(&ts->mu); @@ -172,7 +172,7 @@ static void executor_thread(void* arg) { ts->elems = GRPC_CLOSURE_LIST_INIT; gpr_mu_unlock(&ts->mu); if (executor_trace.enabled()) { - gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", + gpr_log(GPR_INFO, "EXECUTOR[%d]: execute", static_cast(ts - g_thread_state)); } @@ -199,7 +199,7 @@ static void executor_push(grpc_closure* closure, grpc_error* error, gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p (created %s:%d) inline", closure, closure->file_created, closure->line_created); #else - gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p inline", closure); + gpr_log(GPR_INFO, "EXECUTOR: schedule %p inline", closure); #endif } grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(), @@ -225,7 +225,7 @@ static void executor_push(grpc_closure* closure, grpc_error* error, closure, is_short ? "short" : "long", closure->file_created, closure->line_created, static_cast(ts - g_thread_state)); #else - gpr_log(GPR_DEBUG, "EXECUTOR: try to schedule %p (%s) to thread %d", + gpr_log(GPR_INFO, "EXECUTOR: try to schedule %p (%s) to thread %d", closure, is_short ? "short" : "long", (int)(ts - g_thread_state)); #endif diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 8c42dd78cf..8cf4fe9928 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -289,7 +289,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) { GRPC_RULIST_AWAITING_ALLOCATION))) { gpr_mu_lock(&resource_user->mu); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "RQ: check allocation for user %p shutdown=%" PRIdPTR " free_pool=%" PRId64, resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown), @@ -315,7 +315,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) { resource_quota->free_pool -= amt; rq_update_estimate(resource_quota); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "RQ %s %s: grant alloc %" PRId64 " bytes; rq_free_pool -> %" PRId64, resource_quota->name, resource_user->name, amt, @@ -323,7 +323,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) { } } else if (grpc_resource_quota_trace.enabled() && resource_user->free_pool >= 0) { - gpr_log(GPR_DEBUG, "RQ %s %s: discard already satisfied alloc request", + gpr_log(GPR_INFO, "RQ %s %s: discard already satisfied alloc request", resource_quota->name, resource_user->name); } if (resource_user->free_pool >= 0) { @@ -353,7 +353,7 @@ static bool rq_reclaim_from_per_user_free_pool( resource_quota->free_pool += amt; rq_update_estimate(resource_quota); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "RQ %s %s: reclaim_from_per_user_free_pool %" PRId64 " bytes; rq_free_pool -> %" PRId64, resource_quota->name, resource_user->name, amt, @@ -376,9 +376,8 @@ static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) { grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list); if (resource_user == nullptr) return false; if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation", - resource_quota->name, resource_user->name, - destructive ? "destructive" : "benign"); + gpr_log(GPR_INFO, "RQ %s %s: initiate %s reclamation", resource_quota->name, + resource_user->name, destructive ? "destructive" : "benign"); } resource_quota->reclaiming = true; grpc_resource_quota_ref_internal(resource_quota); @@ -506,7 +505,7 @@ static void ru_post_destructive_reclaimer(void* ru, grpc_error* error) { static void ru_shutdown(void* ru, grpc_error* error) { if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "RU shutdown %p", ru); + gpr_log(GPR_INFO, "RU shutdown %p", ru); } grpc_resource_user* resource_user = static_cast(ru); gpr_mu_lock(&resource_user->mu); @@ -793,7 +792,7 @@ void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size, resource_user->free_pool -= static_cast(size); resource_user->outstanding_allocations += static_cast(size); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64, + gpr_log(GPR_INFO, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64, resource_user->resource_quota->name, resource_user->name, size, resource_user->free_pool); } @@ -816,7 +815,7 @@ void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) { bool was_zero_or_negative = resource_user->free_pool <= 0; resource_user->free_pool += static_cast(size); if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64, + gpr_log(GPR_INFO, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64, resource_user->resource_quota->name, resource_user->name, size, resource_user->free_pool); } @@ -842,7 +841,7 @@ void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user, void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) { if (grpc_resource_quota_trace.enabled()) { - gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete", + gpr_log(GPR_INFO, "RQ %s %s: reclamation complete", resource_user->resource_quota->name, resource_user->name); } GRPC_CLOSURE_SCHED( diff --git a/src/core/lib/iomgr/tcp_client_custom.cc b/src/core/lib/iomgr/tcp_client_custom.cc index 55632a55a1..932c79ea0b 100644 --- a/src/core/lib/iomgr/tcp_client_custom.cc +++ b/src/core/lib/iomgr/tcp_client_custom.cc @@ -66,7 +66,7 @@ static void on_alarm(void* acp, grpc_error* error) { grpc_custom_tcp_connect* connect = socket->connector; if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s", + gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", connect->addr_name, str); } if (error == GRPC_ERROR_NONE) { @@ -136,7 +136,7 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep, connect->refs = 2; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %p %s: asynchronously connecting", + gpr_log(GPR_INFO, "CLIENT_CONNECT: %p %s: asynchronously connecting", socket, connect->addr_name); } diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index 9f19b833da..6144d389f7 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -104,7 +104,7 @@ static void tc_on_alarm(void* acp, grpc_error* error) { async_connect* ac = static_cast(acp); if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str, + gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str, str); } gpr_mu_lock(&ac->mu); @@ -141,8 +141,8 @@ static void on_writable(void* acp, grpc_error* error) { if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_writable: error=%s", - ac->addr_str, str); + gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s", ac->addr_str, + str); } gpr_mu_lock(&ac->mu); @@ -325,7 +325,7 @@ void grpc_tcp_client_create_from_prepared_fd( ac->channel_args = grpc_channel_args_copy(channel_args); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting fd %p", + gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: asynchronously connecting fd %p", ac->addr_str, fdobj); } diff --git a/src/core/lib/iomgr/tcp_custom.cc b/src/core/lib/iomgr/tcp_custom.cc index 2b1fc93028..b3b2934014 100644 --- a/src/core/lib/iomgr/tcp_custom.cc +++ b/src/core/lib/iomgr/tcp_custom.cc @@ -125,16 +125,16 @@ static void tcp_ref(custom_tcp_endpoint* tcp) { gpr_ref(&tcp->refcount); } static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) { grpc_closure* cb = tcp->read_cb; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p call_cb %p %p:%p", tcp->socket, cb, cb->cb, + gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp->socket, cb, cb->cb, cb->cb_arg); size_t i; const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "read: error=%s", str); + gpr_log(GPR_INFO, "read: error=%s", str); for (i = 0; i < tcp->read_slices->count; i++) { char* dump = grpc_dump_slice(tcp->read_slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); + gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); gpr_free(dump); } } @@ -171,7 +171,7 @@ static void custom_read_callback(grpc_custom_socket* socket, size_t nread, static void tcp_read_allocation_done(void* tcpp, grpc_error* error) { custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)tcpp; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp->socket, + gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp->socket, grpc_error_string(error)); } if (error == GRPC_ERROR_NONE) { @@ -188,7 +188,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) { } if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "Initiating read on %p: error=%s", tcp->socket, str); + gpr_log(GPR_INFO, "Initiating read on %p: error=%s", tcp->socket, str); } } @@ -214,7 +214,7 @@ static void custom_write_callback(grpc_custom_socket* socket, tcp->write_cb = nullptr; if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp->socket, str); + gpr_log(GPR_INFO, "write complete on %p: error=%s", tcp->socket, str); } TCP_UNREF(tcp, "write"); GRPC_CLOSURE_SCHED(cb, error); @@ -231,8 +231,8 @@ static void endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* write_slices, for (j = 0; j < write_slices->count; j++) { char* data = grpc_dump_slice(write_slices->slices[j], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp->socket, - tcp->peer_string, data); + gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp->socket, tcp->peer_string, + data); gpr_free(data); } } @@ -283,7 +283,7 @@ static void endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) { if (!tcp->shutting_down) { if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(why); - gpr_log(GPR_DEBUG, "TCP %p shutdown why=%s", tcp->socket, str); + gpr_log(GPR_INFO, "TCP %p shutdown why=%s", tcp->socket, str); } tcp->shutting_down = true; // GRPC_CLOSURE_SCHED(tcp->read_cb, GRPC_ERROR_REF(why)); @@ -345,7 +345,7 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket, grpc_core::ExecCtx exec_ctx; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", socket); + gpr_log(GPR_INFO, "Creating TCP endpoint %p", socket); } memset(tcp, 0, sizeof(custom_tcp_endpoint)); socket->refs++; diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 205af22531..fc2b94d693 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -120,7 +120,7 @@ static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */, static void done_poller(void* bp, grpc_error* error_ignored) { backup_poller* p = static_cast(bp); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p destroy", p); } grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p)); gpr_free(p); @@ -129,7 +129,7 @@ static void done_poller(void* bp, grpc_error* error_ignored) { static void run_poller(void* bp, grpc_error* error_ignored) { backup_poller* p = static_cast(bp); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p run", p); } gpr_mu_lock(p->pollset_mu); grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC; @@ -145,18 +145,18 @@ static void run_poller(void* bp, grpc_error* error_ignored) { gpr_mu_lock(p->pollset_mu); bool cas_ok = gpr_atm_full_cas(&g_backup_poller, (gpr_atm)p, 0); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p done cas_ok=%d", p, cas_ok); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p done cas_ok=%d", p, cas_ok); } gpr_mu_unlock(p->pollset_mu); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p shutdown", p); } grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p), GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p, grpc_schedule_on_exec_ctx)); } else { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p reschedule", p); } GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE); } @@ -167,7 +167,7 @@ static void drop_uncovered(grpc_tcp* tcp) { gpr_atm old_count = gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p uncover cnt %d->%d", p, + gpr_log(GPR_INFO, "BACKUP_POLLER:%p uncover cnt %d->%d", p, static_cast(old_count), static_cast(old_count) - 1); } GPR_ASSERT(old_count != 1); @@ -178,7 +178,7 @@ static void cover_self(grpc_tcp* tcp) { gpr_atm old_count = gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER: cover cnt %d->%d", + gpr_log(GPR_INFO, "BACKUP_POLLER: cover cnt %d->%d", static_cast(old_count), 2 + static_cast(old_count)); } if (old_count == 0) { @@ -186,7 +186,7 @@ static void cover_self(grpc_tcp* tcp) { p = static_cast( gpr_zalloc(sizeof(*p) + grpc_pollset_size())); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p create", p); } grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu); gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p); @@ -201,7 +201,7 @@ static void cover_self(grpc_tcp* tcp) { } } if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp); + gpr_log(GPR_INFO, "BACKUP_POLLER:%p add %p", p, tcp); } grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd); if (old_count != 0) { @@ -211,7 +211,7 @@ static void cover_self(grpc_tcp* tcp) { static void notify_on_read(grpc_tcp* tcp) { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp); + gpr_log(GPR_INFO, "TCP:%p notify_on_read", tcp); } GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp, grpc_schedule_on_exec_ctx); @@ -220,7 +220,7 @@ static void notify_on_read(grpc_tcp* tcp) { static void notify_on_write(grpc_tcp* tcp) { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp); + gpr_log(GPR_INFO, "TCP:%p notify_on_write", tcp); } cover_self(tcp); GRPC_CLOSURE_INIT(&tcp->write_done_closure, @@ -231,7 +231,7 @@ static void notify_on_write(grpc_tcp* tcp) { static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error)); + gpr_log(GPR_INFO, "TCP:%p got_write: %s", arg, grpc_error_string(error)); } drop_uncovered(static_cast(arg)); tcp_handle_write(arg, error); @@ -351,15 +351,15 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) { grpc_closure* cb = tcp->read_cb; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg); + gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg); size_t i; const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "read: error=%s", str); + gpr_log(GPR_INFO, "read: error=%s", str); for (i = 0; i < tcp->incoming_buffer->count; i++) { char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); + gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); gpr_free(dump); } } @@ -441,7 +441,7 @@ static void tcp_do_read(grpc_tcp* tcp) { static void tcp_read_allocation_done(void* tcpp, grpc_error* error) { grpc_tcp* tcp = static_cast(tcpp); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp, + gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp, grpc_error_string(error)); } if (error != GRPC_ERROR_NONE) { @@ -459,13 +459,13 @@ static void tcp_continue_read(grpc_tcp* tcp) { if (tcp->incoming_buffer->length < target_read_size && tcp->incoming_buffer->count < MAX_READ_IOVEC) { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp); + gpr_log(GPR_INFO, "TCP:%p alloc_slices", tcp); } grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1, tcp->incoming_buffer); } else { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp); + gpr_log(GPR_INFO, "TCP:%p do_read", tcp); } tcp_do_read(tcp); } @@ -475,7 +475,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) { grpc_tcp* tcp = static_cast(arg); GPR_ASSERT(!tcp->finished_edge); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "TCP:%p got_read: %s", tcp, grpc_error_string(error)); + gpr_log(GPR_INFO, "TCP:%p got_read: %s", tcp, grpc_error_string(error)); } if (error != GRPC_ERROR_NONE) { @@ -618,7 +618,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { if (!tcp_flush(tcp, &error)) { if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "write: delayed"); + gpr_log(GPR_INFO, "write: delayed"); } notify_on_write(tcp); } else { @@ -626,7 +626,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { tcp->write_cb = nullptr; if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "write: %s", str); + gpr_log(GPR_INFO, "write: %s", str); } GRPC_CLOSURE_RUN(cb, error); @@ -646,7 +646,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf, for (i = 0; i < buf->count; i++) { char* data = grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data); + gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data); gpr_free(data); } } @@ -668,13 +668,13 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf, TCP_REF(tcp, "write"); tcp->write_cb = cb; if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "write: delayed"); + gpr_log(GPR_INFO, "write: delayed"); } notify_on_write(tcp); } else { if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); - gpr_log(GPR_DEBUG, "write: %s", str); + gpr_log(GPR_INFO, "write: %s", str); } GRPC_CLOSURE_SCHED(cb, error); } diff --git a/src/core/lib/iomgr/tcp_server_custom.cc b/src/core/lib/iomgr/tcp_server_custom.cc index 79ba5c39ee..019b354473 100644 --- a/src/core/lib/iomgr/tcp_server_custom.cc +++ b/src/core/lib/iomgr/tcp_server_custom.cc @@ -222,10 +222,10 @@ static void finish_accept(grpc_tcp_listener* sp, grpc_custom_socket* socket) { } if (grpc_tcp_trace.enabled()) { if (peer_name_string) { - gpr_log(GPR_DEBUG, "SERVER_CONNECT: %p accepted connection: %s", + gpr_log(GPR_INFO, "SERVER_CONNECT: %p accepted connection: %s", sp->server, peer_name_string); } else { - gpr_log(GPR_DEBUG, "SERVER_CONNECT: %p accepted connection", sp->server); + gpr_log(GPR_INFO, "SERVER_CONNECT: %p accepted connection", sp->server); } } ep = custom_tcp_endpoint_create(socket, sp->server->resource_quota, @@ -377,10 +377,10 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s, grpc_sockaddr_to_string(&port_string, addr, 0); const char* str = grpc_error_string(error); if (port_string) { - gpr_log(GPR_DEBUG, "SERVER %p add_port %s error=%s", s, port_string, str); + gpr_log(GPR_INFO, "SERVER %p add_port %s error=%s", s, port_string, str); gpr_free(port_string); } else { - gpr_log(GPR_DEBUG, "SERVER %p add_port error=%s", s, str); + gpr_log(GPR_INFO, "SERVER %p add_port error=%s", s, str); } } @@ -419,7 +419,7 @@ static void tcp_server_start(grpc_tcp_server* server, grpc_pollset** pollsets, (void)pollset_count; GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD(); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "SERVER_START %p", server); + gpr_log(GPR_INFO, "SERVER_START %p", server); } GPR_ASSERT(on_accept_cb); GPR_ASSERT(!server->on_accept_cb); diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index f11b82f7ab..524beba9ab 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -228,7 +228,7 @@ static void on_read(void* arg, grpc_error* err) { gpr_asprintf(&name, "tcp-server-connection:%s", addr_str); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "SERVER_CONNECT: incoming connection: %s", addr_str); + gpr_log(GPR_INFO, "SERVER_CONNECT: incoming connection: %s", addr_str); } grpc_fd* fdobj = grpc_fd_create(fd, name); diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 0c6f236f83..de2256f7cb 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -346,9 +346,9 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline, #endif if (grpc_timer_trace.enabled()) { - gpr_log(GPR_DEBUG, - "TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer, - deadline, grpc_core::ExecCtx::Get()->Now(), closure, closure->cb); + gpr_log(GPR_INFO, "TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", + timer, deadline, grpc_core::ExecCtx::Get()->Now(), closure, + closure->cb); } if (!g_shared_mutables.initialized) { @@ -382,7 +382,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline, list_join(&shard->list, timer); } if (grpc_timer_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, " .. add to shard %d with queue_deadline_cap=%" PRIdPTR " => is_first_timer=%s", static_cast(shard - g_shards), shard->queue_deadline_cap, @@ -404,7 +404,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline, if (is_first_timer) { gpr_mu_lock(&g_shared_mutables.mu); if (grpc_timer_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. old shard min_deadline=%" PRIdPTR, + gpr_log(GPR_INFO, " .. old shard min_deadline=%" PRIdPTR, shard->min_deadline); } if (deadline < shard->min_deadline) { @@ -434,7 +434,7 @@ static void timer_cancel(grpc_timer* timer) { timer_shard* shard = &g_shards[GPR_HASH_POINTER(timer, g_num_shards)]; gpr_mu_lock(&shard->mu); if (grpc_timer_trace.enabled()) { - gpr_log(GPR_DEBUG, "TIMER %p: CANCEL pending=%s", timer, + gpr_log(GPR_INFO, "TIMER %p: CANCEL pending=%s", timer, timer->pending ? "true" : "false"); } @@ -475,7 +475,7 @@ static int refill_heap(timer_shard* shard, gpr_atm now) { static_cast(deadline_delta * 1000.0)); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. shard[%d]->queue_deadline_cap --> %" PRIdPTR, + gpr_log(GPR_INFO, " .. shard[%d]->queue_deadline_cap --> %" PRIdPTR, static_cast(shard - g_shards), shard->queue_deadline_cap); } for (timer = shard->list.next; timer != &shard->list; timer = next) { @@ -483,7 +483,7 @@ static int refill_heap(timer_shard* shard, gpr_atm now) { if (timer->deadline < shard->queue_deadline_cap) { if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. add timer with deadline %" PRIdPTR " to heap", + gpr_log(GPR_INFO, " .. add timer with deadline %" PRIdPTR " to heap", timer->deadline); } list_remove(timer); @@ -500,7 +500,7 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) { grpc_timer* timer; for (;;) { if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. shard[%d]: heap_empty=%s", + gpr_log(GPR_INFO, " .. shard[%d]: heap_empty=%s", static_cast(shard - g_shards), grpc_timer_heap_is_empty(&shard->heap) ? "true" : "false"); } @@ -510,13 +510,13 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) { } timer = grpc_timer_heap_top(&shard->heap); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, " .. check top timer deadline=%" PRIdPTR " now=%" PRIdPTR, timer->deadline, now); } if (timer->deadline > now) return nullptr; if (grpc_timer_trace.enabled()) { - gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late via %s scheduler", + gpr_log(GPR_INFO, "TIMER %p: FIRE %" PRIdPTR "ms late via %s scheduler", timer, now - timer->deadline, timer->closure->scheduler->vtable->name); } @@ -540,7 +540,7 @@ static size_t pop_timers(timer_shard* shard, gpr_atm now, *new_min_deadline = compute_min_deadline(shard); gpr_mu_unlock(&shard->mu); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. shard[%d] popped %" PRIdPTR, + gpr_log(GPR_INFO, " .. shard[%d] popped %" PRIdPTR, static_cast(shard - g_shards), n); } return n; @@ -563,7 +563,7 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now, result = GRPC_TIMERS_CHECKED_AND_EMPTY; if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, " .. shard[%d]->min_deadline = %" PRIdPTR, + gpr_log(GPR_INFO, " .. shard[%d]->min_deadline = %" PRIdPTR, static_cast(g_shard_queue[0] - g_shards), g_shard_queue[0]->min_deadline); } @@ -580,7 +580,7 @@ static grpc_timer_check_result run_some_expired_timers(gpr_atm now, } if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, " .. result --> %d" ", shard[%d]->min_deadline %" PRIdPTR " --> %" PRIdPTR ", now=%" PRIdPTR, @@ -624,7 +624,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { *next = GPR_MIN(*next, min_timer); } if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "TIMER CHECK SKIP: now=%" PRIdPTR " min_timer=%" PRIdPTR, now, min_timer); } @@ -644,7 +644,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { } else { gpr_asprintf(&next_str, "%" PRIdPTR, *next); } - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "TIMER CHECK BEGIN: now=%" PRIdPTR " next=%s tls_min=%" PRIdPTR " glob_min=%" PRIdPTR, now, next_str, gpr_tls_get(&g_last_seen_min_timer), @@ -662,7 +662,7 @@ static grpc_timer_check_result timer_check(grpc_millis* next) { } else { gpr_asprintf(&next_str, "%" PRIdPTR, *next); } - gpr_log(GPR_DEBUG, "TIMER CHECK END: r=%d; next=%s", r, next_str); + gpr_log(GPR_INFO, "TIMER CHECK END: r=%d; next=%s", r, next_str); gpr_free(next_str); } return r; diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 94f288af27..35e7914568 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -82,7 +82,7 @@ static void start_timer_thread_and_unlock(void) { ++g_thread_count; gpr_mu_unlock(&g_mu); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "Spawn timer thread"); + gpr_log(GPR_INFO, "Spawn timer thread"); } completed_thread* ct = static_cast(gpr_malloc(sizeof(*ct))); @@ -108,7 +108,7 @@ static void run_some_timers() { // waiter so that the next deadline is not missed if (!g_has_timed_waiter) { if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "kick untimed waiter"); + gpr_log(GPR_INFO, "kick untimed waiter"); } gpr_cv_signal(&g_cv_wait); } @@ -116,7 +116,7 @@ static void run_some_timers() { } // without our lock, flush the exec_ctx if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "flush exec_ctx"); + gpr_log(GPR_INFO, "flush exec_ctx"); } grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(&g_mu); @@ -172,8 +172,7 @@ static bool wait_until(grpc_millis next) { if (grpc_timer_check_trace.enabled()) { grpc_millis wait_time = next - grpc_core::ExecCtx::Get()->Now(); - gpr_log(GPR_DEBUG, "sleep for a %" PRIdPTR " milliseconds", - wait_time); + gpr_log(GPR_INFO, "sleep for a %" PRIdPTR " milliseconds", wait_time); } } else { // g_timed_waiter == true && next >= g_timed_waiter_deadline next = GRPC_MILLIS_INF_FUTURE; @@ -181,14 +180,14 @@ static bool wait_until(grpc_millis next) { } if (grpc_timer_check_trace.enabled() && next == GRPC_MILLIS_INF_FUTURE) { - gpr_log(GPR_DEBUG, "sleep until kicked"); + gpr_log(GPR_INFO, "sleep until kicked"); } gpr_cv_wait(&g_cv_wait, &g_mu, grpc_millis_to_timespec(next, GPR_CLOCK_MONOTONIC)); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d", + gpr_log(GPR_INFO, "wait ended: was_timed:%d kicked:%d", my_timed_waiter_generation == g_timed_waiter_generation, g_kicked); } @@ -233,7 +232,7 @@ static void timer_main_loop() { Consequently, we can just sleep forever here and be happy at some saved wakeup cycles. */ if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "timers not checked: expect another thread to"); + gpr_log(GPR_INFO, "timers not checked: expect another thread to"); } next = GRPC_MILLIS_INF_FUTURE; /* fall through */ @@ -259,7 +258,7 @@ static void timer_thread_cleanup(completed_thread* ct) { g_completed_threads = ct; gpr_mu_unlock(&g_mu); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "End timer thread"); + gpr_log(GPR_INFO, "End timer thread"); } } @@ -301,18 +300,18 @@ void grpc_timer_manager_init(void) { static void stop_threads(void) { gpr_mu_lock(&g_mu); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "stop timer threads: threaded=%d", g_threaded); + gpr_log(GPR_INFO, "stop timer threads: threaded=%d", g_threaded); } if (g_threaded) { g_threaded = false; gpr_cv_broadcast(&g_cv_wait); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count); + gpr_log(GPR_INFO, "num timer threads: %d", g_thread_count); } while (g_thread_count > 0) { gpr_cv_wait(&g_cv_shutdown, &g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC)); if (grpc_timer_check_trace.enabled()) { - gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count); + gpr_log(GPR_INFO, "num timer threads: %d", g_thread_count); } gc_completed_threads(); } diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index 31b779e333..840b2e73bc 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -133,7 +133,7 @@ static void call_read_cb(secure_endpoint* ep, grpc_error* error) { for (i = 0; i < ep->read_buffer->count; i++) { char* data = grpc_dump_slice(ep->read_buffer->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "READ %p: %s", ep, data); + gpr_log(GPR_INFO, "READ %p: %s", ep, data); gpr_free(data); } } @@ -269,7 +269,7 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices, for (i = 0; i < slices->count; i++) { char* data = grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "WRITE %p: %s", ep, data); + gpr_log(GPR_INFO, "WRITE %p: %s", ep, data); gpr_free(data); } } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 9a9113643d..0a732bed83 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -747,10 +747,10 @@ static void get_final_status( status[i] = unpack_received_status(gpr_atm_acq_load(&call->status[i])); } if (grpc_call_error_trace.enabled()) { - gpr_log(GPR_DEBUG, "get_final_status %s", call->is_client ? "CLI" : "SVR"); + gpr_log(GPR_INFO, "get_final_status %s", call->is_client ? "CLI" : "SVR"); for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (status[i].is_set) { - gpr_log(GPR_DEBUG, " %d: %s", i, grpc_error_string(status[i].error)); + gpr_log(GPR_INFO, " %d: %s", i, grpc_error_string(status[i].error)); } } } diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index 8130535ddd..8e71f86989 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -47,7 +47,7 @@ grpc_millis BdpEstimator::CompletePing() { double bw = dt > 0 ? (static_cast(accumulator_) / dt) : 0; int start_inter_ping_delay = inter_ping_delay_; if (grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, + gpr_log(GPR_INFO, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64 " dt=%lf bw=%lfMbs bw_est=%lfMbs", name_, accumulator_, estimate_, dt, bw / 125000.0, @@ -58,7 +58,7 @@ grpc_millis BdpEstimator::CompletePing() { estimate_ = GPR_MAX(accumulator_, estimate_ * 2); bw_est_ = bw; if (grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, name_, + gpr_log(GPR_INFO, "bdp[%s]: estimate increased to %" PRId64, name_, estimate_); } inter_ping_delay_ /= 2; // if the ping estimate changes, @@ -75,7 +75,7 @@ grpc_millis BdpEstimator::CompletePing() { if (start_inter_ping_delay != inter_ping_delay_) { stable_estimate_count_ = 0; if (grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "bdp[%s]:update_inter_time to %dms", name_, + gpr_log(GPR_INFO, "bdp[%s]:update_inter_time to %dms", name_, inter_ping_delay_); } } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index e703af121c..ab13ae4be4 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -50,7 +50,7 @@ class BdpEstimator { // transport (but not necessarily started) void SchedulePing() { if (grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_, + gpr_log(GPR_INFO, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } GPR_ASSERT(ping_state_ == PingState::UNSCHEDULED); @@ -63,7 +63,7 @@ class BdpEstimator { // the ping is on the wire void StartPing() { if (grpc_bdp_estimator_trace.enabled()) { - gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_, + gpr_log(GPR_INFO, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } GPR_ASSERT(ping_state_ == PingState::SCHEDULED); diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index 0122e773ca..db6b6c0444 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -78,7 +78,7 @@ grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state cur = static_cast( gpr_atm_no_barrier_load(&tracker->current_state_atm)); if (grpc_connectivity_state_trace.enabled()) { - gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name, + gpr_log(GPR_INFO, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } return cur; @@ -89,7 +89,7 @@ grpc_connectivity_state grpc_connectivity_state_get( grpc_connectivity_state cur = static_cast( gpr_atm_no_barrier_load(&tracker->current_state_atm)); if (grpc_connectivity_state_trace.enabled()) { - gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name, + gpr_log(GPR_INFO, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } if (error != nullptr) { @@ -110,10 +110,10 @@ bool grpc_connectivity_state_notify_on_state_change( gpr_atm_no_barrier_load(&tracker->current_state_atm)); if (grpc_connectivity_state_trace.enabled()) { if (current == nullptr) { - gpr_log(GPR_DEBUG, "CONWATCH: %p %s: unsubscribe notify=%p", tracker, + gpr_log(GPR_INFO, "CONWATCH: %p %s: unsubscribe notify=%p", tracker, tracker->name, notify); } else { - gpr_log(GPR_DEBUG, "CONWATCH: %p %s: from %s [cur=%s] notify=%p", tracker, + gpr_log(GPR_INFO, "CONWATCH: %p %s: from %s [cur=%s] notify=%p", tracker, tracker->name, grpc_connectivity_state_name(*current), grpc_connectivity_state_name(cur), notify); } @@ -161,7 +161,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker, grpc_connectivity_state_watcher* w; if (grpc_connectivity_state_trace.enabled()) { const char* error_string = grpc_error_string(error); - gpr_log(GPR_DEBUG, "SET: %p %s: %s --> %s [%s] error=%p %s", tracker, + gpr_log(GPR_INFO, "SET: %p %s: %s --> %s [%s] error=%p %s", tracker, tracker->name, grpc_connectivity_state_name(cur), grpc_connectivity_state_name(state), reason, error, error_string); } @@ -187,8 +187,7 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker, *w->current = state; tracker->watchers = w->next; if (grpc_connectivity_state_trace.enabled()) { - gpr_log(GPR_DEBUG, "NOTIFY: %p %s: %p", tracker, tracker->name, - w->notify); + gpr_log(GPR_INFO, "NOTIFY: %p %s: %p", tracker, tracker->name, w->notify); } GRPC_CLOSURE_SCHED(w->notify, GRPC_ERROR_REF(tracker->current_error)); gpr_free(w); -- cgit v1.2.3 From 56c32ccb237afa349d1826e4379b0e32c8bc8a72 Mon Sep 17 00:00:00 2001 From: Hope Casey-Allen Date: Sun, 29 Apr 2018 20:28:37 -0700 Subject: Fix typos in GPR_TIMER_SCOPE --- src/core/lib/iomgr/tcp_posix.cc | 2 +- src/core/lib/surface/call.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index fc2b94d693..153be05e83 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -371,7 +371,7 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) { #define MAX_READ_IOVEC 4 static void tcp_do_read(grpc_tcp* tcp) { - GPR_TIMER_SCOPE("tcp_continue_read", 0); + GPR_TIMER_SCOPE("tcp_do_read", 0); struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; ssize_t read_bytes; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 0a732bed83..da488034ca 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -610,7 +610,7 @@ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) { // This is called via the call combiner to start sending a batch down // the filter stack. static void execute_batch_in_call_combiner(void* arg, grpc_error* ignored) { - GPR_TIMER_SCOPE("execute_batch", 0); + GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0); grpc_transport_stream_op_batch* batch = static_cast(arg); grpc_call* call = static_cast(batch->handler_private.extra_arg); @@ -1539,7 +1539,7 @@ static void free_no_op_completion(void* p, grpc_cq_completion* completion) { static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, size_t nops, void* notify_tag, int is_notify_tag_closure) { - GPR_TIMER_SCOPE("grpc_call_start_batch", 0); + GPR_TIMER_SCOPE("call_start_batch", 0); size_t i; const grpc_op* op; -- cgit v1.2.3 From 2d43a45ad1540f554d89503676d2db2bc25776db Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Wed, 2 May 2018 22:49:52 -0700 Subject: Regenerate projects --- CMakeLists.txt | 2 +- Makefile | 4 ++-- gRPC-C++.podspec | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.cc | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core/Version.csproj.include | 2 +- src/csharp/Grpc.Core/VersionInfo.cs | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/objective-c/tests/version.h | 2 +- src/php/composer.json | 2 +- src/php/ext/grpc/version.h | 2 +- src/python/grpcio/grpc/_grpcio_metadata.py | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_testing/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 30 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/core/lib/surface') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e64d2efbc..8db941239f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.12.0-dev") +set(PACKAGE_VERSION "1.13.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 76fa95b419..0b2024996d 100644 --- a/Makefile +++ b/Makefile @@ -421,8 +421,8 @@ Q = @ endif CORE_VERSION = 6.0.0-dev -CPP_VERSION = 1.12.0-dev -CSHARP_VERSION = 1.12.0-dev +CPP_VERSION = 1.13.0-dev +CSHARP_VERSION = 1.13.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 990b0a4f9d..f673dd69dc 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - # version = '1.12.0-dev' + # version = '1.13.0-dev' version = '0.0.2' s.version = version s.summary = 'gRPC C++ library' @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.license = 'Apache License, Version 2.0' s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } - grpc_version = '1.12.0-dev' + grpc_version = '1.13.0-dev' s.source = { :git => 'https://github.com/grpc/grpc.git', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index a1e0fd2ca1..49ad7ef6d6 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.12.0-dev' + version = '1.13.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index e98dee4a3c..17e650c264 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.12.0-dev' + version = '1.13.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 3bba14b695..b9288afd80 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.12.0-dev' + version = '1.13.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index bf73ffd22e..afc4581091 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.12.0-dev' + version = '1.13.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/package.xml b/package.xml index b9cb22b647..7dcfa302ae 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2018-01-19 - 1.12.0dev - 1.12.0dev + 1.13.0dev + 1.13.0dev beta diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index a712e10037..306b7c395e 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -25,4 +25,4 @@ const char* grpc_version_string(void) { return "6.0.0-dev"; } -const char* grpc_g_stands_for(void) { return "glorious"; } +const char* grpc_g_stands_for(void) { return "gloriosa"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index d669ea21a9..54cd2076ec 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include namespace grpc { -grpc::string Version() { return "1.12.0-dev"; } +grpc::string Version() { return "1.13.0-dev"; } } // namespace grpc diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include index 6e28c11df2..f5d63b77f0 100755 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ b/src/csharp/Grpc.Core/Version.csproj.include @@ -1,7 +1,7 @@ - 1.12.0-dev + 1.13.0-dev 3.5.1 diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 06a0396c34..87edddae3f 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -33,11 +33,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.12.0.0"; + public const string CurrentAssemblyFileVersion = "1.13.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.12.0-dev"; + public const string CurrentVersion = "1.13.0-dev"; } } diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 0d65748697..924d7b1697 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -13,7 +13,7 @@ @rem limitations under the License. @rem Current package versions -set VERSION=1.12.0-dev +set VERSION=1.13.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 66aba36089..5c73a8f95f 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -45,7 +45,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts -nuget pack Grpc.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.13.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.13.0-dev" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index f06312bea9..515dc917d1 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.12.0-dev' + v = '1.13.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 1298e7e191..6fe4a7d051 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.12.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.13.0-dev" diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index d36545fced..e9637099d9 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -22,5 +22,5 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.12.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.13.0-dev" #define GRPC_C_VERSION_STRING @"6.0.0-dev" diff --git a/src/php/composer.json b/src/php/composer.json index 57d911db79..03dffb40ab 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "Apache-2.0", - "version": "1.12.0", + "version": "1.13.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.3.0" diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h index 37df2768bf..407d6347e6 100644 --- a/src/php/ext/grpc/version.h +++ b/src/php/ext/grpc/version.h @@ -20,6 +20,6 @@ #ifndef VERSION_H #define VERSION_H -#define PHP_GRPC_VERSION "1.12.0dev" +#define PHP_GRPC_VERSION "1.13.0dev" #endif /* VERSION_H */ diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py index cb5da72f1f..ad53f60ad3 100644 --- a/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/src/python/grpcio/grpc/_grpcio_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! -__version__ = """1.12.0.dev0""" +__version__ = """1.13.0.dev0""" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index de5a780abd..57dc26dbeb 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index afcd316e5c..ba0d4a3b6d 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 824b73201d..ea2878d9ee 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py index 5b1f4c4cc0..02f19f2283 100644 --- a/src/python/grpcio_testing/grpc_version.py +++ b/src/python/grpcio_testing/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 382f95018e..9d2e41644e 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 2cb7c4be53..15f375100a 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -14,5 +14,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.12.0.dev' + VERSION = '1.13.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 822f70eb0a..09d5c82674 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -14,6 +14,6 @@ module GRPC module Tools - VERSION = '1.12.0.dev' + VERSION = '1.13.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index e71f836f6d..f0367e2af4 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION = '1.12.0.dev0' +VERSION = '1.13.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 22f225ec54..884eabb956 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.12.0-dev +PROJECT_NUMBER = 1.13.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 63d238d741..66796bae57 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.12.0-dev +PROJECT_NUMBER = 1.13.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From ead686dd100457f085ea73802282b12c351a3c5e Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 4 May 2018 15:21:24 -0700 Subject: Remove redundant ExecCtx --- src/core/lib/surface/completion_queue.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core/lib/surface') diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index d0363917b0..f751741712 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -390,7 +390,6 @@ static bool cq_event_queue_push(grpc_cq_event_queue* q, grpc_cq_completion* c) { static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) { grpc_cq_completion* c = nullptr; - grpc_core::ExecCtx exec_ctx; if (gpr_spinlock_trylock(&q->queue_lock)) { GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES(); -- cgit v1.2.3