From 06ef5893f87e1bb826d772fd694c6821ecbadb49 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 21 Sep 2021 14:45:49 -0700 Subject: [PATCH] Metadata: replace usage of grpc_metadata_batch_remove with Remove method (#27420) --- src/core/ext/filters/client_channel/retry_filter.cc | 4 ++-- .../ext/filters/http/client/http_client_filter.cc | 6 +++--- .../http/message_compress/message_compress_filter.cc | 3 +-- .../ext/filters/http/server/http_server_filter.cc | 12 ++++++------ src/core/lib/surface/call.cc | 12 ++++++------ src/core/lib/surface/server.cc | 5 ++--- src/cpp/ext/filters/census/client_filter.cc | 3 +-- src/cpp/ext/filters/census/server_filter.cc | 4 ++-- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/core/ext/filters/client_channel/retry_filter.cc b/src/core/ext/filters/client_channel/retry_filter.cc index f740524e461..bd3c9aff1f9 100644 --- a/src/core/ext/filters/client_channel/retry_filter.cc +++ b/src/core/ext/filters/client_channel/retry_filter.cc @@ -1917,8 +1917,8 @@ void RetryFilter::CallData::CallAttempt::BatchData:: call_attempt_->send_initial_metadata_storage_); if (GPR_UNLIKELY(call_attempt_->send_initial_metadata_.legacy_index() ->named.grpc_previous_rpc_attempts != nullptr)) { - grpc_metadata_batch_remove(&call_attempt_->send_initial_metadata_, - GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS); + call_attempt_->send_initial_metadata_.Remove( + GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS); } if (GPR_UNLIKELY(calld->num_attempts_completed_ > 0)) { grpc_mdelem retry_md = grpc_mdelem_create( diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 384637fb9cf..207081cac25 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -120,7 +120,7 @@ static grpc_error_handle client_filter_incoming_metadata( if (b->legacy_index()->named.grpc_status != nullptr || grpc_mdelem_static_value_eq(b->legacy_index()->named.status->md, GRPC_MDELEM_STATUS_200)) { - grpc_metadata_batch_remove(b, GRPC_BATCH_STATUS); + b->Remove(GRPC_BATCH_STATUS); } else { char* val = grpc_dump_slice( GRPC_MDVALUE(b->legacy_index()->named.status->md), GPR_DUMP_ASCII); @@ -184,7 +184,7 @@ static grpc_error_handle client_filter_incoming_metadata( gpr_free(val); } } - grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_TYPE); + b->Remove(GRPC_BATCH_CONTENT_TYPE); } return GRPC_ERROR_NONE; @@ -361,7 +361,7 @@ static grpc_error_handle update_path_for_get( static void remove_if_present(grpc_metadata_batch* batch, grpc_metadata_batch_callouts_index idx) { - grpc_metadata_batch_remove(batch, idx); + batch->Remove(idx); } static void http_client_start_transport_stream_op_batch( diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index d63a6060c64..478fb96f4d8 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -204,8 +204,7 @@ grpc_compression_algorithm FindCompressionAlgorithm( &compression_algorithm)); // Remove this metadata since it's an internal one (i.e., it won't be // transmitted out). - grpc_metadata_batch_remove(initial_metadata, - GRPC_BATCH_GRPC_INTERNAL_ENCODING_REQUEST); + initial_metadata->Remove(GRPC_BATCH_GRPC_INTERNAL_ENCODING_REQUEST); // Check if that algorithm is enabled. Note that GRPC_COMPRESS_NONE is always // enabled. // TODO(juanlishen): Maybe use channel default or abort() if the algorithm diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index ed612457206..5d0e0c4d665 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -185,7 +185,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->legacy_index()->named.method->md)); } - grpc_metadata_batch_remove(b, GRPC_BATCH_METHOD); + b->Remove(GRPC_BATCH_METHOD); } else { hs_add_error( error_name, &error, @@ -202,7 +202,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->legacy_index()->named.te->md)); } - grpc_metadata_batch_remove(b, GRPC_BATCH_TE); + b->Remove(GRPC_BATCH_TE); } else { hs_add_error(error_name, &error, grpc_error_set_str( @@ -222,7 +222,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), b->legacy_index()->named.scheme->md)); } - grpc_metadata_batch_remove(b, GRPC_BATCH_SCHEME); + b->Remove(GRPC_BATCH_SCHEME); } else { hs_add_error( error_name, &error, @@ -261,7 +261,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, gpr_free(val); } } - grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_TYPE); + b->Remove(GRPC_BATCH_CONTENT_TYPE); } if (b->legacy_index()->named.path == nullptr) { @@ -316,7 +316,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, b->legacy_index()->named.authority == nullptr) { grpc_linked_mdelem* el = b->legacy_index()->named.host; grpc_mdelem md = GRPC_MDELEM_REF(el->md); - grpc_metadata_batch_remove(b, el); + b->Remove(el); hs_add_error( error_name, &error, grpc_metadata_batch_add_head( @@ -338,7 +338,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem, channel_data* chand = static_cast(elem->channel_data); if (!chand->surface_user_agent && b->legacy_index()->named.user_agent != nullptr) { - grpc_metadata_batch_remove(b, GRPC_BATCH_USER_AGENT); + b->Remove(GRPC_BATCH_USER_AGENT); } return error; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 3e824bb9f88..7cc8be13dce 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1015,14 +1015,14 @@ static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) { set_incoming_stream_compression_algorithm( call, decode_stream_compression( b->legacy_index()->named.content_encoding->md)); - grpc_metadata_batch_remove(b, GRPC_BATCH_CONTENT_ENCODING); + b->Remove(GRPC_BATCH_CONTENT_ENCODING); } if (b->legacy_index()->named.grpc_encoding != nullptr) { GPR_TIMER_SCOPE("incoming_message_compression_algorithm", 0); set_incoming_message_compression_algorithm( call, decode_message_compression(b->legacy_index()->named.grpc_encoding->md)); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_ENCODING); + b->Remove(GRPC_BATCH_GRPC_ENCODING); } uint32_t message_encodings_accepted_by_peer = 1u; uint32_t stream_encodings_accepted_by_peer = 1u; @@ -1031,14 +1031,14 @@ static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) { set_encodings_accepted_by_peer( call, b->legacy_index()->named.grpc_accept_encoding->md, &message_encodings_accepted_by_peer, false); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_ACCEPT_ENCODING); + b->Remove(GRPC_BATCH_GRPC_ACCEPT_ENCODING); } if (b->legacy_index()->named.accept_encoding != nullptr) { GPR_TIMER_SCOPE("stream_encodings_accepted_by_peer", 0); set_encodings_accepted_by_peer(call, b->legacy_index()->named.accept_encoding->md, &stream_encodings_accepted_by_peer, true); - grpc_metadata_batch_remove(b, GRPC_BATCH_ACCEPT_ENCODING); + b->Remove(GRPC_BATCH_ACCEPT_ENCODING); } call->encodings_accepted_by_peer = grpc_compression_bitset_from_message_stream_compression_bitset( @@ -1069,13 +1069,13 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b, error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_ref_internal( GRPC_MDVALUE(b->legacy_index()->named.grpc_message->md))); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_MESSAGE); + b->Remove(GRPC_BATCH_GRPC_MESSAGE); } else if (error != GRPC_ERROR_NONE) { error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, grpc_empty_slice()); } set_final_status(call, GRPC_ERROR_REF(error)); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_STATUS); + b->Remove(GRPC_BATCH_GRPC_STATUS); GRPC_ERROR_UNREF(error); } else if (!call->is_client) { set_final_status(call, GRPC_ERROR_NONE); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 249a072f3ee..e07772ec283 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1390,9 +1390,8 @@ void Server::CallData::RecvInitialMetadataReady(void* arg, calld->recv_initial_metadata_->legacy_index()->named.path->md))); calld->host_.emplace(grpc_slice_ref_internal(GRPC_MDVALUE( calld->recv_initial_metadata_->legacy_index()->named.authority->md))); - grpc_metadata_batch_remove(calld->recv_initial_metadata_, GRPC_BATCH_PATH); - grpc_metadata_batch_remove(calld->recv_initial_metadata_, - GRPC_BATCH_AUTHORITY); + calld->recv_initial_metadata_->Remove(GRPC_BATCH_PATH); + calld->recv_initial_metadata_->Remove(GRPC_BATCH_AUTHORITY); } else { GRPC_ERROR_REF(error); } diff --git a/src/cpp/ext/filters/census/client_filter.cc b/src/cpp/ext/filters/census/client_filter.cc index 23f5a9e29de..7b9c033aebc 100644 --- a/src/cpp/ext/filters/census/client_filter.cc +++ b/src/cpp/ext/filters/census/client_filter.cc @@ -130,8 +130,7 @@ void FilterTrailingMetadata(grpc_metadata_batch* b, uint64_t* elapsed_time) { GRPC_SLICE_LENGTH( GRPC_MDVALUE(b->legacy_index()->named.grpc_server_stats_bin->md)), elapsed_time); - grpc_metadata_batch_remove(b, - b->legacy_index()->named.grpc_server_stats_bin); + b->Remove(b->legacy_index()->named.grpc_server_stats_bin); } } diff --git a/src/cpp/ext/filters/census/server_filter.cc b/src/cpp/ext/filters/census/server_filter.cc index 28e9ab37982..0a84680b9de 100644 --- a/src/cpp/ext/filters/census/server_filter.cc +++ b/src/cpp/ext/filters/census/server_filter.cc @@ -52,12 +52,12 @@ void FilterInitialMetadata(grpc_metadata_batch* b, if (b->legacy_index()->named.grpc_trace_bin != nullptr) { sml->tracing_slice = grpc_slice_ref_internal( GRPC_MDVALUE(b->legacy_index()->named.grpc_trace_bin->md)); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_TRACE_BIN); + b->Remove(GRPC_BATCH_GRPC_TRACE_BIN); } if (b->legacy_index()->named.grpc_tags_bin != nullptr) { sml->census_proto = grpc_slice_ref_internal( GRPC_MDVALUE(b->legacy_index()->named.grpc_tags_bin->md)); - grpc_metadata_batch_remove(b, GRPC_BATCH_GRPC_TAGS_BIN); + b->Remove(GRPC_BATCH_GRPC_TAGS_BIN); } }