diff options
Diffstat (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc')
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc index 18ef1f6ff5..cc259bcdbf 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc @@ -35,9 +35,10 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem, static void destroy_channel_elem(grpc_channel_element* elem) {} namespace { + struct call_data { // Stats object to update. - grpc_grpclb_client_stats* client_stats; + grpc_core::RefCountedPtr<grpc_core::GrpcLbClientStats> client_stats; // State for intercepting send_initial_metadata. grpc_closure on_complete_for_send; grpc_closure* original_on_complete_for_send; @@ -47,6 +48,7 @@ struct call_data { grpc_closure* original_recv_initial_metadata_ready; bool recv_initial_metadata_succeeded; }; + } // namespace static void on_complete_for_send(void* arg, grpc_error* error) { @@ -72,11 +74,11 @@ static grpc_error* init_call_elem(grpc_call_element* elem, // Get stats object from context and take a ref. GPR_ASSERT(args->context != nullptr); if (args->context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) { - calld->client_stats = - grpc_grpclb_client_stats_ref(static_cast<grpc_grpclb_client_stats*>( - args->context[GRPC_GRPCLB_CLIENT_STATS].value)); + calld->client_stats = static_cast<grpc_core::GrpcLbClientStats*>( + args->context[GRPC_GRPCLB_CLIENT_STATS].value) + ->Ref(); // Record call started. - grpc_grpclb_client_stats_add_call_started(calld->client_stats); + calld->client_stats->AddCallStarted(); } return GRPC_ERROR_NONE; } @@ -88,12 +90,12 @@ static void destroy_call_elem(grpc_call_element* elem, if (calld->client_stats != nullptr) { // Record call finished, optionally setting client_failed_to_send and // received. - grpc_grpclb_client_stats_add_call_finished( + calld->client_stats->AddCallFinished( !calld->send_initial_metadata_succeeded /* client_failed_to_send */, - calld->recv_initial_metadata_succeeded /* known_received */, - calld->client_stats); + calld->recv_initial_metadata_succeeded /* known_received */); // All done, so unref the stats object. - grpc_grpclb_client_stats_unref(calld->client_stats); + // TODO(roth): Eliminate this once filter stack is converted to C++. + calld->client_stats.reset(); } } |