run clang-format

pull/209/head
Yang Gao 10 years ago
parent c38dda4b90
commit 5fd0d29dfe
  1. 12
      include/grpc/support/sync_generic.h
  2. 37
      src/compiler/ruby_generator.cc
  3. 20
      src/core/channel/census_filter.c
  4. 4
      src/core/channel/channel_stack.c
  5. 4
      src/core/channel/channel_stack.h
  6. 11
      src/core/channel/child_channel.c
  7. 11
      src/core/channel/client_channel.c
  8. 14
      src/core/channel/connected_channel.c
  9. 14
      src/core/channel/http_client_filter.c
  10. 10
      src/core/channel/http_filter.c
  11. 10
      src/core/channel/http_server_filter.c
  12. 4
      src/core/channel/metadata_buffer.c
  13. 10
      src/core/channel/noop_filter.c
  14. 4
      src/core/iomgr/alarm_heap.c
  15. 3
      src/core/iomgr/tcp_server_posix.c
  16. 3
      src/core/support/histogram.c
  17. 19
      src/core/surface/client.c
  18. 19
      src/core/surface/lame_client.c
  19. 11
      src/core/surface/server.c
  20. 3
      src/core/transport/chttp2/frame_settings.c
  21. 14
      src/core/transport/chttp2/gen_hpack_tables.c
  22. 18
      src/core/transport/chttp2/hpack_parser.c
  23. 3
      src/core/transport/chttp2/hpack_table.c
  24. 3
      src/core/transport/chttp2/huffsyms.c
  25. 3
      src/core/transport/chttp2/varint.h
  26. 4
      src/core/transport/chttp2_transport.c
  27. 6
      src/core/tsi/fake_transport_security.c
  28. 6
      src/core/tsi/ssl_transport_security.c
  29. 3
      src/node/credentials.cc
  30. 4
      src/ruby/ext/grpc/rb_credentials.c
  31. 11
      test/core/channel/channel_stack_test.c
  32. 3
      test/core/end2end/fixtures/chttp2_fake_security.c
  33. 3
      test/core/end2end/fixtures/chttp2_fullstack.c
  34. 3
      test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
  35. 6
      test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
  36. 3
      test/core/end2end/fixtures/chttp2_socket_pair.c
  37. 3
      test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c
  38. 3
      test/core/end2end/tests/cancel_test_helpers.h
  39. 3
      test/core/fling/client.c
  40. 14
      test/core/iomgr/resolve_address_test.c
  41. 3
      test/core/iomgr/tcp_posix_test.c
  42. 3
      test/core/security/secure_endpoint_test.c
  43. 4
      test/core/surface/completion_queue_benchmark.c
  44. 4
      test/core/surface/completion_queue_test.c
  45. 4
      test/core/transport/chttp2/hpack_parser_test.c
  46. 3
      test/core/transport/chttp2_transport_end2end_test.c
  47. 12
      test/core/transport/transport_end2end_tests.c
  48. 7
      test/core/util/port_posix.c
  49. 18
      test/cpp/qps/client.cc
  50. 6
      test/cpp/util/create_test_channel.cc
  51. 4
      test/cpp/util/create_test_channel.h

@ -38,16 +38,22 @@
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
/* gpr_event */ /* gpr_event */
typedef struct { gpr_atm state; } gpr_event; typedef struct {
gpr_atm state;
} gpr_event;
#define GPR_EVENT_INIT \ #define GPR_EVENT_INIT \
{ 0 } { 0 }
/* gpr_refcount */ /* gpr_refcount */
typedef struct { gpr_atm count; } gpr_refcount; typedef struct {
gpr_atm count;
} gpr_refcount;
/* gpr_stats_counter */ /* gpr_stats_counter */
typedef struct { gpr_atm value; } gpr_stats_counter; typedef struct {
gpr_atm value;
} gpr_stats_counter;
#define GPR_STATS_INIT \ #define GPR_STATS_INIT \
{ 0 } { 0 }

