[chttp2] use new channel args type (#30252)

* x

* x

* Automated change: Fix sanity tests

* fix

* fix

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
revert-30252-ARGUE
Craig Tiller 2 years ago committed by GitHub
parent fb67563c73
commit d7e6878ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  2. 9
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  3. 213
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  4. 5
      src/core/ext/transport/chttp2/transport/chttp2_transport.h
  5. 8
      src/core/ext/transport/chttp2/transport/internal.h
  6. 3
      src/core/lib/channel/channel_args.h
  7. 7
      test/core/bad_client/bad_client.cc
  8. 7
      test/core/bad_connection/close_fd_test.cc
  9. 22
      test/core/end2end/fixtures/h2_sockpair+trace.cc
  10. 25
      test/core/end2end/fixtures/h2_sockpair.cc
  11. 25
      test/core/end2end/fixtures/h2_sockpair_1byte.cc
  12. 2
      test/core/end2end/fuzzers/api_fuzzer.cc
  13. 2
      test/core/end2end/fuzzers/client_fuzzer.cc
  14. 4
      test/core/end2end/fuzzers/server_fuzzer.cc
  15. 12
      test/core/transport/chttp2/context_list_test.cc
  16. 4
      test/core/transport/chttp2/graceful_shutdown_test.cc
  17. 5
      test/cpp/microbenchmarks/bm_chttp2_transport.cc
  18. 10
      test/cpp/microbenchmarks/fullstack_fixtures.h
  19. 28
      test/cpp/performance/writes_per_rpc_test.cc

@ -164,8 +164,8 @@ void Chttp2Connector::OnHandshakeDone(void* arg, grpc_error_handle error) {
self->result_->Reset();
NullThenSchedClosure(DEBUG_LOCATION, &self->notify_, error);
} else if (args->endpoint != nullptr) {
self->result_->transport = grpc_create_chttp2_transport(
args->args.ToC().get(), args->endpoint, true);
self->result_->transport =
grpc_create_chttp2_transport(args->args, args->endpoint, true);
self->result_->socket_node =
grpc_chttp2_transport_get_socket_node(self->result_->transport);
self->result_->channel_args = args->args;
@ -405,7 +405,7 @@ grpc_channel* grpc_channel_create_from_fd(const char* target, int fd,
grpc_endpoint* client = grpc_tcp_client_create_from_fd(
grpc_fd_create(fd, "client", true), c_final_args.get(), "fd-client");
grpc_transport* transport =
grpc_create_chttp2_transport(c_final_args.get(), client, true);
grpc_create_chttp2_transport(final_args, client, true);
GPR_ASSERT(transport);
auto channel = grpc_core::Channel::Create(
target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);

@ -465,8 +465,8 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone(
// handshaker may have handed off the connection to some external
// code, so we can just clean up here without creating a transport.
if (args->endpoint != nullptr) {
grpc_transport* transport = grpc_create_chttp2_transport(
args->args.ToC().get(), args->endpoint, false);
grpc_transport* transport =
grpc_create_chttp2_transport(args->args, args->endpoint, false);
grpc_error_handle channel_init_err =
self->connection_->listener_->server_->SetupTransport(
transport, self->accepting_pollset_, args->args,
@ -1072,11 +1072,10 @@ void grpc_server_add_channel_from_fd(grpc_server* server, int fd,
std::string name = absl::StrCat("fd:", fd);
auto memory_quota =
server_args.GetObject<grpc_core::ResourceQuota>()->memory_quota();
auto server_channel_args = server_args.ToC();
grpc_endpoint* server_endpoint = grpc_tcp_create(
grpc_fd_create(fd, name.c_str(), true), server_channel_args.get(), name);
grpc_fd_create(fd, name.c_str(), true), server_args.ToC().get(), name);
grpc_transport* transport = grpc_create_chttp2_transport(
server_channel_args.get(), server_endpoint, false /* is_client */
server_args, server_endpoint, false /* is_client */
);
grpc_error_handle error =
core_server->SetupTransport(transport, nullptr, server_args, nullptr);

@ -40,6 +40,7 @@
#include "absl/types/variant.h"
#include <grpc/impl/codegen/connectivity_state.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/slice_buffer.h>
#include <grpc/status.h>
#include <grpc/support/alloc.h>
@ -75,7 +76,6 @@
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/promise/poll.h"
#include "src/core/lib/resource_quota/api.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/resource_quota/resource_quota.h"
@ -286,147 +286,126 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
static const grpc_transport_vtable* get_vtable(void);
static void read_channel_args(grpc_chttp2_transport* t,
const grpc_channel_args* channel_args,
const grpc_core::ChannelArgs& channel_args,
bool is_client) {
bool channelz_enabled = GRPC_ENABLE_CHANNELZ_DEFAULT;
size_t i;
int j;
for (i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) {
const grpc_integer_options options = {-1, 0, INT_MAX};
const int value =
grpc_channel_arg_get_integer(&channel_args->args[i], options);
if (value >= 0) {
if ((t->next_stream_id & 1) != (value & 1)) {
const int initial_sequence_number =
channel_args.GetInt(GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER).value_or(-1);
if (initial_sequence_number > 0) {
if ((t->next_stream_id & 1) != (initial_sequence_number & 1)) {
gpr_log(GPR_ERROR, "%s: low bit must be %d on %s",
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER, t->next_stream_id & 1,
is_client ? "client" : "server");
} else {
t->next_stream_id = static_cast<uint32_t>(value);
t->next_stream_id = static_cast<uint32_t>(initial_sequence_number);
}
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER)) {
const grpc_integer_options options = {-1, 0, INT_MAX};
const int value =
grpc_channel_arg_get_integer(&channel_args->args[i], options);
if (value >= 0) {
t->hpack_compressor.SetMaxUsableSize(value);
const int max_hpack_table_size =
channel_args.GetInt(GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER).value_or(-1);
if (max_hpack_table_size >= 0) {
t->hpack_compressor.SetMaxUsableSize(max_hpack_table_size);
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
t->ping_policy.max_pings_without_data = grpc_channel_arg_get_integer(
&channel_args->args[i],
{g_default_max_pings_without_data, 0, INT_MAX});
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
t->ping_policy.max_ping_strikes = grpc_channel_arg_get_integer(
&channel_args->args[i], {g_default_max_ping_strikes, 0, INT_MAX});
} else if (0 ==
strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS)) {
t->ping_policy.max_pings_without_data =
std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)
.value_or(g_default_max_pings_without_data));
t->ping_policy.max_ping_strikes =
std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES)
.value_or(g_default_max_ping_strikes));
t->ping_policy.min_recv_ping_interval_without_data =
grpc_core::Duration::Milliseconds(grpc_channel_arg_get_integer(
&channel_args->args[i],
grpc_integer_options{
g_default_min_recv_ping_interval_without_data_ms, 0,
INT_MAX}));
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
t->write_buffer_size = static_cast<uint32_t>(grpc_channel_arg_get_integer(
&channel_args->args[i], {0, 0, MAX_WRITE_BUFFER_SIZE}));
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
grpc_integer_options{t->is_client
? g_default_client_keepalive_time_ms
: g_default_server_keepalive_time_ms,
1, INT_MAX});
t->keepalive_time = value == INT_MAX
? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(value);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
const int value = grpc_channel_arg_get_integer(
&channel_args->args[i],
grpc_integer_options{t->is_client
? g_default_client_keepalive_timeout_ms
: g_default_server_keepalive_timeout_ms,
0, INT_MAX});
t->keepalive_timeout = value == INT_MAX
? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(value);
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
t->keepalive_permit_without_calls = static_cast<uint32_t>(
grpc_channel_arg_get_integer(&channel_args->args[i], {0, 0, 1}));
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_OPTIMIZATION_TARGET)) {
gpr_log(GPR_INFO, "GRPC_ARG_OPTIMIZATION_TARGET is deprecated");
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) {
channelz_enabled = grpc_channel_arg_get_bool(
&channel_args->args[i], GRPC_ENABLE_CHANNELZ_DEFAULT);
} else {
std::max(grpc_core::Duration::Zero(),
channel_args
.GetDurationFromIntMillis(
GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS)
.value_or(grpc_core::Duration::Milliseconds(
g_default_min_recv_ping_interval_without_data_ms)));
t->write_buffer_size =
std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)
.value_or(grpc_core::chttp2::kDefaultWindow));
t->keepalive_time =
std::max(grpc_core::Duration::Milliseconds(1),
channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIME_MS)
.value_or(grpc_core::Duration::Milliseconds(
t->is_client ? g_default_client_keepalive_time_ms
: g_default_server_keepalive_time_ms)));
t->keepalive_timeout = std::max(
grpc_core::Duration::Zero(),
channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIMEOUT_MS)
.value_or(grpc_core::Duration::Milliseconds(
t->is_client ? g_default_client_keepalive_timeout_ms
: g_default_server_keepalive_timeout_ms)));
t->keepalive_permit_without_calls =
channel_args.GetBool(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)
.value_or(false);
if (channel_args.GetBool(GRPC_ARG_ENABLE_CHANNELZ)
.value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) {
t->channelz_socket =
grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>(
std::string(grpc_endpoint_get_local_address(t->ep)), t->peer_string,
absl::StrFormat("%s %s", get_vtable()->name, t->peer_string),
channel_args
.GetObjectRef<grpc_core::channelz::SocketNode::Security>());
}
static const struct {
const char* channel_arg_name;
absl::string_view channel_arg_name;
grpc_chttp2_setting_id setting_id;
grpc_integer_options integer_options;
int default_value;
int min;
int max;
bool availability[2] /* server, client */;
} settings_map[] = {{GRPC_ARG_MAX_CONCURRENT_STREAMS,
GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS,
{-1, 0, INT32_MAX},
-1,
0,
INT32_MAX,
{true, false}},
{GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER,
GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE,
{-1, 0, INT32_MAX},
-1,
0,
INT32_MAX,
{true, true}},
{GRPC_ARG_MAX_METADATA_SIZE,
GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
{-1, 0, INT32_MAX},
-1,
0,
INT32_MAX,
{true, true}},
{GRPC_ARG_HTTP2_MAX_FRAME_SIZE,
GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
{-1, 16384, 16777215},
-1,
16384,
16777215,
{true, true}},
{GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY,
GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA,
{1, 0, 1},
1,
0,
1,
{true, true}},
{GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES,
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
{-1, 5, INT32_MAX},
-1,
5,
INT32_MAX,
{true, true}}};
for (j = 0; j < static_cast<int> GPR_ARRAY_SIZE(settings_map); j++) {
if (0 == strcmp(channel_args->args[i].key,
settings_map[j].channel_arg_name)) {
if (!settings_map[j].availability[is_client]) {
gpr_log(GPR_DEBUG, "%s is not available on %s",
settings_map[j].channel_arg_name,
is_client ? "clients" : "servers");
} else {
int value = grpc_channel_arg_get_integer(
&channel_args->args[i], settings_map[j].integer_options);
for (size_t i = 0; i < GPR_ARRAY_SIZE(settings_map); i++) {
const auto& setting = settings_map[i];
if (setting.availability[is_client]) {
const int value = channel_args.GetInt(setting.channel_arg_name)
.value_or(setting.default_value);
if (value >= 0) {
queue_setting_update(t, settings_map[j].setting_id,
static_cast<uint32_t>(value));
}
}
break;
}
}
queue_setting_update(t, setting.setting_id,
grpc_core::Clamp(value, setting.min, setting.max));
}
} else if (channel_args.Contains(setting.channel_arg_name)) {
gpr_log(GPR_DEBUG, "%s is not available on %s",
std::string(setting.channel_arg_name).c_str(),
is_client ? "clients" : "servers");
}
if (channelz_enabled) {
t->channelz_socket =
grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>(
std::string(grpc_endpoint_get_local_address(t->ep)), t->peer_string,
absl::StrFormat("%s %s", get_vtable()->name, t->peer_string),
grpc_core::channelz::SocketNode::Security::GetFromChannelArgs(
channel_args));
}
}
@ -481,13 +460,14 @@ static void init_keepalive_pings_if_enabled(grpc_chttp2_transport* t) {
}
grpc_chttp2_transport::grpc_chttp2_transport(
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client)
const grpc_core::ChannelArgs& channel_args, grpc_endpoint* ep,
bool is_client)
: refs(1, GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_refcount)
? "chttp2_refcount"
: nullptr),
ep(ep),
peer_string(grpc_endpoint_get_peer(ep)),
memory_owner(grpc_core::ResourceQuotaFromChannelArgs(channel_args)
memory_owner(channel_args.GetObject<grpc_core::ResourceQuota>()
->memory_quota()
->CreateMemoryOwner(absl::StrCat(
grpc_endpoint_get_peer(ep), ":client_transport"))),
@ -498,9 +478,9 @@ grpc_chttp2_transport::grpc_chttp2_transport(
GRPC_CHANNEL_READY),
is_client(is_client),
next_stream_id(is_client ? 1 : 2),
flow_control(peer_string.c_str(),
grpc_channel_args_find_bool(channel_args,
GRPC_ARG_HTTP2_BDP_PROBE, true),
flow_control(
peer_string.c_str(),
channel_args.GetBool(GRPC_ARG_HTTP2_BDP_PROBE).value_or(true),
&memory_owner),
deframe_state(is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0) {
GPR_ASSERT(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) ==
@ -543,9 +523,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
configure_transport_ping_policy(this);
init_transport_keepalive_settings(this);
if (channel_args != nullptr) {
read_channel_args(this, channel_args, is_client);
}
// No pings allowed before receiving a header or data frame.
ping_state.pings_before_data_required = 0;
@ -3120,7 +3098,8 @@ grpc_chttp2_transport_get_socket_node(grpc_transport* transport) {
}
grpc_transport* grpc_create_chttp2_transport(
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client) {
const grpc_core::ChannelArgs& channel_args, grpc_endpoint* ep,
bool is_client) {
auto t = new grpc_chttp2_transport(channel_args, ep, is_client);
return &t->base;
}

@ -21,9 +21,9 @@
#include <grpc/support/port_platform.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/slice.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -41,7 +41,8 @@ extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser;
/// from the caller; if the caller still needs the resource_user after creating
/// a transport, the caller must take another ref.
grpc_transport* grpc_create_chttp2_transport(
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client);
const grpc_core::ChannelArgs& channel_args, grpc_endpoint* ep,
bool is_client);
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode>
grpc_chttp2_transport_get_socket_node(grpc_transport* transport);

@ -30,7 +30,6 @@
#include "absl/types/optional.h"
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/slice.h>
#include "src/core/ext/transport/chttp2/transport/flow_control.h"
@ -44,6 +43,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/stream_map.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/bitset.h"
@ -236,7 +236,7 @@ typedef enum {
} grpc_chttp2_keepalive_state;
struct grpc_chttp2_transport {
grpc_chttp2_transport(const grpc_channel_args* channel_args,
grpc_chttp2_transport(const grpc_core::ChannelArgs& channel_args,
grpc_endpoint* ep, bool is_client);
~grpc_chttp2_transport();
@ -774,8 +774,8 @@ void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
/** Set the default keepalive configurations, must only be called at
initialization */
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client);
void grpc_chttp2_config_default_keepalive_args(
const grpc_core::ChannelArgs& args, bool is_client);
void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error_handle error);

@ -173,6 +173,9 @@ class ChannelArgs {
ChannelArgs& operator=(ChannelArgs&&) noexcept;
static ChannelArgs FromC(const grpc_channel_args* args);
static ChannelArgs FromC(const grpc_channel_args& args) {
return FromC(&args);
}
// Construct a new grpc_channel_args struct.
CPtr ToC() const;

@ -214,11 +214,10 @@ void grpc_run_bad_client_test(
GRPC_BAD_CLIENT_REGISTERED_HOST,
GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0);
grpc_server_start(a.server);
transport = grpc_create_chttp2_transport(grpc_core::CoreConfiguration::Get()
transport =
grpc_create_chttp2_transport(grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.ToC()
.get(),
.PreconditionChannelArgs(nullptr),
sfd.server, false);
server_setup_transport(&a, transport);
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);

@ -21,6 +21,7 @@
* an RPC call is in progress.
*
*/
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/port.h"
// This test won't work except with posix sockets enabled
@ -101,7 +102,8 @@ static void client_setup_transport(grpc_transport* transport) {
static void init_client() {
grpc_core::ExecCtx exec_ctx;
grpc_transport* transport;
transport = grpc_create_chttp2_transport(nullptr, g_ctx.ep->client, true);
transport = grpc_create_chttp2_transport(grpc_core::ChannelArgs(),
g_ctx.ep->client, true);
client_setup_transport(transport);
GPR_ASSERT(g_ctx.client);
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);
@ -114,7 +116,8 @@ static void init_server() {
g_ctx.server = grpc_server_create(nullptr, nullptr);
grpc_server_register_completion_queue(g_ctx.server, g_ctx.cq, nullptr);
grpc_server_start(g_ctx.server);
transport = grpc_create_chttp2_transport(nullptr, g_ctx.ep->server, false);
transport = grpc_create_chttp2_transport(grpc_core::ChannelArgs(),
g_ctx.ep->server, false);
server_setup_transport(transport);
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);
}

@ -111,14 +111,11 @@ static void chttp2_init_client_socketpair(
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
client_args = grpc_core::CoreConfiguration::Get()
auto client_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(client_args)
.ToC()
.release();
transport =
grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true);
grpc_channel_args_destroy(client_args);
.PreconditionChannelArgs(client_args);
transport = grpc_create_chttp2_transport(client_channel_args,
fixture_data->ep.client, true);
client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
}
@ -132,14 +129,11 @@ static void chttp2_init_server_socketpair(
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
server_args = grpc_core::CoreConfiguration::Get()
auto server_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(server_args)
.ToC()
.release();
transport =
grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false);
grpc_channel_args_destroy(server_args);
.PreconditionChannelArgs(server_args);
transport = grpc_create_chttp2_transport(server_channel_args,
fixture_data->ep.server, false);
server_setup_transport(f, transport);
}

@ -104,17 +104,15 @@ static void chttp2_init_client_socketpair(
auto* fixture_data = static_cast<custom_fixture_data*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
client_args = grpc_core::CoreConfiguration::Get()
auto client_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(client_args)
.ToC()
.release();
cs.client_args = client_args;
.PreconditionChannelArgs(client_args);
cs.client_args = client_channel_args.ToC().release();
cs.f = f;
transport =
grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true);
transport = grpc_create_chttp2_transport(client_channel_args,
fixture_data->ep.client, true);
client_setup_transport(&cs, transport);
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(cs.client_args);
GPR_ASSERT(f->client);
}
@ -127,14 +125,11 @@ static void chttp2_init_server_socketpair(
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
server_args = grpc_core::CoreConfiguration::Get()
auto server_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(server_args)
.ToC()
.release();
transport =
grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false);
grpc_channel_args_destroy(server_args);
.PreconditionChannelArgs(server_args);
transport = grpc_create_chttp2_transport(server_channel_args,
fixture_data->ep.server, false);
server_setup_transport(f, transport);
}

