clang-format

reviewable/pr4859/r2
Craig Tiller 9 years ago
parent 14890f4d87
commit 5de79ee59f
  1. 13
      src/core/channel/channel_args.c
  2. 3
      src/core/channel/channel_args.h
  3. 2
      src/core/client_config/connector.c
  4. 3
      src/core/client_config/subchannel.c
  5. 7
      src/core/client_config/subchannel.h
  6. 41
      src/core/client_config/subchannel_index.c
  7. 13
      src/core/client_config/subchannel_index.h
  8. 6
      src/core/security/credentials.c
  9. 10
      src/core/security/security_connector.c
  10. 10
      src/core/security/security_context.c
  11. 7
      src/cpp/common/channel_arguments.cc

@ -54,7 +54,8 @@ static grpc_arg copy_arg(const grpc_arg *src) {
break;
case GRPC_ARG_POINTER:
dst.value.pointer = src->value.pointer;
dst.value.pointer.p = src->value.pointer.vtable->copy(src->value.pointer.p);
dst.value.pointer.p =
src->value.pointer.vtable->copy(src->value.pointer.p);
break;
}
return dst;
@ -104,11 +105,9 @@ static int cmp_arg(const grpc_arg *a, const grpc_arg *b) {
c = GPR_ICMP(a->value.integer, b->value.integer);
break;
case GRPC_ARG_POINTER:
c = GPR_ICMP(a->value.pointer.p,
b->value.pointer.p);
c = GPR_ICMP(a->value.pointer.p, b->value.pointer.p);
if (c != 0) {
c = GPR_ICMP(a->value.pointer.vtable,
b->value.pointer.vtable);
c = GPR_ICMP(a->value.pointer.vtable, b->value.pointer.vtable);
if (c == 0) {
c = a->value.pointer.vtable->cmp(a->value.pointer.p,
b->value.pointer.p);
@ -128,11 +127,11 @@ static int cmp_key_stable(const void *ap, const void *bp) {
}
grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) {
grpc_arg **args = gpr_malloc(sizeof(grpc_arg*) * a->num_args);
grpc_arg **args = gpr_malloc(sizeof(grpc_arg *) * a->num_args);
for (size_t i = 0; i < a->num_args; i++) {
args[i] = &a->args[i];
}
qsort(args, a->num_args, sizeof(grpc_arg*), cmp_key_stable);
qsort(args, a->num_args, sizeof(grpc_arg *), cmp_key_stable);
grpc_channel_args *b = gpr_malloc(sizeof(grpc_channel_args));
b->num_args = a->num_args;

@ -88,6 +88,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
int grpc_channel_args_compression_algorithm_get_states(
const grpc_channel_args *a);
int grpc_channel_args_compare(const grpc_channel_args *a, const grpc_channel_args *b);
int grpc_channel_args_compare(const grpc_channel_args *a,
const grpc_channel_args *b);
#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */

@ -33,7 +33,7 @@
#include "src/core/client_config/connector.h"
grpc_connector *grpc_connector_ref(grpc_connector* connector) {
grpc_connector* grpc_connector_ref(grpc_connector* connector) {
connector->vtable->ref(connector);
return connector;
}

@ -239,7 +239,8 @@ void grpc_subchannel_weak_ref(grpc_subchannel *c
GPR_ASSERT(old_refs != 0);
}
grpc_subchannel *grpc_subchannel_ref_from_weak_ref(grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
grpc_subchannel *grpc_subchannel_ref_from_weak_ref(
grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
if (!c) return NULL;
for (;;) {
gpr_atm old_refs = gpr_atm_acq_load(&c->ref_pair);

@ -68,7 +68,8 @@ typedef struct grpc_subchannel_args grpc_subchannel_args;
, const char *file, int line, const char *reason
#else
#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) grpc_subchannel_ref_from_weak_ref((p))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) \
grpc_subchannel_ref_from_weak_ref((p))
#define GRPC_SUBCHANNEL_UNREF(cl, p, r) grpc_subchannel_unref((cl), (p))
#define GRPC_SUBCHANNEL_WEAK_REF(p, r) grpc_subchannel_weak_ref((p))
#define GRPC_SUBCHANNEL_WEAK_UNREF(cl, p, r) \
@ -84,8 +85,8 @@ typedef struct grpc_subchannel_args grpc_subchannel_args;
void grpc_subchannel_ref(grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel *grpc_subchannel_ref_from_weak_ref(grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel *grpc_subchannel_ref_from_weak_ref(
grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);

@ -71,12 +71,15 @@ static grpc_exec_ctx *current_ctx() {
return c;
}
static grpc_subchannel_key *create_key(grpc_connector *connector, grpc_subchannel_args *args, grpc_channel_args *(*copy_channel_args)(const grpc_channel_args *args)) {
static grpc_subchannel_key *create_key(
grpc_connector *connector, grpc_subchannel_args *args,
grpc_channel_args *(*copy_channel_args)(const grpc_channel_args *args)) {
grpc_subchannel_key *k = gpr_malloc(sizeof(*k));
k->connector = grpc_connector_ref(connector);
k->args.filter_count = args->filter_count;
k->args.filters = gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count);
memcpy(k->args.filters, args->filters, sizeof(*k->args.filters) * k->args.filter_count);
memcpy(k->args.filters, args->filters,
sizeof(*k->args.filters) * k->args.filter_count);
k->args.addr_len = args->addr_len;
k->args.addr = gpr_malloc(args->addr_len);
memcpy(k->args.addr, args->addr, k->args.addr_len);
@ -84,7 +87,8 @@ static grpc_subchannel_key *create_key(grpc_connector *connector, grpc_subchanne
return k;
}
grpc_subchannel_key *grpc_subchannel_key_create(grpc_connector *connector, grpc_subchannel_args *args) {
grpc_subchannel_key *grpc_subchannel_key_create(grpc_connector *connector,
grpc_subchannel_args *args) {
return create_key(connector, args, grpc_channel_args_normalize);
}
@ -92,7 +96,8 @@ static grpc_subchannel_key *subchannel_key_copy(grpc_subchannel_key *k) {
return create_key(k->connector, &k->args, grpc_channel_args_copy);
}
static int subchannel_key_compare(grpc_subchannel_key *a, grpc_subchannel_key *b) {
static int subchannel_key_compare(grpc_subchannel_key *a,
grpc_subchannel_key *b) {
int c = GPR_ICMP(a->connector, b->connector);
if (c != 0) return c;
c = GPR_ICMP(a->args.addr_len, b->args.addr_len);
@ -101,24 +106,21 @@ static int subchannel_key_compare(grpc_subchannel_key *a, grpc_subchannel_key *b
if (c != 0) return c;
c = memcmp(a->args.addr, b->args.addr, a->args.addr_len);
if (c != 0) return c;
c = memcmp(a->args.filters, b->args.filters, a->args.filter_count * sizeof(*a->args.filters));
c = memcmp(a->args.filters, b->args.filters,
a->args.filter_count * sizeof(*a->args.filters));
return grpc_channel_args_compare(a->args.args, b->args.args);
}
void grpc_subchannel_key_destroy(grpc_subchannel_key *k) {
gpr_free(k->args.addr);
gpr_free(k->args.filters);
grpc_channel_args_destroy((grpc_channel_args*)k->args.args);
grpc_channel_args_destroy((grpc_channel_args *)k->args.args);
gpr_free(k);
}
static void sck_avl_destroy(void *p) {
grpc_subchannel_key_destroy(p);
}
static void sck_avl_destroy(void *p) { grpc_subchannel_key_destroy(p); }
static void *sck_avl_copy(void *p) {
return subchannel_key_copy(p);
}
static void *sck_avl_copy(void *p) { return subchannel_key_copy(p); }
static long sck_avl_compare(void *a, void *b) {
return subchannel_key_compare(a, b);
@ -139,8 +141,7 @@ static const gpr_avl_vtable subchannel_avl_vtable = {
.copy_key = sck_avl_copy,
.compare_keys = sck_avl_compare,
.destroy_value = scv_avl_destroy,
.copy_value = scv_avl_copy
};
.copy_value = scv_avl_copy};
void grpc_subchannel_index_init(void) {
g_subchannel_index = gpr_avl_create(&subchannel_avl_vtable);
@ -152,8 +153,7 @@ void grpc_subchannel_index_shutdown(void) {
gpr_avl_unref(g_subchannel_index);
}
grpc_subchannel *grpc_subchannel_index_find(
grpc_exec_ctx *exec_ctx,
grpc_subchannel *grpc_subchannel_index_find(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key) {
enter_ctx(exec_ctx);
@ -161,15 +161,15 @@ grpc_subchannel *grpc_subchannel_index_find(
gpr_avl index = gpr_avl_ref(g_subchannel_index);
gpr_mu_unlock(&g_mu);
grpc_subchannel *c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(gpr_avl_get(index, key), "index_find");
grpc_subchannel *c =
GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(gpr_avl_get(index, key), "index_find");
gpr_avl_unref(index);
leave_ctx(exec_ctx);
return c;
}
grpc_subchannel *grpc_subchannel_index_register(
grpc_exec_ctx *exec_ctx,
grpc_subchannel *grpc_subchannel_index_register(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key,
grpc_subchannel *constructed) {
enter_ctx(exec_ctx);
@ -202,8 +202,7 @@ grpc_subchannel *grpc_subchannel_index_register(
return c;
}
void grpc_subchannel_index_unregister(
grpc_exec_ctx *exec_ctx,
void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key,
grpc_subchannel *constructed) {
enter_ctx(exec_ctx);

@ -39,22 +39,19 @@
typedef struct grpc_subchannel_key grpc_subchannel_key;
grpc_subchannel_key *grpc_subchannel_key_create(
grpc_connector *con, grpc_subchannel_args *args);
grpc_subchannel_key *grpc_subchannel_key_create(grpc_connector *con,
grpc_subchannel_args *args);
void grpc_subchannel_key_destroy(grpc_subchannel_key *key);
grpc_subchannel *grpc_subchannel_index_find(
grpc_exec_ctx *exec_ctx,
grpc_subchannel *grpc_subchannel_index_find(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key);
grpc_subchannel *grpc_subchannel_index_register(
grpc_exec_ctx *exec_ctx,
grpc_subchannel *grpc_subchannel_index_register(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key,
grpc_subchannel *constructed);
void grpc_subchannel_index_unregister(
grpc_exec_ctx *exec_ctx,
void grpc_subchannel_index_unregister(grpc_exec_ctx *exec_ctx,
grpc_subchannel_key *key,
grpc_subchannel *constructed);

@ -201,10 +201,8 @@ static int server_credentials_pointer_cmp(void *a, void *b) {
}
static const grpc_arg_pointer_vtable cred_ptr_vtable = {
server_credentials_pointer_arg_copy,
server_credentials_pointer_arg_destroy,
server_credentials_pointer_cmp
};
server_credentials_pointer_arg_copy, server_credentials_pointer_arg_destroy,
server_credentials_pointer_cmp};
grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials *p) {
grpc_arg arg;

@ -194,15 +194,11 @@ static void *connector_pointer_arg_copy(void *p) {
return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg");
}
static int connector_pointer_cmp(void *a, void *b) {
return GPR_ICMP(a, b);
}
static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
static const grpc_arg_pointer_vtable connector_pointer_vtable = {
connector_pointer_arg_copy,
connector_pointer_arg_destroy,
connector_pointer_cmp
};
connector_pointer_arg_copy, connector_pointer_arg_destroy,
connector_pointer_cmp};
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) {
grpc_arg result;

@ -309,15 +309,11 @@ static void *auth_context_pointer_arg_copy(void *p) {
return GRPC_AUTH_CONTEXT_REF(p, "auth_context_pointer_arg");
}
static int auth_context_pointer_cmp(void *a, void *b) {
return GPR_ICMP(a, b);
}
static int auth_context_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
static const grpc_arg_pointer_vtable auth_context_pointer_vtable = {
auth_context_pointer_arg_copy,
auth_context_pointer_arg_destroy,
auth_context_pointer_cmp
};
auth_context_pointer_arg_copy, auth_context_pointer_arg_destroy,
auth_context_pointer_cmp};
grpc_arg grpc_auth_context_to_arg(grpc_auth_context *p) {
grpc_arg arg;

@ -93,17 +93,14 @@ void ChannelArguments::SetPointer(const grpc::string& key, void* value) {
struct VtableMembers {
static void* Copy(void* in) { return in; }
static void Destroy(void* in) {}
static int Compare(void* a, void *b) {
static int Compare(void* a, void* b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
};
static const grpc_arg_pointer_vtable vtable = {
&VtableMembers::Copy,
&VtableMembers::Destroy,
&VtableMembers::Compare
};
&VtableMembers::Copy, &VtableMembers::Destroy, &VtableMembers::Compare};
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;

Loading…
Cancel
Save