Add chttp2 trace

pull/10833/head
ncteisen 8 years ago
parent d39010e68a
commit ffe7209279
  1. 3
      src/core/ext/transport/chttp2/transport/chttp2_plugin.c
  2. 20
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  3. 4
      src/core/ext/transport/chttp2/transport/chttp2_transport.h
  4. 3
      src/core/ext/transport/chttp2/transport/internal.h

@ -23,6 +23,9 @@
void grpc_chttp2_plugin_init(void) { void grpc_chttp2_plugin_init(void) {
grpc_register_tracer("http", &grpc_http_trace); grpc_register_tracer("http", &grpc_http_trace);
grpc_register_tracer("flowctl", &grpc_flowctl_trace); grpc_register_tracer("flowctl", &grpc_flowctl_trace);
#ifndef NDEBUG
grpc_register_tracer("chttp2_refcount", &grpc_trace_chttp2_refcount);
#endif
} }
void grpc_chttp2_plugin_shutdown(void) {} void grpc_chttp2_plugin_shutdown(void) {}

@ -76,6 +76,10 @@ static bool g_default_keepalive_permit_without_calls =
grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_http_trace = GRPC_TRACER_INITIALIZER(false);
grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_flowctl_trace = GRPC_TRACER_INITIALIZER(false);
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_chttp2_refcount = GRPC_TRACER_INITIALIZER(false);
#endif
static const grpc_transport_vtable vtable; static const grpc_transport_vtable vtable;
/* forward declarations of various callbacks that we'll build closures around */ /* forward declarations of various callbacks that we'll build closures around */
@ -212,20 +216,26 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
gpr_free(t); gpr_free(t);
} }
#ifdef GRPC_CHTTP2_REFCOUNTING_DEBUG #ifndef NDEBUG
void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx, void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t, const char *reason, grpc_chttp2_transport *t, const char *reason,
const char *file, int line) { const char *file, int line) {
gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]", t, if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) {
t->refs.count, t->refs.count - 1, reason, file, line); 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);
}
if (!gpr_unref(&t->refs)) return; if (!gpr_unref(&t->refs)) return;
destruct_transport(exec_ctx, t); destruct_transport(exec_ctx, t);
} }
void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason, void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
const char *file, int line) { const char *file, int line) {
gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]", t, if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) {
t->refs.count, t->refs.count + 1, reason, file, line); 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);
}
gpr_ref(&t->refs); gpr_ref(&t->refs);
} }
#else #else

@ -26,6 +26,10 @@
extern grpc_tracer_flag grpc_http_trace; extern grpc_tracer_flag grpc_http_trace;
extern grpc_tracer_flag grpc_flowctl_trace; extern grpc_tracer_flag grpc_flowctl_trace;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_chttp2_refcount;
#endif
grpc_transport *grpc_create_chttp2_transport( grpc_transport *grpc_create_chttp2_transport(
grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args, grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
grpc_endpoint *ep, int is_client); grpc_endpoint *ep, int is_client);

@ -764,8 +764,7 @@ void grpc_chttp2_stream_ref(grpc_chttp2_stream *s);
void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s); void grpc_chttp2_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s);
#endif #endif
//#define GRPC_CHTTP2_REFCOUNTING_DEBUG 1 #ifndef NDEBUG
#ifdef GRPC_CHTTP2_REFCOUNTING_DEBUG
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ #define GRPC_CHTTP2_REF_TRANSPORT(t, r) \
grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__)
#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) \ #define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) \

Loading…
Cancel
Save