@ -115,17 +115,15 @@ static void chttp2_init_client_socketpair(
auto* fixture_data = static_cast<custom_fixture_data*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
client_args = grpc_core::CoreConfiguration::Get()
auto client_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(client_args)
.ToC()
.release();
cs.client_args = client_args;
.PreconditionChannelArgs(client_args);
cs.client_args = client_channel_args.ToC().release();
cs.f = f;
transport =
grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true);
transport = grpc_create_chttp2_transport(client_channel_args,
fixture_data->ep.client, true);
client_setup_transport(&cs, transport);
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(cs.client_args);
GPR_ASSERT(f->client);
}
@ -138,14 +136,11 @@ static void chttp2_init_server_socketpair(
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
server_args = grpc_core::CoreConfiguration::Get()
auto server_channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(server_args)
.ToC()
.release();
transport =
grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false);
grpc_channel_args_destroy(server_args);
.PreconditionChannelArgs(server_args);
transport = grpc_create_chttp2_transport(server_channel_args,
fixture_data->ep.server, false);
server_setup_transport(f, transport);
}

@ -217,7 +217,7 @@ static void do_connect(void* arg, grpc_error_handle error) {
grpc_core::Server* core_server = grpc_core::Server::FromC(g_server);
grpc_transport* transport = grpc_create_chttp2_transport(
core_server->channel_args().ToC().get(), server, false);
core_server->channel_args(), server, false);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"SetupTransport",
core_server->SetupTransport(transport, nullptr,

@ -55,7 +55,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr);
grpc_transport* transport =
grpc_create_chttp2_transport(args.ToC().get(), mock_endpoint, true);
grpc_create_chttp2_transport(args, mock_endpoint, true);
grpc_resource_quota_unref(resource_quota);
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);
auto channel_args =