@ -67,10 +67,9 @@ void PrintMethod(const MethodDescriptor *method, const std::string &package,
if (method->server_streaming()) { if (method->server_streaming()) {
output_type = "stream(" + output_type + ")"; output_type = "stream(" + output_type + ")";
} }
std::map<std::string, std::string> method_vars = ListToDict({ std::map<std::string, std::string> method_vars =
"mth.name", method->name(), "input.type", input_type, "output.type", ListToDict({"mth.name", method->name(), "input.type", input_type,
output_type, "output.type", output_type, });
});
out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n"); out->Print(method_vars, "rpc :$mth.name$, $input.type$, $output.type$\n");
} }
@ -82,17 +81,15 @@ void PrintService(const ServiceDescriptor *service, const std::string &package,
} }
// Begin the service module // Begin the service module
std::map<std::string, std::string> module_vars = ListToDict({ std::map<std::string, std::string> module_vars =
"module.name", CapitalizeFirst(service->name()), ListToDict({"module.name", CapitalizeFirst(service->name()), });
});
out->Print(module_vars, "module $module.name$\n"); out->Print(module_vars, "module $module.name$\n");
out->Indent(); out->Indent();
// TODO(temiola): add documentation // TODO(temiola): add documentation
std::string doc = "TODO: add proto service documentation here"; std::string doc = "TODO: add proto service documentation here";
std::map<std::string, std::string> template_vars = ListToDict({ std::map<std::string, std::string> template_vars =
"Documentation", doc, ListToDict({"Documentation", doc, });
});
out->Print("\n"); out->Print("\n");
out->Print(template_vars, "# $Documentation$\n"); out->Print(template_vars, "# $Documentation$\n");
out->Print("class Service\n"); out->Print("class Service\n");
@ -104,9 +101,8 @@ void PrintService(const ServiceDescriptor *service, const std::string &package,
out->Print("\n"); out->Print("\n");
out->Print("self.marshal_class_method = :encode\n"); out->Print("self.marshal_class_method = :encode\n");
out->Print("self.unmarshal_class_method = :decode\n"); out->Print("self.unmarshal_class_method = :decode\n");
std::map<std::string, std::string> pkg_vars = ListToDict({ std::map<std::string, std::string> pkg_vars =
"service.name", service->name(), "pkg.name", package, ListToDict({"service.name", service->name(), "pkg.name", package, });
});
out->Print(pkg_vars, "self.service_name = '$pkg.name$.$service.name$'\n"); out->Print(pkg_vars, "self.service_name = '$pkg.name$.$service.name$'\n");
out->Print("\n"); out->Print("\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
@ -137,9 +133,8 @@ std::string GetServices(const FileDescriptor *file) {
} }
// Write out a file header. // Write out a file header.
std::map<std::string, std::string> header_comment_vars = ListToDict({ std::map<std::string, std::string> header_comment_vars = ListToDict(
"file.name", file->name(), "file.package", file->package(), {"file.name", file->name(), "file.package", file->package(), });
});
out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n"); out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n");
out.Print(header_comment_vars, out.Print(header_comment_vars,
"# Source: $file.name$ for package '$file.package$'\n"); "# Source: $file.name$ for package '$file.package$'\n");
@ -149,18 +144,16 @@ std::string GetServices(const FileDescriptor *file) {
// Write out require statemment to import the separately generated file // Write out require statemment to import the separately generated file
// that defines the messages used by the service. This is generated by the // that defines the messages used by the service. This is generated by the
// main ruby plugin. // main ruby plugin.
std::map<std::string, std::string> dep_vars = ListToDict({ std::map<std::string, std::string> dep_vars =
"dep.name", MessagesRequireName(file), ListToDict({"dep.name", MessagesRequireName(file), });
});
out.Print(dep_vars, "require '$dep.name$'\n"); out.Print(dep_vars, "require '$dep.name$'\n");
// Write out services within the modules // Write out services within the modules
out.Print("\n"); out.Print("\n");
std::vector<std::string> modules = Split(file->package(), '.'); std::vector<std::string> modules = Split(file->package(), '.');
for (size_t i = 0; i < modules.size(); ++i) { for (size_t i = 0; i < modules.size(); ++i) {
std::map<std::string, std::string> module_vars = ListToDict({ std::map<std::string, std::string> module_vars =
"module.name", CapitalizeFirst(modules[i]), ListToDict({"module.name", CapitalizeFirst(modules[i]), });
});
out.Print(module_vars, "module $module.name$\n"); out.Print(module_vars, "module $module.name$\n");
out.Indent(); out.Indent();
} }

@ -178,19 +178,11 @@ static void destroy_channel_elem(grpc_channel_element* elem) {
} }
const grpc_channel_filter grpc_client_census_filter = { const grpc_channel_filter grpc_client_census_filter = {
client_call_op, channel_op, client_call_op, channel_op, sizeof(call_data),
client_init_call_elem, client_destroy_call_elem, sizeof(channel_data),
sizeof(call_data), client_init_call_elem, client_destroy_call_elem, init_channel_elem, destroy_channel_elem, "census-client"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"census-client"};
const grpc_channel_filter grpc_server_census_filter = { const grpc_channel_filter grpc_server_census_filter = {
server_call_op, channel_op, server_call_op, channel_op, sizeof(call_data),
server_init_call_elem, server_destroy_call_elem, sizeof(channel_data),
sizeof(call_data), server_init_call_elem, server_destroy_call_elem, init_channel_elem, destroy_channel_elem, "census-server"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"census-server"};

@ -76,8 +76,8 @@ size_t grpc_channel_stack_size(const grpc_channel_filter **filters,
} }
#define CHANNEL_ELEMS_FROM_STACK(stk) \ #define CHANNEL_ELEMS_FROM_STACK(stk) \
((grpc_channel_element *)((char *)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE( \ ((grpc_channel_element *)( \
sizeof(grpc_channel_stack)))) (char *)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_channel_stack))))
#define CALL_ELEMS_FROM_STACK(stk) \ #define CALL_ELEMS_FROM_STACK(stk) \
((grpc_call_element *)((char *)(stk) + \ ((grpc_call_element *)((char *)(stk) + \

@ -244,7 +244,9 @@ typedef struct {
/* A call stack tracks a set of related filters for one call, and guarantees /* A call stack tracks a set of related filters for one call, and guarantees
they live within a single malloc() allocation */ they live within a single malloc() allocation */
typedef struct { size_t count; } grpc_call_stack; typedef struct {
size_t count;
} grpc_call_stack;
/* Get a channel element given a channel stack and its index */ /* Get a channel element given a channel stack and its index */
grpc_channel_element *grpc_channel_stack_element(grpc_channel_stack *stack, grpc_channel_element *grpc_channel_stack_element(grpc_channel_stack *stack,

@ -165,14 +165,9 @@ static void lb_destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_child_channel_top_filter = { const grpc_channel_filter grpc_child_channel_top_filter = {
lb_call_op, lb_channel_op, lb_call_op, lb_channel_op, sizeof(lb_call_data),
lb_init_call_elem, lb_destroy_call_elem, sizeof(lb_channel_data),
sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem, lb_init_channel_elem, lb_destroy_channel_elem, "child-channel", };
sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem,
"child-channel",
};
/* grpc_child_channel proper */ /* grpc_child_channel proper */

@ -450,14 +450,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_client_channel_filter = { const grpc_channel_filter grpc_client_channel_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "client-channel", };
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"client-channel",
};
grpc_transport_setup_result grpc_client_channel_transport_setup_complete( grpc_transport_setup_result grpc_client_channel_transport_setup_complete(
grpc_channel_stack *channel_stack, grpc_transport *transport, grpc_channel_stack *channel_stack, grpc_transport *transport,

@ -257,14 +257,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_connected_channel_filter = { const grpc_channel_filter grpc_connected_channel_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "connected", };
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"connected",
};
static gpr_slice alloc_recv_buffer(void *user_data, grpc_transport *transport, static gpr_slice alloc_recv_buffer(void *user_data, grpc_transport *transport,
grpc_stream *stream, size_t size_hint) { grpc_stream *stream, size_t size_hint) {
@ -507,8 +502,7 @@ static void transport_closed(void *user_data, grpc_transport *transport) {
const grpc_transport_callbacks connected_channel_transport_callbacks = { const grpc_transport_callbacks connected_channel_transport_callbacks = {
alloc_recv_buffer, accept_stream, recv_batch, alloc_recv_buffer, accept_stream, recv_batch,
transport_goaway, transport_closed, transport_goaway, transport_closed, };
};
grpc_transport_setup_result grpc_connected_channel_bind_transport( grpc_transport_setup_result grpc_connected_channel_bind_transport(
grpc_channel_stack *channel_stack, grpc_transport *transport) { grpc_channel_stack *channel_stack, grpc_transport *transport) {

@ -35,7 +35,9 @@
#include <string.h> #include <string.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
typedef struct call_data { int sent_headers; } call_data; typedef struct call_data {
int sent_headers;
} call_data;
typedef struct channel_data { typedef struct channel_data {
grpc_mdelem *te_trailers; grpc_mdelem *te_trailers;
@ -178,10 +180,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_client_filter = { const grpc_channel_filter grpc_http_client_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "http-client"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"http-client"};

@ -132,10 +132,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_filter = { const grpc_channel_filter grpc_http_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "http"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"http"};

@ -244,10 +244,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_server_filter = { const grpc_channel_filter grpc_http_server_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "http-server"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"http-server"};

@ -152,7 +152,9 @@ size_t grpc_metadata_buffer_count(const grpc_metadata_buffer *buffer) {
return *buffer ? (*buffer)->elems : 0; return *buffer ? (*buffer)->elems : 0;
} }
typedef struct { grpc_metadata_buffer_impl *impl; } elems_hdr; typedef struct {
grpc_metadata_buffer_impl *impl;
} elems_hdr;
grpc_metadata *grpc_metadata_buffer_extract_elements( grpc_metadata *grpc_metadata_buffer_extract_elements(
grpc_metadata_buffer *buffer) { grpc_metadata_buffer *buffer) {

@ -131,10 +131,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_no_op_filter = { const grpc_channel_filter grpc_no_op_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "no-op"};
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"no-op"};

@ -66,8 +66,8 @@ static void adjust_downwards(grpc_alarm **first, int i, int length,
int next_i; int next_i;
if (left_child >= length) break; if (left_child >= length) break;
right_child = left_child + 1; right_child = left_child + 1;
next_i = right_child < length && next_i =
gpr_time_cmp(first[left_child]->deadline, right_child < length && gpr_time_cmp(first[left_child]->deadline,
first[right_child]->deadline) < 0 first[right_child]->deadline) < 0
? right_child ? right_child
: left_child; : left_child;

@ -255,8 +255,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd,
/* append it to the list under a lock */ /* append it to the list under a lock */
if (s->nports == s->port_capacity) { if (s->nports == s->port_capacity) {
s->port_capacity *= 2; s->port_capacity *= 2;
s->ports = s->ports = gpr_realloc(s->ports, sizeof(server_port) * s->port_capacity);
gpr_realloc(s->ports, sizeof(server_port) * s->port_capacity);
} }
sp = &s->ports[s->nports++]; sp = &s->ports[s->nports++];
sp->server = s; sp->server = s;

@ -186,8 +186,7 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
should lie */ should lie */
lower_bound = bucket_start(h, lower_idx); lower_bound = bucket_start(h, lower_idx);
upper_bound = bucket_start(h, lower_idx + 1); upper_bound = bucket_start(h, lower_idx + 1);
return GPR_CLAMP(upper_bound - return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) *
(upper_bound - lower_bound) *
(count_so_far - count_below) / (count_so_far - count_below) /
h->buckets[lower_idx], h->buckets[lower_idx],
h->min_seen, h->max_seen); h->min_seen, h->max_seen);

@ -38,9 +38,13 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
typedef struct { void *unused; } call_data; typedef struct {
void *unused;
} call_data;
typedef struct { void *unused; } channel_data; typedef struct {
void *unused;
} channel_data;
static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, static void call_op(grpc_call_element *elem, grpc_call_element *from_elem,
grpc_call_op *op) { grpc_call_op *op) {
@ -109,11 +113,6 @@ static void init_channel_elem(grpc_channel_element *elem,
static void destroy_channel_elem(grpc_channel_element *elem) {} static void destroy_channel_elem(grpc_channel_element *elem) {}
const grpc_channel_filter grpc_client_surface_filter = { const grpc_channel_filter grpc_client_surface_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "client", };
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"client",
};

@ -42,9 +42,13 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
typedef struct { void *unused; } call_data; typedef struct {
void *unused;
} call_data;
typedef struct { grpc_mdelem *message; } channel_data; typedef struct {
grpc_mdelem *message;
} channel_data;
static void do_nothing(void *data, grpc_op_error error) {} static void do_nothing(void *data, grpc_op_error error) {}
@ -111,14 +115,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
static const grpc_channel_filter lame_filter = { static const grpc_channel_filter lame_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "lame-client", };
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"lame-client",
};
grpc_channel *grpc_lame_client_channel_create(void) { grpc_channel *grpc_lame_client_channel_create(void) {
static const grpc_channel_filter *filters[] = {&lame_filter}; static const grpc_channel_filter *filters[] = {&lame_filter};

@ -411,14 +411,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
static const grpc_channel_filter server_surface_filter = { static const grpc_channel_filter server_surface_filter = {
call_op, channel_op, call_op, channel_op, sizeof(call_data),
init_call_elem, destroy_call_elem, sizeof(channel_data),
sizeof(call_data), init_call_elem, destroy_call_elem, init_channel_elem, destroy_channel_elem, "server", };
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"server",
};
static void early_terminate_requested_calls(grpc_completion_queue *cq, static void early_terminate_requested_calls(grpc_completion_queue *cq,
void **tags, size_t ntags) { void **tags, size_t ntags) {

@ -53,8 +53,7 @@ const grpc_chttp2_setting_parameters
{"MAX_FRAME_SIZE", 16384, 16384, 16777215, {"MAX_FRAME_SIZE", 16384, 16384, 16777215,
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE}, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE},
{"MAX_HEADER_LIST_SIZE", 0xffffffffu, 0, 0xffffffffu, {"MAX_HEADER_LIST_SIZE", 0xffffffffu, 0, 0xffffffffu,
GRPC_CHTTP2_CLAMP_INVALID_VALUE}, GRPC_CHTTP2_CLAMP_INVALID_VALUE}, };
};
static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length, static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length,
gpr_uint8 flags) { gpr_uint8 flags) {

@ -55,8 +55,7 @@ typedef struct {
unsigned char index; unsigned char index;
} spec; } spec;
static const spec fields[] = { static const spec fields[] = {{"INDEXED_FIELD", 0X80, 1, 1},
{"INDEXED_FIELD", 0X80, 1, 1},
{"INDEXED_FIELD_X", 0X80, 1, 2}, {"INDEXED_FIELD_X", 0X80, 1, 2},
{"LITHDR_INCIDX", 0X40, 2, 1}, {"LITHDR_INCIDX", 0X40, 2, 1},
{"LITHDR_INCIDX_X", 0X40, 2, 2}, {"LITHDR_INCIDX_X", 0X40, 2, 2},
@ -68,8 +67,7 @@ static const spec fields[] = {
{"LITHDR_NVRIDX_X", 0X10, 4, 2}, {"LITHDR_NVRIDX_X", 0X10, 4, 2},
{"LITHDR_NVRIDX_V", 0X10, 4, 0}, {"LITHDR_NVRIDX_V", 0X10, 4, 0},
{"MAX_TBL_SIZE", 0X20, 3, 1}, {"MAX_TBL_SIZE", 0X20, 3, 1},
{"MAX_TBL_SIZE_X", 0X20, 3, 2}, {"MAX_TBL_SIZE_X", 0X20, 3, 2}, };
};
static const int num_fields = sizeof(fields) / sizeof(*fields); static const int num_fields = sizeof(fields) / sizeof(*fields);
@ -131,9 +129,13 @@ static void generate_first_byte_lut(void) {
#define MAXHUFFSTATES 1024 #define MAXHUFFSTATES 1024
/* represents a set of symbols as an array of booleans indicating inclusion */ /* represents a set of symbols as an array of booleans indicating inclusion */
typedef struct { char included[GRPC_CHTTP2_NUM_HUFFSYMS]; } symset; typedef struct {
char included[GRPC_CHTTP2_NUM_HUFFSYMS];
} symset;
/* represents a lookup table indexed by a nibble */ /* represents a lookup table indexed by a nibble */
typedef struct { int values[16]; } nibblelut; typedef struct {
int values[16];
} nibblelut;
/* returns a symset that includes all possible symbols */ /* returns a symset that includes all possible symbols */
static symset symset_all(void) { static symset symset_all(void) {

@ -221,8 +221,7 @@ static const gpr_uint8 first_byte_lut[256] = {
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD_X, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD_X, };
};
/* state table for huffman decoding: given a state, gives an index/16 into /* state table for huffman decoding: given a state, gives an index/16 into
next_sub_tbl. Taking that index and adding the value of the nibble being next_sub_tbl. Taking that index and adding the value of the nibble being
@ -242,8 +241,7 @@ static const gpr_uint8 next_tbl[256] = {
38, 1, 1, 1, 1, 1, 1, 1, 15, 2, 2, 2, 2, 26, 3, 3, 39, 1, 1, 1, 38, 1, 1, 1, 1, 1, 1, 1, 15, 2, 2, 2, 2, 26, 3, 3, 39, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 7, 3, 3, 3, 40, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 7, 3, 3, 3, 40, 2,
41, 1, 1, 1, 42, 43, 1, 1, 44, 1, 1, 1, 1, 15, 2, 2, 2, 2, 2, 2, 41, 1, 1, 1, 42, 43, 1, 1, 44, 1, 1, 1, 1, 15, 2, 2, 2, 2, 2, 2,
3, 3, 3, 45, 46, 1, 1, 2, 2, 2, 35, 3, 3, 18, 47, 2, 3, 3, 3, 45, 46, 1, 1, 2, 2, 2, 35, 3, 3, 18, 47, 2, };
};
/* next state, based upon current state and the current nibble: see above. /* next state, based upon current state and the current nibble: see above.
generated by gen_hpack_tables.c */ generated by gen_hpack_tables.c */
static const gpr_int16 next_sub_tbl[48 * 16] = { static const gpr_int16 next_sub_tbl[48 * 16] = {
@ -298,8 +296,7 @@ static const gpr_int16 next_sub_tbl[48 * 16] = {
4, 8, 4, 8, 4, 8, 4, 8, 4, 8, 0, 0, 0, 0, 0, 4, 8, 4, 8, 4, 8, 4, 8, 4, 8, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 245, 246, 247, 248, 249, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 245, 246, 247, 248, 249, 250, 251, 252,
253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 255, 0, 0, 255, };
};
/* emission table: indexed like next_tbl, ultimately gives the byte to be /* emission table: indexed like next_tbl, ultimately gives the byte to be
emitted, or -1 for no byte, or 256 for end of stream emitted, or -1 for no byte, or 256 for end of stream
@ -322,8 +319,7 @@ static const gpr_uint16 emit_tbl[256] = {
204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
219, 220, 221, 0, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 219, 220, 221, 0, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
248, 248, };
};
/* generated by gen_hpack_tables.c */ /* generated by gen_hpack_tables.c */
static const gpr_int16 emit_sub_tbl[249 * 16] = { static const gpr_int16 emit_sub_tbl[249 * 16] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@ -591,8 +587,7 @@ static const gpr_int16 emit_sub_tbl[249 * 16] = {
251, 251, 252, 252, 253, 253, 254, 254, 2, 3, 4, 5, 6, 7, 8, 251, 251, 252, 252, 253, 253, 254, 254, 2, 3, 4, 5, 6, 7, 8,
11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27,
28, 29, 30, 31, 127, 220, 249, -1, 10, 10, 10, 10, 13, 13, 13, 28, 29, 30, 31, 127, 220, 249, -1, 10, 10, 10, 10, 13, 13, 13,
13, 22, 22, 22, 22, 256, 256, 256, 256, 13, 22, 22, 22, 22, 256, 256, 256, 256, };
};
static const gpr_uint8 inverse_base64[256] = { static const gpr_uint8 inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
@ -612,8 +607,7 @@ static const gpr_uint8 inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, };
};
/* emission helpers */ /* emission helpers */
static void on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md, static void on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md,

@ -104,8 +104,7 @@ static struct {
/* 58: */ {"user-agent", ""}, /* 58: */ {"user-agent", ""},
/* 59: */ {"vary", ""}, /* 59: */ {"vary", ""},
/* 60: */ {"via", ""}, /* 60: */ {"via", ""},
/* 61: */ {"www-authenticate", ""}, /* 61: */ {"www-authenticate", ""}, };
};
void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) { void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) {
size_t i; size_t i;

@ -293,5 +293,4 @@ const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS] = {
{0x7ffffef, 27}, {0x7ffffef, 27},
{0x7fffff0, 27}, {0x7fffff0, 27},
{0x3ffffee, 26}, {0x3ffffee, 26},
{0x3fffffff, 30}, {0x3fffffff, 30}, };
};

@ -66,7 +66,8 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
} else { \ } else { \
(tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ (tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
grpc_chttp2_hpack_write_varint_tail( \ grpc_chttp2_hpack_write_varint_tail( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt)+1, (length)-1); \ (n) - GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, \
(length) - 1); \
} \ } \
} while (0) } while (0)

@ -1503,8 +1503,8 @@ static int process_read(transport *t, gpr_slice slice) {
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) " "Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
"at byte %d", "at byte %d",
CLIENT_CONNECT_STRING[t->deframe_state], CLIENT_CONNECT_STRING[t->deframe_state],
(int)(gpr_uint8) CLIENT_CONNECT_STRING[t->deframe_state], (int)(gpr_uint8)CLIENT_CONNECT_STRING[t->deframe_state], *cur,
*cur, (int)*cur, t->deframe_state); (int)*cur, t->deframe_state);
drop_connection(t); drop_connection(t);
return 0; return 0;
} }

@ -369,8 +369,7 @@ static void fake_protector_destroy(tsi_frame_protector* self) {
static const tsi_frame_protector_vtable frame_protector_vtable = { static const tsi_frame_protector_vtable frame_protector_vtable = {
fake_protector_protect, fake_protector_protect_flush, fake_protector_protect, fake_protector_protect_flush,
fake_protector_unprotect, fake_protector_destroy, fake_protector_unprotect, fake_protector_destroy, };
};
/* --- tsi_handshaker methods implementation. ---*/ /* --- tsi_handshaker methods implementation. ---*/
@ -485,8 +484,7 @@ static const tsi_handshaker_vtable handshaker_vtable = {
fake_handshaker_get_result, fake_handshaker_get_result,
fake_handshaker_extract_peer, fake_handshaker_extract_peer,
fake_handshaker_create_frame_protector, fake_handshaker_create_frame_protector,
fake_handshaker_destroy, fake_handshaker_destroy, };
};
tsi_handshaker* tsi_create_fake_handshaker(int is_client) { tsi_handshaker* tsi_create_fake_handshaker(int is_client) {
tsi_fake_handshaker* impl = calloc(1, sizeof(tsi_fake_handshaker)); tsi_fake_handshaker* impl = calloc(1, sizeof(tsi_fake_handshaker));

@ -703,8 +703,7 @@ static void ssl_protector_destroy(tsi_frame_protector* self) {
static const tsi_frame_protector_vtable frame_protector_vtable = { static const tsi_frame_protector_vtable frame_protector_vtable = {
ssl_protector_protect, ssl_protector_protect_flush, ssl_protector_unprotect, ssl_protector_protect, ssl_protector_protect_flush, ssl_protector_unprotect,
ssl_protector_destroy, ssl_protector_destroy, };
};
/* --- tsi_handshaker methods implementation. ---*/ /* --- tsi_handshaker methods implementation. ---*/
@ -877,8 +876,7 @@ static const tsi_handshaker_vtable handshaker_vtable = {
ssl_handshaker_get_result, ssl_handshaker_get_result,
ssl_handshaker_extract_peer, ssl_handshaker_extract_peer,
ssl_handshaker_create_frame_protector, ssl_handshaker_create_frame_protector,
ssl_handshaker_destroy, ssl_handshaker_destroy, };
};
/* --- tsi_ssl_handshaker_factory common methods. --- */ /* --- tsi_ssl_handshaker_factory common methods. --- */

@ -157,8 +157,7 @@ NAN_METHOD(Credentials::CreateSsl) {
} }
NanReturnValue(WrapStruct(grpc_ssl_credentials_create( NanReturnValue(WrapStruct(grpc_ssl_credentials_create(
root_certs, root_certs, key_cert_pair.private_key == NULL ? NULL : &key_cert_pair)));
key_cert_pair.private_key == NULL ? NULL : &key_cert_pair)));
} }
NAN_METHOD(Credentials::CreateComposite) { NAN_METHOD(Credentials::CreateComposite) {

@ -230,8 +230,8 @@ static VALUE grpc_rb_credentials_init(int argc, VALUE *argv, VALUE self) {
} else { } else {
grpc_ssl_pem_key_cert_pair key_cert_pair = {RSTRING_PTR(pem_private_key), grpc_ssl_pem_key_cert_pair key_cert_pair = {RSTRING_PTR(pem_private_key),
RSTRING_PTR(pem_cert_chain)}; RSTRING_PTR(pem_cert_chain)};
creds = grpc_ssl_credentials_create( creds = grpc_ssl_credentials_create(RSTRING_PTR(pem_root_certs),
RSTRING_PTR(pem_root_certs), &key_cert_pair); &key_cert_pair);
} }
if (creds == NULL) { if (creds == NULL) {
rb_raise(rb_eRuntimeError, "could not create a credentials, not sure why"); rb_raise(rb_eRuntimeError, "could not create a credentials, not sure why");

@ -77,13 +77,10 @@ static void channel_func(grpc_channel_element *elem,
} }
static void test_create_channel_stack(void) { static void test_create_channel_stack(void) {
const grpc_channel_filter filter = { const grpc_channel_filter
call_func, channel_func, filter = {call_func, channel_func, sizeof(int),
call_init_func, call_destroy_func, sizeof(int),
sizeof(int), call_init_func, call_destroy_func, channel_init_func, channel_destroy_func, };
sizeof(int), channel_init_func, channel_destroy_func,
};
const grpc_channel_filter *filters = &filter; const grpc_channel_filter *filters = &filter;
grpc_channel_stack *channel_stack; grpc_channel_stack *channel_stack;
grpc_call_stack *call_stack; grpc_call_stack *call_stack;

@ -117,8 +117,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack, chttp2_create_fixture_secure_fullstack,
chttp2_init_client_fake_secure_fullstack, chttp2_init_client_fake_secure_fullstack,
chttp2_init_server_fake_secure_fullstack, chttp2_init_server_fake_secure_fullstack,
chttp2_tear_down_secure_fullstack}, chttp2_tear_down_secure_fullstack}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -99,8 +99,7 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = { static grpc_end2end_test_config configs[] = {
{"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION,
chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -125,8 +125,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack, chttp2_create_fixture_secure_fullstack,
chttp2_init_client_simple_ssl_secure_fullstack, chttp2_init_client_simple_ssl_secure_fullstack,
chttp2_init_server_simple_ssl_secure_fullstack, chttp2_init_server_simple_ssl_secure_fullstack,
chttp2_tear_down_secure_fullstack}, chttp2_tear_down_secure_fullstack}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -99,7 +99,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
grpc_credentials *ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL); grpc_credentials *ssl_creds =
grpc_ssl_credentials_create(test_root_cert, NULL);
grpc_credentials *oauth2_creds = grpc_credentials *oauth2_creds =
grpc_fake_oauth2_credentials_create("Bearer aaslkfjs424535asdf", 1); grpc_fake_oauth2_credentials_create("Bearer aaslkfjs424535asdf", 1);
grpc_credentials *ssl_oauth2_creds = grpc_credentials *ssl_oauth2_creds =
@ -132,8 +133,7 @@ static grpc_end2end_test_config configs[] = {
chttp2_create_fixture_secure_fullstack, chttp2_create_fixture_secure_fullstack,
chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack, chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack,
chttp2_init_server_simple_ssl_secure_fullstack, chttp2_init_server_simple_ssl_secure_fullstack,
chttp2_tear_down_secure_fullstack}, chttp2_tear_down_secure_fullstack}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -133,8 +133,7 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = { static grpc_end2end_test_config configs[] = {
{"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair,
chttp2_init_client_socketpair, chttp2_init_server_socketpair, chttp2_init_client_socketpair, chttp2_init_server_socketpair,
chttp2_tear_down_socketpair}, chttp2_tear_down_socketpair}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -133,8 +133,7 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) {
static grpc_end2end_test_config configs[] = { static grpc_end2end_test_config configs[] = {
{"chttp2/socketpair_one_byte_at_a_time", 0, {"chttp2/socketpair_one_byte_at_a_time", 0,
chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, chttp2_create_fixture_socketpair, chttp2_init_client_socketpair,
chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
size_t i; size_t i;

@ -46,7 +46,6 @@ static grpc_call_error wait_for_deadline(grpc_call *call) {
static const cancellation_mode cancellation_modes[] = { static const cancellation_mode cancellation_modes[] = {
{grpc_call_cancel, GRPC_STATUS_CANCELLED, NULL}, {grpc_call_cancel, GRPC_STATUS_CANCELLED, NULL},
{wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, {wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, };
};
#endif #endif

@ -98,8 +98,7 @@ typedef struct {
static const scenario scenarios[] = { static const scenario scenarios[] = {
{"ping-pong-request", init_ping_pong_request, step_ping_pong_request}, {"ping-pong-request", init_ping_pong_request, step_ping_pong_request},
{"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream}, {"ping-pong-stream", init_ping_pong_stream, step_ping_pong_stream}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
gpr_slice slice = gpr_slice_from_copied_string("x"); gpr_slice slice = gpr_slice_from_copied_string("x");

@ -83,9 +83,8 @@ static void test_ipv6_with_port(void) {
} }
static void test_ipv6_without_port(void) { static void test_ipv6_without_port(void) {
const char* const kCases[] = { const char* const kCases[] = {"2001:db8::1", "2001:db8::1.2.3.4",
"2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]", "[2001:db8::1]", };
};
int i; int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev; gpr_event ev;
@ -96,9 +95,7 @@ static void test_ipv6_without_port(void) {
} }
static void test_invalid_ip_addresses(void) { static void test_invalid_ip_addresses(void) {
const char* const kCases[] = { const char* const kCases[] = {"293.283.1238.3:1", "[2001:db8::11111]:1", };
"293.283.1238.3:1", "[2001:db8::11111]:1",
};
int i; int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev; gpr_event ev;
@ -109,9 +106,8 @@ static void test_invalid_ip_addresses(void) {
} }
static void test_unparseable_hostports(void) { static void test_unparseable_hostports(void) {
const char* const kCases[] = { const char* const kCases[] = {"[", "[::1", "[::1]bad",
"[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1", "[1.2.3.4]", "[localhost]", "[localhost]:1", };
};
int i; int i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
gpr_event ev; gpr_event ev;

@ -484,8 +484,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
} }
static grpc_endpoint_test_config configs[] = { static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, };
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);

@ -131,8 +131,7 @@ static grpc_endpoint_test_config configs[] = {
{"secure_ep/tcp_socketpair", {"secure_ep/tcp_socketpair",
secure_endpoint_create_fixture_tcp_socketpair_noleftover, clean_up}, secure_endpoint_create_fixture_tcp_socketpair_noleftover, clean_up},
{"secure_ep/tcp_socketpair_leftover", {"secure_ep/tcp_socketpair_leftover",
secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up}, secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up}, };
};
static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices, static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices,
grpc_endpoint_cb_status error) { grpc_endpoint_cb_status error) {

@ -58,8 +58,8 @@ static void producer_thread(void *arg) {
for (i = 0; i < opt->iterations; i++) { for (i = 0; i < opt->iterations; i++) {
grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED); grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED);
grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL, grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
NULL, GRPC_OP_OK); GRPC_OP_OK);
} }
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);

@ -296,8 +296,8 @@ static void producer_thread(void *arg) {
gpr_log(GPR_INFO, "producer %d phase 2", opt->id); gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) { for (i = 0; i < TEST_THREAD_EVENTS; i++) {
grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL, grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL,
NULL, GRPC_OP_OK); GRPC_OP_OK);
opt->events_triggered++; opt->events_triggered++;
} }

@ -42,7 +42,9 @@
#include "test/core/util/slice_splitter.h" #include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
typedef struct { va_list args; } test_checker; typedef struct {
va_list args;
} test_checker;
static void onhdr(void *ud, grpc_mdelem *md) { static void onhdr(void *ud, grpc_mdelem *md) {
const char *ekey, *evalue; const char *ekey, *evalue;

@ -100,8 +100,7 @@ grpc_transport_test_config fixture_configs[] = {
{"chttp2_on_socketpair/medium", {"chttp2_on_socketpair/medium",
create_http2_transport_for_test_medium_slices}, create_http2_transport_for_test_medium_slices},
{"chttp2_on_socketpair/large", {"chttp2_on_socketpair/large",
create_http2_transport_for_test_large_slices}, create_http2_transport_for_test_large_slices}, };
};
/* Driver function: run the test suite for each test configuration */ /* Driver function: run the test suite for each test configuration */
int main(int argc, char **argv) { int main(int argc, char **argv) {

@ -63,7 +63,9 @@ static int g_pending_ops;
typedef struct test_fixture test_fixture; typedef struct test_fixture test_fixture;
/* User data passed to the transport and handed to each callback */ /* User data passed to the transport and handed to each callback */
typedef struct test_user_data { test_fixture *fixture; } test_user_data; typedef struct test_user_data {
test_fixture *fixture;
} test_user_data;
/* A message we expect to receive (forms a singly linked list with next) */ /* A message we expect to receive (forms a singly linked list with next) */
typedef struct expected_message { typedef struct expected_message {
@ -589,8 +591,7 @@ static void begin_test(test_fixture *f, grpc_transport_test_config *config,
f->client_transport = NULL; f->client_transport = NULL;
f->server_transport = NULL; f->server_transport = NULL;
GPR_ASSERT(0 == GPR_ASSERT(0 == config->create_transport(setup_client_transport, f,
config->create_transport(setup_client_transport, f,
setup_server_transport, f, setup_server_transport, f,
g_metadata_context)); g_metadata_context));
@ -908,9 +909,8 @@ static void test_ping(grpc_transport_test_config *config) {
* Test driver * Test driver
*/ */
static const size_t interesting_message_lengths[] = { static const size_t interesting_message_lengths[] = {1, 100, 10000,
1, 100, 10000, 100000, 1000000, 100000, 1000000, };
};
void grpc_transport_end2end_tests(grpc_transport_test_config *config) { void grpc_transport_end2end_tests(grpc_transport_test_config *config) {
int i; int i;

@ -113,12 +113,11 @@ int grpc_pick_unused_port(void) {
/* Type of port to first pick in next iteration */ /* Type of port to first pick in next iteration */
int is_tcp = 1; int is_tcp = 1;
int try int try = 0;
= 0;
for (;;) { for (;;) {
int port = try int port =
< NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0; try < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0;
if (!is_port_available(&port, is_tcp)) { if (!is_port_available(&port, is_tcp)) {
continue; continue;
} }

@ -134,19 +134,22 @@ void RunTest(const int client_threads, const int client_channels,
GPR_ASSERT(hist != NULL); GPR_ASSERT(hist != NULL);
thread_stats[i] = hist; thread_stats[i] = hist;
threads.push_back(std::thread( threads.push_back(
[hist, client_threads, client_channels, num_rpcs, payload_size, std::thread([hist, client_threads, client_channels, num_rpcs,
&channels](int channel_num) { payload_size, &channels](int channel_num) {
SimpleRequest request; SimpleRequest request;
SimpleResponse response; SimpleResponse response;
request.set_response_type(grpc::testing::PayloadType::COMPRESSABLE); request.set_response_type(
grpc::testing::PayloadType::COMPRESSABLE);
request.set_response_size(payload_size); request.set_response_size(payload_size);
for (int j = 0; j < num_rpcs; j++) { for (int j = 0; j < num_rpcs; j++) {
TestService::Stub *stub = channels[channel_num].get_stub(); TestService::Stub *stub =
channels[channel_num].get_stub();
double start = now(); double start = now();
grpc::ClientContext context; grpc::ClientContext context;
grpc::Status s = stub->UnaryCall(&context, request, &response); grpc::Status s =
stub->UnaryCall(&context, request, &response);
gpr_histogram_add(hist, now() - start); gpr_histogram_add(hist, now() - start);
GPR_ASSERT((s.code() == grpc::StatusCode::OK) && GPR_ASSERT((s.code() == grpc::StatusCode::OK) &&
@ -155,7 +158,8 @@ void RunTest(const int client_threads, const int client_channels,
(response.payload().body().length() == (response.payload().body().length() ==
static_cast<size_t>(payload_size))); static_cast<size_t>(payload_size)));
// Now do runtime round-robin assignment of the next channel number // Now do runtime round-robin assignment of the next
// channel number
channel_num += client_threads; channel_num += client_threads;
channel_num %= client_channels; channel_num %= client_channels;
} }

@ -72,7 +72,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& connect_to = const grpc::string& connect_to =
server.empty() ? override_hostname : server; server.empty() ? override_hostname : server;
if (creds.get()) { if (creds.get()) {
channel_creds = CredentialsFactory::ComposeCredentials(creds, channel_creds); channel_creds =
CredentialsFactory::ComposeCredentials(creds, channel_creds);
} }
return CreateChannel(connect_to, channel_creds, channel_args); return CreateChannel(connect_to, channel_creds, channel_args);
} else { } else {
@ -83,7 +84,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
std::shared_ptr<ChannelInterface> CreateTestChannel( std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname, const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots) { bool enable_ssl, bool use_prod_roots) {
return CreateTestChannel(server, override_hostname, enable_ssl, use_prod_roots, std::unique_ptr<Credentials>()); return CreateTestChannel(server, override_hostname, enable_ssl,
use_prod_roots, std::unique_ptr<Credentials>());
} }
// Shortcut for end2end and interop tests. // Shortcut for end2end and interop tests.

@ -37,6 +37,7 @@
#include <memory> #include <memory>
#include <grpc++/config.h> #include <grpc++/config.h>
#include <grpc++/credentials.h>
namespace grpc { namespace grpc {
class ChannelInterface; class ChannelInterface;
@ -50,7 +51,8 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
std::shared_ptr<ChannelInterface> CreateTestChannel( std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname, const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots, const std::unique_ptr<Credentials>& creds); bool enable_ssl, bool use_prod_roots,
const std::unique_ptr<Credentials>& creds);
} // namespace grpc } // namespace grpc

Loading…
Cancel
Save