Apply clang-format diffs.

pull/6320/head
Mark D. Roth 9 years ago
parent 2df502e518
commit 22b338e210
  1. 14
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  2. 2
      src/core/ext/transport/chttp2/transport/incoming_metadata.h
  3. 8
      src/core/ext/transport/chttp2/transport/parsing.c
  4. 4
      src/core/lib/transport/metadata.h
  5. 4
      src/core/lib/transport/metadata_batch.c
  6. 7
      test/core/bad_client/bad_client.c
  7. 8
      test/core/bad_client/bad_client.h
  8. 33
      test/core/bad_client/tests/large_metadata.c
  9. 4
      test/core/end2end/fixtures/h2_ssl_proxy.c
  10. 6
      test/core/end2end/fixtures/proxy.c
  11. 6
      test/core/end2end/fixtures/proxy.h
  12. 11
      test/core/end2end/tests/large_metadata.c

@ -948,15 +948,16 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
stream_global->send_initial_metadata_finished =
add_closure_barrier(on_complete);
stream_global->send_initial_metadata = op->send_initial_metadata;
const size_t metadata_size = grpc_metadata_batch_size(
op->send_initial_metadata);
const size_t metadata_size =
grpc_metadata_batch_size(op->send_initial_metadata);
const size_t metadata_peer_limit =
transport_global->settings[GRPC_PEER_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
if (metadata_size > metadata_peer_limit) {
gpr_log(GPR_DEBUG,
"to-be-sent initial metadata size exceeds peer limit "
"(%lu vs. %lu)", metadata_size, metadata_peer_limit);
"(%lu vs. %lu)",
metadata_size, metadata_peer_limit);
cancel_from_api(exec_ctx, transport_global, stream_global,
GRPC_STATUS_RESOURCE_EXHAUSTED);
} else {
@ -1002,15 +1003,16 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx,
stream_global->send_trailing_metadata_finished =
add_closure_barrier(on_complete);
stream_global->send_trailing_metadata = op->send_trailing_metadata;
const size_t metadata_size = grpc_metadata_batch_size(
op->send_trailing_metadata);
const size_t metadata_size =
grpc_metadata_batch_size(op->send_trailing_metadata);
const size_t metadata_peer_limit =
transport_global->settings[GRPC_PEER_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
if (metadata_size > metadata_peer_limit) {
gpr_log(GPR_DEBUG,
"to-be-sent trailing metadata size exceeds peer limit "
"(%lu vs. %lu)", metadata_size, metadata_peer_limit);
"(%lu vs. %lu)",
metadata_size, metadata_peer_limit);
cancel_from_api(exec_ctx, transport_global, stream_global,
GRPC_STATUS_RESOURCE_EXHAUSTED);
} else {

@ -42,7 +42,7 @@ typedef struct {
size_t capacity;
gpr_timespec deadline;
int published;
size_t size; /* total size of metadata */
size_t size; // total size of metadata
} grpc_chttp2_incoming_metadata_buffer;
/** assumes everything initially zeroed */

@ -639,8 +639,8 @@ static void on_initial_header(void *tp, grpc_mdelem *md) {
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), *cached_timeout));
GRPC_MDELEM_UNREF(md);
} else {
const size_t new_size = stream_parsing->metadata_buffer[0].size +
GRPC_MDELEM_LENGTH(md);
const size_t new_size =
stream_parsing->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md);
grpc_chttp2_transport_global *transport_global =
&TRANSPORT_FROM_PARSING(transport_parsing)->global;
const size_t metadata_size_limit =
@ -685,8 +685,8 @@ static void on_trailing_header(void *tp, grpc_mdelem *md) {
stream_parsing->seen_error = true;
}
const size_t new_size = stream_parsing->metadata_buffer[1].size +
GRPC_MDELEM_LENGTH(md);
const size_t new_size =
stream_parsing->metadata_buffer[1].size + GRPC_MDELEM_LENGTH(md);
grpc_chttp2_transport_global *transport_global =
&TRANSPORT_FROM_PARSING(transport_parsing)->global;
const size_t metadata_size_limit =

@ -148,8 +148,8 @@ const char *grpc_mdstr_as_c_string(grpc_mdstr *s);
#define GRPC_MDSTR_LENGTH(s) (GPR_SLICE_LENGTH(s->slice))
/* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */
#define GRPC_MDELEM_LENGTH(e) (GRPC_MDSTR_LENGTH((e)->key) + \
GRPC_MDSTR_LENGTH((e)->value) + 32)
#define GRPC_MDELEM_LENGTH(e) \
(GRPC_MDSTR_LENGTH((e)->key) + GRPC_MDSTR_LENGTH((e)->value) + 32)
int grpc_mdstr_is_legal_header(grpc_mdstr *s);
int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s);

