From fad045004d5576a3f2d32f6d27b0fc285ff589d0 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 29 Apr 2016 16:43:46 -0700 Subject: [PATCH] debug logging fix --- src/core/ext/lb_policy/round_robin/round_robin.c | 6 ++++-- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 3 ++- src/core/ext/transport/chttp2/transport/hpack_encoder.c | 6 +++++- src/core/ext/transport/chttp2/transport/hpack_table.c | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/core/ext/lb_policy/round_robin/round_robin.c b/src/core/ext/lb_policy/round_robin/round_robin.c index 3f6051b8925..dcdc0c62857 100644 --- a/src/core/ext/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/lb_policy/round_robin/round_robin.c @@ -306,8 +306,10 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) { size_t i; p->started_picking = 1; - gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%d", p, - p->num_subchannels); + if (grpc_lb_round_robin_trace) { + gpr_log(GPR_DEBUG, "LB_POLICY: p=%p num_subchannels=%d", p, + p->num_subchannels); + } for (i = 0; i < p->num_subchannels; i++) { subchannel_data *sd = p->subchannels[i]; diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index fcf2abfe66e..02ad0c0370a 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -776,7 +776,8 @@ void grpc_chttp2_add_incoming_goaway( grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, uint32_t goaway_error, gpr_slice goaway_text) { char *msg = gpr_dump_slice(goaway_text, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg); + GRPC_CHTTP2_IF_TRACING(gpr_log( + GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg)); gpr_free(msg); gpr_slice_unref(goaway_text); transport_global->seen_goaway = 1; diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index 555027c8660..ebeee37f0d9 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -63,6 +63,8 @@ /* don't consider adding anything bigger than this to the hpack table */ #define MAX_DECODER_SPACE_USAGE 512 +extern int grpc_http_trace; + typedef struct { int is_first_frame; /* number of bytes in 'output' when we started the frame - used to calculate @@ -532,7 +534,9 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( } } c->advertise_table_size_change = 1; - gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size); + if (grpc_http_trace) { + gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size); + } } void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.c b/src/core/ext/transport/chttp2/transport/hpack_table.c index 4d64506de29..295f31c44f2 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.c +++ b/src/core/ext/transport/chttp2/transport/hpack_table.c @@ -253,7 +253,9 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl, if (tbl->max_bytes == max_bytes) { return; } - gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes); + if (grpc_http_trace) { + gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes); + } while (tbl->mem_used > max_bytes) { evict1(tbl); }