diff options
author | Mark D. Roth <roth@google.com> | 2017-11-20 12:35:02 -0800 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2017-11-20 12:35:02 -0800 |
commit | da6b4790e5e34958d444ee12f3eefcc2dac464a9 (patch) | |
tree | 60e22bbd5b44c1247b10188a62fbaf7a4320d9f2 /src/core/ext/transport | |
parent | e36d9eaa2c6ba687a1fb0909b3d87b8c332a249c (diff) | |
parent | c567ceb01af2ccfc4bd631c0c1247767732c67a1 (diff) |
Merge remote-tracking branch 'upstream/master' into server_connection_timeout
Diffstat (limited to 'src/core/ext/transport')
17 files changed, 64 insertions, 85 deletions
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index ac9ae5c395..2569347def 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -20,13 +20,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/transport/metadata.h" -extern "C" void grpc_chttp2_plugin_init(void) { - grpc_register_tracer(&grpc_http_trace); - grpc_register_tracer(&grpc_flowctl_trace); - grpc_register_tracer(&grpc_trace_http2_stream_state); -#ifndef NDEBUG - grpc_register_tracer(&grpc_trace_chttp2_refcount); -#endif -} +extern "C" void grpc_chttp2_plugin_init(void) {} extern "C" void grpc_chttp2_plugin_shutdown(void) {} diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index ab2c768911..635034db61 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -90,13 +90,9 @@ static int g_default_max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA; static int g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES; #define MAX_CLIENT_STREAM_ID 0x7fffffffu -grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false, "http"); -grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false, "flowctl"); - -#ifndef NDEBUG -grpc_tracer_flag grpc_trace_chttp2_refcount = - GRPC_TRACER_INITIALIZER(false, "chttp2_refcount"); -#endif +grpc_core::TraceFlag grpc_http_trace(false, "http"); +grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false, + "chttp2_refcount"); /* forward declarations of various callbacks that we'll build closures around */ static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* t, @@ -235,7 +231,7 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx, void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, const char* reason, const char* file, int line) { - if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) { + if (grpc_trace_chttp2_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count); gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]", t, val, val - 1, reason, file, line); @@ -246,7 +242,7 @@ void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx, void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason, const char* file, int line) { - if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) { + if (grpc_trace_chttp2_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count); gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]", t, val, val + 1, reason, file, line); @@ -1237,7 +1233,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx, return; } closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT; - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { const char* errstr = grpc_error_string(error); gpr_log( GPR_DEBUG, @@ -1396,7 +1392,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op, GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx); - if (GRPC_TRACER_ON(grpc_http_trace)) { + 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, op->on_complete); @@ -1686,7 +1682,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, } } - if (GRPC_TRACER_ON(grpc_http_trace)) { + 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_free(str); @@ -2598,7 +2594,7 @@ static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx, static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp, grpc_error* error) { grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp; - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string, grpc_error_string(error)); } @@ -2612,7 +2608,7 @@ static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp, static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp, grpc_error* error) { grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp; - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string, grpc_error_string(error)); } @@ -3113,7 +3109,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_chttp2_stream_map_size(&t->stream_map) == 0) { /* Channel with no active streams: send a goaway to try and make it * disconnect cleanly */ - if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { + if (grpc_resource_quota_trace.enabled()) { gpr_log(GPR_DEBUG, "HTTP2: %s - send goaway to free memory", t->peer_string); } @@ -3121,8 +3117,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error_set_int( 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_TRACER_ON(grpc_resource_quota_trace)) { + } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) { gpr_log(GPR_DEBUG, "HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR " streams", @@ -3144,7 +3139,7 @@ static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg, if (error == GRPC_ERROR_NONE && n > 0) { grpc_chttp2_stream* s = (grpc_chttp2_stream*)grpc_chttp2_stream_map_rand(&t->stream_map); - if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { + if (grpc_resource_quota_trace.enabled()) { gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string, s->id); } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index a349e00498..198523d59a 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -23,18 +23,14 @@ #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/transport/transport.h" +extern grpc_core::TraceFlag grpc_http_trace; +extern grpc_core::TraceFlag grpc_trace_http2_stream_state; +extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount; + #ifdef __cplusplus extern "C" { #endif -extern grpc_tracer_flag grpc_http_trace; -extern grpc_tracer_flag grpc_flowctl_trace; -extern grpc_tracer_flag grpc_trace_http2_stream_state; - -#ifndef NDEBUG -extern grpc_tracer_flag grpc_trace_chttp2_refcount; -#endif - grpc_transport* grpc_create_chttp2_transport( grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client); diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index 64f6b3c917..8a057bd9ff 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -31,6 +31,8 @@ #include "src/core/ext/transport/chttp2/transport/internal.h" #include "src/core/lib/support/string.h" +grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl"); + namespace grpc_core { namespace chttp2 { @@ -312,7 +314,9 @@ double TransportFlowControl::SmoothLogBdp(grpc_exec_ctx* exec_ctx, double bdp_error = value - pid_controller_.last_control_value(); const double dt = (double)(now - last_pid_update_) * 1e-3; last_pid_update_ = now; - return pid_controller_.Update(bdp_error, dt); + // Limit dt to 100ms + const double kMaxDt = 0.1; + return pid_controller_.Update(bdp_error, dt > kMaxDt ? kMaxDt : dt); } FlowControlAction::Urgency TransportFlowControl::DeltaUrgency( diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h index 7dd348ed5f..bb710fef83 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/src/core/ext/transport/chttp2/transport/flow_control.h @@ -30,7 +30,7 @@ struct grpc_chttp2_transport; struct grpc_chttp2_stream; -extern "C" grpc_tracer_flag grpc_flowctl_trace; +extern grpc_core::TraceFlag grpc_flowctl_trace; namespace grpc { namespace testing { @@ -118,7 +118,7 @@ class FlowControlTrace { StreamFlowControl* sfc); void Finish(); - const bool enabled_ = GRPC_TRACER_ON(grpc_flowctl_trace); + const bool enabled_ = grpc_flowctl_trace.enabled(); TransportFlowControl* tfc_; StreamFlowControl* sfc_; diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index a1da607516..de4340fea5 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -209,20 +209,19 @@ grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx, void* p, parser->incoming_settings[id] != parser->value) { t->initial_window_update += (int64_t)parser->value - parser->incoming_settings[id]; - if (GRPC_TRACER_ON(grpc_http_trace) || - GRPC_TRACER_ON(grpc_flowctl_trace)) { + 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", (int)t->initial_window_update); } } parser->incoming_settings[id] = parser->value; - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %s = %d", t->is_client ? "CLI" : "SVR", t->peer_string, sp->name, parser->value); } - } else if (GRPC_TRACER_ON(grpc_http_trace)) { + } else if (grpc_http_trace.enabled()) { gpr_log(GPR_ERROR, "CHTTP2: Ignoring unknown setting %d (value %d)", parser->id, 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 e6e4ff24a3..e76d92e31d 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -57,8 +57,6 @@ static const grpc_slice terminal_slice = { {{nullptr, 0}} /* data.refcounted */ }; -extern "C" grpc_tracer_flag grpc_http_trace; - typedef struct { int is_first_frame; /* number of bytes in 'output' when we started the frame - used to calculate @@ -475,7 +473,7 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c, "Reserved header (colon-prefixed) happening after regular ones."); } - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem)); char* v = nullptr; if (grpc_is_binary_header(GRPC_MDKEY(elem))) { @@ -669,7 +667,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( } } c->advertise_table_size_change = 1; - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size); } } diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index fd01d1621a..96d8e99dd0 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -34,6 +34,8 @@ /* maximum table size we'll actually use */ #define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024) +extern grpc_core::TraceFlag grpc_http_trace; + #ifdef __cplusplus extern "C" { #endif diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 960610eee0..18cb27f199 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -651,7 +651,7 @@ static const uint8_t inverse_base64[256] = { /* emission helpers */ static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, grpc_mdelem md, int add_to_table) { - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { char* k = grpc_slice_to_c_string(GRPC_MDKEY(md)); char* v = nullptr; if (grpc_is_binary_header(GRPC_MDKEY(md))) { @@ -1047,7 +1047,7 @@ static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx, static grpc_error* finish_max_tbl_size(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) { - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index); } grpc_error* err = diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 7970d2ae27..75b83b80b6 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -28,7 +28,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/support/murmur_hash.h" -extern "C" grpc_tracer_flag grpc_http_trace; +extern grpc_core::TraceFlag grpc_http_trace; static struct { const char* key; @@ -246,7 +246,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx, if (tbl->max_bytes == max_bytes) { return; } - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes); } while (tbl->mem_used > max_bytes) { @@ -270,7 +270,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx, gpr_free(msg); return err; } - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes); } while (tbl->mem_used > bytes) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index aafbfddf2a..e939445684 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -676,13 +676,13 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx, #define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) -extern grpc_tracer_flag grpc_http_trace; -extern grpc_tracer_flag grpc_flowctl_trace; +// extern grpc_core::TraceFlag grpc_http_trace; +// extern grpc_core::TraceFlag grpc_flowctl_trace; -#define GRPC_CHTTP2_IF_TRACING(stmt) \ - if (!(GRPC_TRACER_ON(grpc_http_trace))) \ - ; \ - else \ +#define GRPC_CHTTP2_IF_TRACING(stmt) \ + if (!(grpc_http_trace.enabled())) \ + ; \ + else \ stmt void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 5f07dec8e8..46ec3fbaa6 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -312,7 +312,7 @@ static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx, case GRPC_CHTTP2_FRAME_GOAWAY: return init_goaway_parser(exec_ctx, t); default: - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { gpr_log(GPR_ERROR, "Unknown frame type %02x", t->incoming_frame_type); } return init_skip_frame_parser(exec_ctx, t, 0); @@ -417,7 +417,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp, GPR_ASSERT(s != nullptr); - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); char* value = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -501,7 +501,7 @@ static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp, GPR_ASSERT(s != nullptr); - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); char* value = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -758,7 +758,7 @@ static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx, if (err == GRPC_ERROR_NONE) { return err; } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) { - if (GRPC_TRACER_ON(grpc_http_trace)) { + if (grpc_http_trace.enabled()) { const char* msg = grpc_error_string(err); gpr_log(GPR_ERROR, "%s", msg); } diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc index d92527f05c..c95d02541a 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -39,8 +39,7 @@ static const char* stream_list_id_string(grpc_chttp2_stream_list_id id) { GPR_UNREACHABLE_CODE(return "unknown"); } -grpc_tracer_flag grpc_trace_http2_stream_state = - GRPC_TRACER_INITIALIZER(false, "http2_stream_state"); +grpc_core::TraceFlag grpc_trace_http2_stream_state(false, "http2_stream_state"); /* core list management */ @@ -66,7 +65,7 @@ static bool stream_list_pop(grpc_chttp2_transport* t, s->included[id] = 0; } *stream = s; - if (s && GRPC_TRACER_ON(grpc_trace_http2_stream_state)) { + if (s && grpc_trace_http2_stream_state.enabled()) { gpr_log(GPR_DEBUG, "%p[%d][%s]: pop from %s", t, s->id, t->is_client ? "cli" : "svr", stream_list_id_string(id)); } @@ -88,7 +87,7 @@ static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s, } else { t->lists[id].tail = s->links[id].prev; } - if (GRPC_TRACER_ON(grpc_trace_http2_stream_state)) { + if (grpc_trace_http2_stream_state.enabled()) { gpr_log(GPR_DEBUG, "%p[%d][%s]: remove from %s", t, s->id, t->is_client ? "cli" : "svr", stream_list_id_string(id)); } @@ -120,7 +119,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t, } t->lists[id].tail = s; s->included[id] = 1; - if (GRPC_TRACER_ON(grpc_trace_http2_stream_state)) { + if (grpc_trace_http2_stream_state.enabled()) { gpr_log(GPR_DEBUG, "%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 61a2598618..15869b8880 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -51,8 +51,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx, } if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { /* ping already in-flight: wait */ - if (GRPC_TRACER_ON(grpc_http_trace) || - GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: already pinging", t->is_client ? "CLIENT" : "SERVER", t->peer_string); } @@ -61,8 +60,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx, if (t->ping_state.pings_before_data_required == 0 && t->ping_policy.max_pings_without_data != 0) { /* need to receive something of substance before sending a ping again */ - if (GRPC_TRACER_ON(grpc_http_trace) || - GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%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, @@ -81,8 +79,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx, } if (next_allowed_ping > now) { /* not enough elapsed time between successive pings */ - if (GRPC_TRACER_ON(grpc_http_trace) || - GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: not enough time elapsed since last ping", t->is_client ? "CLIENT" : "SERVER", t->peer_string); @@ -103,8 +100,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_ping_create(false, pq->inflight_id)); GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx); t->ping_state.last_ping_sent_time = now; - if (GRPC_TRACER_ON(grpc_http_trace) || - GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d", t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, @@ -322,7 +318,7 @@ class DataSendContext { GPR_MIN(stream_remote_window(), t_->flow_control->remote_window())); } - bool AnyOutgoing() const { return max_outgoing() != 0; } + bool AnyOutgoing() const { return max_outgoing() > 0; } void FlushCompressedBytes() { uint32_t send_bytes = diff --git a/src/core/ext/transport/inproc/inproc_plugin.cc b/src/core/ext/transport/inproc/inproc_plugin.cc index 5d8a1c74ab..2526dbfa06 100644 --- a/src/core/ext/transport/inproc/inproc_plugin.cc +++ b/src/core/ext/transport/inproc/inproc_plugin.cc @@ -19,12 +19,9 @@ #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/debug/trace.h" -grpc_tracer_flag grpc_inproc_trace = GRPC_TRACER_INITIALIZER(false, "inproc"); +grpc_core::TraceFlag grpc_inproc_trace(false, "inproc"); -extern "C" void grpc_inproc_plugin_init(void) { - grpc_register_tracer(&grpc_inproc_trace); - grpc_inproc_transport_init(); -} +extern "C" void grpc_inproc_plugin_init(void) { grpc_inproc_transport_init(); } extern "C" void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 7ea08b05bb..2579060811 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -32,9 +32,9 @@ #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/transport_impl.h" -#define INPROC_LOG(...) \ - do { \ - if (GRPC_TRACER_ON(grpc_inproc_trace)) gpr_log(__VA_ARGS__); \ +#define INPROC_LOG(...) \ + do { \ + if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \ } while (0) static grpc_slice g_empty_slice; @@ -199,7 +199,7 @@ static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s, const grpc_metadata_batch* metadata, uint32_t flags, grpc_metadata_batch* out_md, uint32_t* outflags, bool* markfilled) { - if (GRPC_TRACER_ON(grpc_inproc_trace)) { + if (grpc_inproc_trace.enabled()) { log_metadata(metadata, s->t->is_client, outflags != nullptr); } @@ -873,7 +873,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed gpr_mu_lock(mu); - if (GRPC_TRACER_ON(grpc_inproc_trace)) { + if (grpc_inproc_trace.enabled()) { if (op->send_initial_metadata) { log_metadata(op->payload->send_initial_metadata.send_initial_metadata, s->t->is_client, true); diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h index 6e83af3b4c..f27789a50d 100644 --- a/src/core/ext/transport/inproc/inproc_transport.h +++ b/src/core/ext/transport/inproc/inproc_transport.h @@ -29,7 +29,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, grpc_channel_args* args, void* reserved); -extern grpc_tracer_flag grpc_inproc_trace; +extern grpc_core::TraceFlag grpc_inproc_trace; void grpc_inproc_transport_init(void); void grpc_inproc_transport_shutdown(void); |