@ -195,8 +195,8 @@ int grpc_metadata_batch_is_empty(grpc_metadata_batch *batch) {
size_t grpc_metadata_batch_size(grpc_metadata_batch *batch) {
size_t size = 0;
for (grpc_linked_mdelem* elem = batch->list.head;
elem != NULL; elem = elem->next) {
for (grpc_linked_mdelem* elem = batch->list.head; elem != NULL;
elem = elem->next) {
size += GRPC_MDELEM_LENGTH(elem->md);
}
return size;

@ -90,8 +90,7 @@ static void read_done(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
void grpc_run_bad_client_test(
grpc_bad_client_server_side_validator server_validator,
grpc_bad_client_client_stream_validator client_validator,
const char *client_payload,
size_t client_payload_length, uint32_t flags) {
const char *client_payload, size_t client_payload_length, uint32_t flags) {
grpc_endpoint_pair sfd;
thd_args a;
gpr_thd_id id;
@ -177,8 +176,8 @@ void grpc_run_bad_client_test(
grpc_endpoint_read(&exec_ctx, sfd.client, &args.incoming,
&read_done_closure);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&args.read_done,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)));
GPR_ASSERT(
gpr_event_wait(&args.read_done, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)));
gpr_slice_buffer_destroy(&args.incoming);
}
// Shutdown.

@ -59,9 +59,9 @@ void grpc_run_bad_client_test(
grpc_bad_client_client_stream_validator client_validator,
const char *client_payload, size_t client_payload_length, uint32_t flags);
#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, \
payload, flags) \
grpc_run_bad_client_test(server_validator, client_validator, \
payload, sizeof(payload) - 1, flags)
#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \
flags) \
grpc_run_bad_client_test(server_validator, client_validator, payload, \
sizeof(payload) - 1, flags)
#endif /* GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H */

@ -40,16 +40,19 @@
#include "test/core/end2end/cq_verifier.h"
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_STR \
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
/* settings frame */ \
"\x00\x00\x00\x04\x00\x00\x00\x00\x00" \
/* headers: generated from large_metadata.headers in this directory */ \
"\x00""5{\x01\x05\x00\x00\x00\x01" \
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" /* settings frame */ \
"\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* headers: generated from \
large_metadata.headers in this \
directory */ \
"\x00" \
"5{\x01\x05\x00\x00\x00\x01" \
"\x10\x05:path\x08/foo/bar" \
"\x10\x07:scheme\x04http" \
"\x10\x07:method\x04POST" \
"\x10\x0a:authority\x09localhost" \
"\x10\x0c""content-type\x10""application/grpc" \
"\x10\x0c" \
"content-type\x10" \
"application/grpc" \
"\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \
"\x10\x02te\x08trailers" \
"\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" \
@ -340,10 +343,15 @@
"aaaaaaaa"
#define PFX_TOO_MUCH_METADATA_FROM_SERVER_STR \
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
/* settings frame: sets MAX_HEADER_LIST_SIZE to 16K */ \
"\x00\x00\x06\x04\x00\x00\x00\x00\x00\x00\x06\x00\x00\x40\x00" \
/* headers: generated from simple_request.headers in this directory */ \
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" /* settings frame: sets \
MAX_HEADER_LIST_SIZE to 16K */ \
"\x00\x00\x06\x04\x00\x00\x00\x00\x00\x00\x06\x00\x00\x40\x00" /* headers: \
generated \
from \
simple_request.headers \
in this \
directory \
*/ \
"\x00\x00\xc9\x01\x04\x00\x00\x00\x01" \
"\x10\x05:path\x08/foo/bar" \
"\x10\x07:scheme\x04http" \
@ -385,8 +393,9 @@ static void server_verifier(grpc_server *server, grpc_completion_queue *cq,
cq_verifier_destroy(cqv);
}
static void server_verifier_sends_too_much_metadata(
grpc_server *server, grpc_completion_queue *cq, void *registered_method) {
static void server_verifier_sends_too_much_metadata(grpc_server *server,
grpc_completion_queue *cq,
void *registered_method) {
grpc_call_error error;
grpc_call *s;
grpc_call_details call_details;

@ -76,8 +76,8 @@ static grpc_channel *create_proxy_client(const char *target,
{"foo.test.google.fr"}};
grpc_channel_args *new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
channel = grpc_secure_channel_create(ssl_creds, target, new_client_args,
NULL);
channel =
grpc_secure_channel_create(ssl_creds, target, new_client_args, NULL);
grpc_channel_credentials_release(ssl_creds);
grpc_channel_args_destroy(new_client_args);
return channel;

@ -89,9 +89,9 @@ typedef struct {
static void thread_main(void *arg);
static void request_call(grpc_end2end_proxy *proxy);
grpc_end2end_proxy *grpc_end2end_proxy_create(
const grpc_end2end_proxy_def *def,
grpc_channel_args *client_args, grpc_channel_args *server_args) {
grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
grpc_channel_args *client_args,
grpc_channel_args *server_args) {
gpr_thd_options opt = gpr_thd_options_default();
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();

@ -47,9 +47,9 @@ typedef struct grpc_end2end_proxy_def {
grpc_channel_args *client_args);
} grpc_end2end_proxy_def;
grpc_end2end_proxy *grpc_end2end_proxy_create(
const grpc_end2end_proxy_def *def,
grpc_channel_args *client_args, grpc_channel_args *server_args);
grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
grpc_channel_args *client_args,
grpc_channel_args *server_args);
void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy);
const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy);

@ -107,11 +107,12 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta;
const size_t large_size = 64 * 1024;
grpc_arg arg = { GRPC_ARG_INTEGER, GRPC_ARG_MAX_METADATA_SIZE,
{ .integer=(int)large_size + 1024 } };
grpc_channel_args args = { 1, &arg };
grpc_end2end_test_fixture f = begin_test(
config, "test_request_with_large_metadata", &args, &args);
grpc_arg arg = {GRPC_ARG_INTEGER,
GRPC_ARG_MAX_METADATA_SIZE,
{.integer=(int)large_size + 1024}};
grpc_channel_args args = {1, &arg};
grpc_end2end_test_fixture f =
begin_test(config, "test_request_with_large_metadata", &args, &args);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;

Loading…
Cancel
Save