@ -57,8 +57,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_core::ChannelArgs channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr);
grpc_transport* transport = grpc_create_chttp2_transport(
channel_args.ToC().get(), mock_endpoint, false);
grpc_transport* transport =
grpc_create_chttp2_transport(channel_args, mock_endpoint, false);
grpc_resource_quota_unref(resource_quota);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"SetupTransport", grpc_core::Server::FromC(server)->SetupTransport(

@ -75,10 +75,8 @@ TEST_F(ContextListTest, ExecuteFlushesList) {
grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write);
auto args = CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.ToC();
grpc_transport* t =
grpc_create_chttp2_transport(args.get(), mock_endpoint, true);
.PreconditionChannelArgs(nullptr);
grpc_transport* t = grpc_create_chttp2_transport(args, mock_endpoint, true);
std::vector<grpc_chttp2_stream*> s;
s.reserve(kNumElems);
gpr_atm verifier_called[kNumElems];
@ -131,10 +129,8 @@ TEST_F(ContextListTest, NonEmptyListEmptyTimestamp) {
grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write);
auto args = CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.ToC();
grpc_transport* t =
grpc_create_chttp2_transport(args.get(), mock_endpoint, true);
.PreconditionChannelArgs(nullptr);
grpc_transport* t = grpc_create_chttp2_transport(args, mock_endpoint, true);
std::vector<grpc_chttp2_stream*> s;
s.reserve(kNumElems);
gpr_atm verifier_called[kNumElems];

@ -78,8 +78,8 @@ class GracefulShutdownTest : public ::testing::Test {
grpc_server_register_completion_queue(server_, cq_, nullptr);
grpc_server_start(server_);
fds_ = grpc_iomgr_create_endpoint_pair("fixture", nullptr);
auto* transport = grpc_create_chttp2_transport(
core_server->channel_args().ToC().get(), fds_.server, false);
auto* transport = grpc_create_chttp2_transport(core_server->channel_args(),
fds_.server, false);
grpc_endpoint_add_to_pollset(fds_.server, grpc_cq_pollset(cq_));
GPR_ASSERT(core_server->SetupTransport(transport, nullptr,
core_server->channel_args(),

@ -139,9 +139,8 @@ class Fixture {
ep_ = new PhonyEndpoint;
auto final_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(&c_args)
.ToC();
t_ = grpc_create_chttp2_transport(final_args.get(), ep_, client);
.PreconditionChannelArgs(&c_args);
t_ = grpc_create_chttp2_transport(final_args, ep_, client);
grpc_chttp2_transport_start_reading(t_, nullptr, nullptr, nullptr);
FlushExecCtx();
}

@ -178,7 +178,7 @@ class EndpointPairFixture : public BaseFixture {
grpc_core::Server::FromC(server_->c_server());
grpc_core::ChannelArgs server_args = core_server->channel_args();
server_transport_ = grpc_create_chttp2_transport(
server_args.ToC().get(), endpoints.server, false /* is_client */);
server_args, endpoints.server, false /* is_client */);
for (grpc_pollset* pollset : core_server->pollsets()) {
grpc_endpoint_add_to_pollset(endpoints.server, pollset);
}
@ -197,14 +197,14 @@ class EndpointPairFixture : public BaseFixture {
args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority");
fixture_configuration.ApplyCommonChannelArguments(&args);
grpc_channel_args c_args = args.c_channel_args();
grpc_core::ChannelArgs c_args =
grpc_core::ChannelArgs::FromC(args.c_channel_args());
client_transport_ =
grpc_create_chttp2_transport(&c_args, endpoints.client, true);
grpc_create_chttp2_transport(c_args, endpoints.client, true);
GPR_ASSERT(client_transport_);
grpc_channel* channel =
grpc_core::Channel::Create(
"target", grpc_core::ChannelArgs::FromC(&c_args),
GRPC_CLIENT_DIRECT_CHANNEL, client_transport_)
"target", c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_)
->release()
->c_ptr();
grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr,

@ -29,6 +29,7 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -52,10 +53,9 @@ static void ApplyCommonServerBuilderConfig(ServerBuilder* b) {
b->SetMaxSendMessageSize(INT_MAX);
}
static void ApplyCommonChannelArguments(ChannelArguments* c) {
c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX);
c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX);
c->SetResourceQuota(ResourceQuota());
static void ApplyCommonChannelArguments(grpc_core::ChannelArgs* c) {
*c = c->Set(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX)
.Set(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX);
}
class EndpointPairFixture {
@ -73,9 +73,8 @@ class EndpointPairFixture {
{
grpc_core::Server* core_server =
grpc_core::Server::FromC(server_->c_server());
grpc_transport* transport =
grpc_create_chttp2_transport(core_server->channel_args().ToC().get(),
endpoints.server, false /* is_client */);
grpc_transport* transport = grpc_create_chttp2_transport(
core_server->channel_args(), endpoints.server, false /* is_client */);
for (grpc_pollset* pollset : core_server->pollsets()) {
grpc_endpoint_add_to_pollset(endpoints.server, pollset);
}
@ -89,18 +88,19 @@ class EndpointPairFixture {
/* create channel */
{
ChannelArguments args;
args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority");
grpc_core::ChannelArgs args =
grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.Set(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority");
ApplyCommonChannelArguments(&args);
grpc_channel_args c_args = args.c_channel_args();
grpc_transport* transport =
grpc_create_chttp2_transport(&c_args, endpoints.client, true);
grpc_create_chttp2_transport(args, endpoints.client, true);
GPR_ASSERT(transport);
grpc_channel* channel =
grpc_core::Channel::Create("target",
grpc_core::ChannelArgs::FromC(&c_args),
GRPC_CLIENT_DIRECT_CHANNEL, transport)
grpc_core::Channel::Create("target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport)
->release()
->c_ptr();
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);

Loading…
Cancel
Save