diff options
author | ncteisen <ncteisen@gmail.com> | 2017-06-08 16:44:38 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-06-08 17:50:02 -0700 |
commit | 4b584054b9cba502adbfb13b36bd22edee5019ae (patch) | |
tree | 3878b88829f4ee4c1bba220958a4eca87a5b4c98 /src/core/lib/security/context | |
parent | 0e3aee3dff24f6db5d76d553bc137d64132fa316 (diff) |
Add metadata, secendp, sec conn tracers
Diffstat (limited to 'src/core/lib/security/context')
-rw-r--r-- | src/core/lib/security/context/security_context.c | 26 | ||||
-rw-r--r-- | src/core/lib/security/context/security_context.h | 6 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/core/lib/security/context/security_context.c b/src/core/lib/security/context/security_context.c index e528428650..9d95d48057 100644 --- a/src/core/lib/security/context/security_context.c +++ b/src/core/lib/security/context/security_context.c @@ -28,6 +28,10 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#ifndef NDEBUG +grpc_tracer_flag grpc_trace_auth_context_refcount = GRPC_TRACER_INITIALIZER(false); +#endif + /* --- grpc_call --- */ grpc_call_error grpc_call_set_credentials(grpc_call *call, @@ -121,14 +125,17 @@ grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) { return ctx; } -#ifdef GRPC_AUTH_CONTEXT_REFCOUNT_DEBUG +#ifndef NDEBUG grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx, const char *file, int line, const char *reason) { if (ctx == NULL) return NULL; - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "AUTH_CONTEXT:%p ref %d -> %d %s", ctx, (int)ctx->refcount.count, - (int)ctx->refcount.count + 1, reason); + if (GRPC_TRACER_ON(grpc_trace_auth_context_refcount)) { + gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "AUTH_CONTEXT:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", ctx, val, + val + 1, reason); + } #else grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx) { if (ctx == NULL) return NULL; @@ -137,13 +144,16 @@ grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx) { return ctx; } -#ifdef GRPC_AUTH_CONTEXT_REFCOUNT_DEBUG +#ifndef NDEBUG void grpc_auth_context_unref(grpc_auth_context *ctx, const char *file, int line, const char *reason) { if (ctx == NULL) return; - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "AUTH_CONTEXT:%p unref %d -> %d %s", ctx, (int)ctx->refcount.count, - (int)ctx->refcount.count - 1, reason); + if (GRPC_TRACER_ON(grpc_trace_auth_context_refcount)) { + gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "AUTH_CONTEXT:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", ctx, val, + val - 1, reason); + } #else void grpc_auth_context_unref(grpc_auth_context *ctx) { if (ctx == NULL) return; diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index 102f9d6e2f..0df39257a7 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -22,6 +22,10 @@ #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/security/credentials/credentials.h" +#ifndef NDEBUG +extern grpc_tracer_flag grpc_trace_auth_context_refcount; +#endif + #ifdef __cplusplus extern "C" { #endif @@ -50,7 +54,7 @@ struct grpc_auth_context { grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained); /* Refcounting. */ -#ifdef GRPC_AUTH_CONTEXT_REFCOUNT_DEBUG +#ifndef NDEBUG #define GRPC_AUTH_CONTEXT_REF(p, r) \ grpc_auth_context_ref((p), __FILE__, __LINE__, (r)) #define GRPC_AUTH_CONTEXT_UNREF(p, r) \ |