clang-format

pull/8303/head
Mark D. Roth 9 years ago
parent 72d0b1615f
commit afa8c1051e
  1. 10
      include/grpc/impl/codegen/grpc_types.h
  2. 16
      src/core/ext/client_config/client_channel.c
  3. 18
      src/core/ext/client_config/method_config.c
  4. 32
      src/core/ext/resolver/sockaddr/sockaddr_resolver.c
  5. 8
      src/core/lib/channel/message_size_filter.c
  6. 4
      src/core/lib/transport/hashtable.c
  7. 2
      src/core/lib/transport/hashtable.h
  8. 16
      test/core/client_config/resolvers/sockaddr_resolver_test.c

@ -263,7 +263,7 @@ typedef enum grpc_call_error {
#define GRPC_INITIAL_METADATA_WAIT_FOR_READY (0x00000020u)
/** DEPRECATED: for backward compatibility */
#define GRPC_INITIAL_METADATA_IGNORE_CONNECTIVITY \
GRPC_INITIAL_METADATA_WAIT_FOR_READY
GRPC_INITIAL_METADATA_WAIT_FOR_READY
/** Signal that the call is cacheable. GRPC is free to use GET verb */
#define GRPC_INITIAL_METADATA_CACHEABLE_REQUEST (0x00000040u)
/** Signal that GRPC_INITIAL_METADATA_WAIT_FOR_READY was explicitly set
@ -271,10 +271,10 @@ typedef enum grpc_call_error {
#define GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET (0x00000080u)
/** Mask of all valid flags */
#define GRPC_INITIAL_METADATA_USED_MASK \
(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST | \
GRPC_INITIAL_METADATA_WAIT_FOR_READY | \
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST | \
#define GRPC_INITIAL_METADATA_USED_MASK \
(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST | \
GRPC_INITIAL_METADATA_WAIT_FOR_READY | \
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST | \
GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET)
/** A single metadata element */

@ -421,8 +421,11 @@ typedef struct client_channel_call_data {
grpc_deadline_state deadline_state;
gpr_timespec deadline;
enum { WAIT_FOR_READY_UNSET, WAIT_FOR_READY_FALSE, WAIT_FOR_READY_TRUE }
wait_for_ready_from_service_config;
enum {
WAIT_FOR_READY_UNSET,
WAIT_FOR_READY_FALSE,
WAIT_FOR_READY_TRUE
} wait_for_ready_from_service_config;
// Request path.
grpc_mdstr *path;
@ -798,14 +801,13 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx,
: grpc_method_config_table_ref(chand->method_config_table);
gpr_mu_unlock(&chand->mu);
grpc_method_config *method_config =
method_config_table == NULL
? NULL
: grpc_method_config_table_get_method_config(method_config_table,
args->path);
method_config_table == NULL ? NULL
: grpc_method_config_table_get_method_config(
method_config_table, args->path);
grpc_deadline_state_init(exec_ctx, elem, args, method_config);
calld->wait_for_ready_from_service_config = WAIT_FOR_READY_UNSET;
if (method_config != NULL) {
bool* wait_for_ready = grpc_method_config_get_wait_for_ready(method_config);
bool *wait_for_ready = grpc_method_config_get_wait_for_ready(method_config);
if (wait_for_ready != NULL) {
calld->wait_for_ready_from_service_config =
*wait_for_ready ? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE;

@ -78,8 +78,8 @@ static int timespec_cmp(void* v1, void* v2) {
return gpr_time_cmp(*(gpr_timespec*)v1, *(gpr_timespec*)v2);
}
static grpc_hash_table_vtable timespec_vtable = {
gpr_free, timespec_copy, timespec_cmp};
static grpc_hash_table_vtable timespec_vtable = {gpr_free, timespec_copy,
timespec_cmp};
// int32 vtable
@ -102,11 +102,11 @@ static grpc_hash_table_vtable int32_vtable = {gpr_free, int32_copy, int32_cmp};
// Hash table keys.
#define GRPC_METHOD_CONFIG_WAIT_FOR_READY "grpc.wait_for_ready" // bool
#define GRPC_METHOD_CONFIG_TIMEOUT "grpc.timeout" // gpr_timespec
#define GRPC_METHOD_CONFIG_TIMEOUT "grpc.timeout" // gpr_timespec
#define GRPC_METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES \
"grpc.max_request_message_bytes" // int32
"grpc.max_request_message_bytes" // int32
#define GRPC_METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES \
"grpc.max_response_message_bytes" // int32
"grpc.max_response_message_bytes" // int32
struct grpc_method_config {
grpc_hash_table* table;
@ -265,13 +265,9 @@ grpc_method_config* grpc_method_config_table_get_method_config(
return method_config;
}
static void* copy_arg(void* p) {
return grpc_method_config_table_ref(p);
}
static void* copy_arg(void* p) { return grpc_method_config_table_ref(p); }
static void destroy_arg(void* p) {
grpc_method_config_table_unref(p);
}
static void destroy_arg(void* p) { grpc_method_config_table_unref(p); }
static int cmp_arg(void* p1, void* p2) {
return grpc_method_config_table_cmp(p1, p2);

@ -127,8 +127,8 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
r->published = true;
grpc_channel_args *lb_policy_args = NULL;
if (r->method_config_table != NULL) {
const grpc_arg arg = grpc_method_config_table_create_channel_arg(
r->method_config_table);
const grpc_arg arg =
grpc_method_config_table_create_channel_arg(r->method_config_table);
lb_policy_args = grpc_channel_args_copy_and_add(NULL /* src */, &arg, 1);
}
*r->target_result = grpc_resolver_result_create(
@ -246,29 +246,31 @@ static grpc_resolver *sockaddr_create(
// Anything other than "0" is interpreted as true.
bool wait_for_ready =
wait_for_ready_str != NULL && strcmp("0", wait_for_ready_str) != 0;
const char* timeout_str =
const char *timeout_str =
grpc_uri_get_query_arg(args->uri, "timeout_seconds");
gpr_timespec timeout = {
timeout_str == NULL ? 0 : atoi(timeout_str), 0, GPR_CLOCK_MONOTONIC};
const char* max_request_message_bytes_str =
gpr_timespec timeout = {timeout_str == NULL ? 0 : atoi(timeout_str), 0,
GPR_CLOCK_MONOTONIC};
const char *max_request_message_bytes_str =
grpc_uri_get_query_arg(args->uri, "max_request_message_bytes");
int32_t max_request_message_bytes =
max_request_message_bytes_str == NULL
? 0 : atoi(max_request_message_bytes_str);
const char* max_response_message_bytes_str =
? 0
: atoi(max_request_message_bytes_str);
const char *max_response_message_bytes_str =
grpc_uri_get_query_arg(args->uri, "max_response_message_bytes");
int32_t max_response_message_bytes =
max_response_message_bytes_str == NULL
? 0 : atoi(max_response_message_bytes_str);
? 0
: atoi(max_response_message_bytes_str);
grpc_method_config *method_config = grpc_method_config_create(
wait_for_ready_str == NULL ? NULL : &wait_for_ready,
timeout_str == NULL ? NULL : &timeout,
max_request_message_bytes_str == NULL
? NULL : &max_request_message_bytes,
max_response_message_bytes_str == NULL
? NULL : &max_response_message_bytes);
grpc_method_config_table_entry entry = {
grpc_mdstr_from_string(method_name), method_config};
max_request_message_bytes_str == NULL ? NULL
: &max_request_message_bytes,
max_response_message_bytes_str == NULL ? NULL
: &max_response_message_bytes);
grpc_method_config_table_entry entry = {grpc_mdstr_from_string(method_name),
method_config};
r->method_config_table = grpc_method_config_table_create(1, &entry);
GRPC_MDSTR_UNREF(entry.method_name);
grpc_method_config_unref(method_config);

@ -38,8 +38,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/ext/client_config/method_config.h"
#include "src/core/lib/channel/channel_args.h"
#define DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 // Unlimited.
// The protobuf library will (by default) start warning at 100 megs.
@ -181,12 +181,12 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx,
}
}
// Get method config table from channel args.
const grpc_arg *channel_arg = grpc_channel_args_find(
args->channel_args, GRPC_ARG_SERVICE_CONFIG);
const grpc_arg* channel_arg =
grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG);
if (channel_arg != NULL) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER);
chand->method_config_table = grpc_method_config_table_ref(
(grpc_method_config_table *)channel_arg->value.pointer.p);
(grpc_method_config_table*)channel_arg->value.pointer.p);
}
}

@ -47,8 +47,8 @@ struct grpc_hash_table {
// Helper function for insert and get operations that performs quadratic
// probing (https://en.wikipedia.org/wiki/Quadratic_probing).
static size_t grpc_hash_table_find_index(
grpc_hash_table* table, grpc_mdstr* key, bool find_empty) {
static size_t grpc_hash_table_find_index(grpc_hash_table* table,
grpc_mdstr* key, bool find_empty) {
for (size_t i = 0; i < table->num_entries; ++i) {
const size_t idx = (key->hash + i * i) % table->num_entries;
if (table->entries[idx].key == NULL)

@ -58,7 +58,7 @@ typedef struct grpc_hash_table_vtable {
typedef struct grpc_hash_table_entry {
grpc_mdstr* key;
void* value; /* Must not be NULL. */
void* value; /* Must not be NULL. */
const grpc_hash_table_vtable* vtable;
} grpc_hash_table_entry;

@ -61,8 +61,8 @@ void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
if (res->expected_method_name == NULL) {
GPR_ASSERT(lb_policy_args == NULL);
} else {
const grpc_arg *channel_arg = grpc_channel_args_find(
lb_policy_args, GRPC_ARG_SERVICE_CONFIG);
const grpc_arg *channel_arg =
grpc_channel_args_find(lb_policy_args, GRPC_ARG_SERVICE_CONFIG);
GPR_ASSERT(channel_arg != NULL);
GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER);
grpc_method_config_table *method_config_table =
@ -73,18 +73,18 @@ void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_method_config_table_get_method_config(method_config_table, path);
GRPC_MDSTR_UNREF(path);
GPR_ASSERT(method_config != NULL);
bool* wait_for_ready = grpc_method_config_get_wait_for_ready(method_config);
bool *wait_for_ready = grpc_method_config_get_wait_for_ready(method_config);
GPR_ASSERT(wait_for_ready != NULL);
GPR_ASSERT(*wait_for_ready == res->expected_wait_for_ready);
gpr_timespec* timeout = grpc_method_config_get_timeout(method_config);
gpr_timespec *timeout = grpc_method_config_get_timeout(method_config);
GPR_ASSERT(timeout != NULL);
GPR_ASSERT(gpr_time_cmp(*timeout, res->expected_timeout) == 0);
int32_t* max_request_message_bytes =
int32_t *max_request_message_bytes =
grpc_method_config_get_max_request_message_bytes(method_config);
GPR_ASSERT(max_request_message_bytes != NULL);
GPR_ASSERT(*max_request_message_bytes ==
res->expected_max_request_message_bytes);
int32_t* max_response_message_bytes =
int32_t *max_response_message_bytes =
grpc_method_config_get_max_response_message_bytes(method_config);
GPR_ASSERT(max_response_message_bytes != NULL);
GPR_ASSERT(*max_response_message_bytes ==
@ -117,8 +117,8 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
}
static void test_succeeds_with_service_config(
grpc_resolver_factory *factory, const char *string,
const char *method_name, bool wait_for_ready, gpr_timespec timeout,
grpc_resolver_factory *factory, const char *string, const char *method_name,
bool wait_for_ready, gpr_timespec timeout,
int32_t max_request_message_bytes, int32_t max_response_message_bytes) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_uri *uri = grpc_uri_parse(string, 0);

Loading…
Cancel
Save