From 0900584543f676474355643dc0282cbfdf1cbcb2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 24 Aug 2023 19:40:05 -0700 Subject: [PATCH] [logging-filter] Work around bug in promise_based_filter destruction (#34163) Fixes internal b/297030898. This ought not be necessary, but getting context from the promise based filter wrapper code at call destruction is unwieldy. Hacking around it here and fixing it properly post client rollout seems wiser. --- src/core/ext/filters/logging/logging_filter.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/logging/logging_filter.cc b/src/core/ext/filters/logging/logging_filter.cc index 561e4718ab3..db02366fee5 100644 --- a/src/core/ext/filters/logging/logging_filter.cc +++ b/src/core/ext/filters/logging/logging_filter.cc @@ -433,13 +433,15 @@ class ClientLoggingFilter final : public ChannelFilter { md.get()); return md; }), - [calld]() { + // TODO(yashykt/ctiller): GetContext is not + // valid for the cancellation function requiring us to capture it here. + // This ought to be easy to fix once client side promises are completely + // rolled out. + [calld, ctx = GetContext()]() { calld->LogCancel( /*is_client=*/true, static_cast( - GetContext() - [GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE] - .value)); + ctx[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value)); }); }