Merge pull request #17776 from soheilhy/worktree-auth

Cache the default mdelem for client authority.
pull/17789/head
Soheil Hassas Yeganeh 6 years ago committed by GitHub
commit 00234e89cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/core/ext/filters/http/client_authority_filter.cc

@ -45,6 +45,7 @@ struct call_data {
struct channel_data { struct channel_data {
grpc_slice default_authority; grpc_slice default_authority;
grpc_mdelem default_authority_mdelem;
}; };
void authority_start_transport_stream_op_batch( void authority_start_transport_stream_op_batch(
@ -59,8 +60,7 @@ void authority_start_transport_stream_op_batch(
initial_metadata->idx.named.authority == nullptr) { initial_metadata->idx.named.authority == nullptr) {
grpc_error* error = grpc_metadata_batch_add_head( grpc_error* error = grpc_metadata_batch_add_head(
initial_metadata, &calld->authority_storage, initial_metadata, &calld->authority_storage,
grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, chand->default_authority, GRPC_MDELEM_REF(chand->default_authority_mdelem));
nullptr));
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(batch, error, grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner); calld->call_combiner);
@ -103,6 +103,8 @@ grpc_error* init_channel_elem(grpc_channel_element* elem,
} }
chand->default_authority = chand->default_authority =
grpc_slice_intern(grpc_slice_from_static_string(default_authority_str)); grpc_slice_intern(grpc_slice_from_static_string(default_authority_str));
chand->default_authority_mdelem = grpc_mdelem_create(
GRPC_MDSTR_AUTHORITY, chand->default_authority, nullptr);
GPR_ASSERT(!args->is_last); GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -111,6 +113,7 @@ grpc_error* init_channel_elem(grpc_channel_element* elem,
void destroy_channel_elem(grpc_channel_element* elem) { void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data);
grpc_slice_unref_internal(chand->default_authority); grpc_slice_unref_internal(chand->default_authority);
GRPC_MDELEM_UNREF(chand->default_authority_mdelem);
} }
} // namespace } // namespace

Loading…
Cancel
Save