diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2017-11-06 12:36:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-06 12:36:46 -0800 |
commit | e759d2ad7abdb0702970eeccc5f033ff4b2a4c7f (patch) | |
tree | b958e8ecb8856bdd1cf7fbfe35c98a0873b130fd /src/core/ext/transport/chttp2/client | |
parent | 4f22c919e1207af206fc83e7378f04e047f7c78d (diff) | |
parent | 34992a63e0def16262d7fc9cac10ab527ac8eaa6 (diff) |
Merge pull request #13255 from ctiller/50
Update clang-format to 5.0
Diffstat (limited to 'src/core/ext/transport/chttp2/client')
4 files changed, 111 insertions, 109 deletions
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc index 74839f2156..6cd476f4ca 100644 --- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -45,25 +45,25 @@ typedef struct { bool shutdown; bool connecting; - grpc_closure *notify; + grpc_closure* notify; grpc_connect_in_args args; - grpc_connect_out_args *result; + grpc_connect_out_args* result; - grpc_endpoint *endpoint; // Non-NULL until handshaking starts. + grpc_endpoint* endpoint; // Non-NULL until handshaking starts. grpc_closure connected; - grpc_handshake_manager *handshake_mgr; + grpc_handshake_manager* handshake_mgr; } chttp2_connector; -static void chttp2_connector_ref(grpc_connector *con) { - chttp2_connector *c = (chttp2_connector *)con; +static void chttp2_connector_ref(grpc_connector* con) { + chttp2_connector* c = (chttp2_connector*)con; gpr_ref(&c->refs); } -static void chttp2_connector_unref(grpc_exec_ctx *exec_ctx, - grpc_connector *con) { - chttp2_connector *c = (chttp2_connector *)con; +static void chttp2_connector_unref(grpc_exec_ctx* exec_ctx, + grpc_connector* con) { + chttp2_connector* c = (chttp2_connector*)con; if (gpr_unref(&c->refs)) { gpr_mu_destroy(&c->mu); // If handshaking is not yet in progress, destroy the endpoint. @@ -73,9 +73,9 @@ static void chttp2_connector_unref(grpc_exec_ctx *exec_ctx, } } -static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx, - grpc_connector *con, grpc_error *why) { - chttp2_connector *c = (chttp2_connector *)con; +static void chttp2_connector_shutdown(grpc_exec_ctx* exec_ctx, + grpc_connector* con, grpc_error* why) { + chttp2_connector* c = (chttp2_connector*)con; gpr_mu_lock(&c->mu); c->shutdown = true; if (c->handshake_mgr != NULL) { @@ -91,10 +91,10 @@ static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx, GRPC_ERROR_UNREF(why); } -static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - grpc_handshaker_args *args = (grpc_handshaker_args *)arg; - chttp2_connector *c = (chttp2_connector *)args->user_data; +static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_handshaker_args* args = (grpc_handshaker_args*)arg; + chttp2_connector* c = (chttp2_connector*)args->user_data; gpr_mu_lock(&c->mu); if (error != GRPC_ERROR_NONE || c->shutdown) { if (error == GRPC_ERROR_NONE) { @@ -124,17 +124,17 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg, args->read_buffer); c->result->channel_args = args->args; } - grpc_closure *notify = c->notify; + grpc_closure* notify = c->notify; c->notify = NULL; GRPC_CLOSURE_SCHED(exec_ctx, notify, error); grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr); c->handshake_mgr = NULL; gpr_mu_unlock(&c->mu); - chttp2_connector_unref(exec_ctx, (grpc_connector *)c); + chttp2_connector_unref(exec_ctx, (grpc_connector*)c); } -static void start_handshake_locked(grpc_exec_ctx *exec_ctx, - chttp2_connector *c) { +static void start_handshake_locked(grpc_exec_ctx* exec_ctx, + chttp2_connector* c) { c->handshake_mgr = grpc_handshake_manager_create(); grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, c->args.channel_args, c->handshake_mgr); @@ -146,8 +146,8 @@ static void start_handshake_locked(grpc_exec_ctx *exec_ctx, c->endpoint = NULL; // Endpoint handed off to handshake manager. } -static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - chttp2_connector *c = (chttp2_connector *)arg; +static void connected(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + chttp2_connector* c = (chttp2_connector*)arg; gpr_mu_lock(&c->mu); GPR_ASSERT(c->connecting); c->connecting = false; @@ -158,14 +158,14 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { error = GRPC_ERROR_REF(error); } memset(c->result, 0, sizeof(*c->result)); - grpc_closure *notify = c->notify; + grpc_closure* notify = c->notify; c->notify = NULL; GRPC_CLOSURE_SCHED(exec_ctx, notify, error); if (c->endpoint != NULL) { grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error)); } gpr_mu_unlock(&c->mu); - chttp2_connector_unref(exec_ctx, (grpc_connector *)arg); + chttp2_connector_unref(exec_ctx, (grpc_connector*)arg); } else { GPR_ASSERT(c->endpoint != NULL); start_handshake_locked(exec_ctx, c); @@ -173,12 +173,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } } -static void chttp2_connector_connect(grpc_exec_ctx *exec_ctx, - grpc_connector *con, - const grpc_connect_in_args *args, - grpc_connect_out_args *result, - grpc_closure *notify) { - chttp2_connector *c = (chttp2_connector *)con; +static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx, + grpc_connector* con, + const grpc_connect_in_args* args, + grpc_connect_out_args* result, + grpc_closure* notify) { + chttp2_connector* c = (chttp2_connector*)con; grpc_resolved_address addr; grpc_get_subchannel_address_arg(exec_ctx, args->channel_args, &addr); gpr_mu_lock(&c->mu); @@ -201,8 +201,8 @@ static const grpc_connector_vtable chttp2_connector_vtable = { chttp2_connector_ref, chttp2_connector_unref, chttp2_connector_shutdown, chttp2_connector_connect}; -grpc_connector *grpc_chttp2_connector_create() { - chttp2_connector *c = (chttp2_connector *)gpr_zalloc(sizeof(*c)); +grpc_connector* grpc_chttp2_connector_create() { + chttp2_connector* c = (chttp2_connector*)gpr_zalloc(sizeof(*c)); c->base.vtable = &chttp2_connector_vtable; gpr_mu_init(&c->mu); gpr_ref_init(&c->refs, 1); diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index 6410a6043d..26c7f0debf 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -31,37 +31,37 @@ #include "src/core/lib/surface/channel.h" static void client_channel_factory_ref( - grpc_client_channel_factory *cc_factory) {} + grpc_client_channel_factory* cc_factory) {} static void client_channel_factory_unref( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {} + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {} -static grpc_subchannel *client_channel_factory_create_subchannel( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory, - const grpc_subchannel_args *args) { - grpc_connector *connector = grpc_chttp2_connector_create(); - grpc_subchannel *s = grpc_subchannel_create(exec_ctx, connector, args); +static grpc_subchannel* client_channel_factory_create_subchannel( + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory, + const grpc_subchannel_args* args) { + grpc_connector* connector = grpc_chttp2_connector_create(); + grpc_subchannel* s = grpc_subchannel_create(exec_ctx, connector, args); grpc_connector_unref(exec_ctx, connector); return s; } -static grpc_channel *client_channel_factory_create_channel( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory, - const char *target, grpc_client_channel_type type, - const grpc_channel_args *args) { +static grpc_channel* client_channel_factory_create_channel( + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory, + const char* target, grpc_client_channel_type type, + const grpc_channel_args* args) { if (target == NULL) { gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); return NULL; } // Add channel arg containing the server URI. grpc_arg arg = grpc_channel_arg_string_create( - (char *)GRPC_ARG_SERVER_URI, + (char*)GRPC_ARG_SERVER_URI, grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target)); - const char *to_remove[] = {GRPC_ARG_SERVER_URI}; - grpc_channel_args *new_args = + const char* to_remove[] = {GRPC_ARG_SERVER_URI}; + grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); gpr_free(arg.value.string); - grpc_channel *channel = grpc_channel_create(exec_ctx, target, new_args, + grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args, GRPC_CLIENT_CHANNEL, NULL); grpc_channel_args_destroy(exec_ctx, new_args); return channel; @@ -79,9 +79,9 @@ static grpc_client_channel_factory client_channel_factory = { Asynchronously: - resolve target - connect to it (trying alternatives as presented) - perform handshakes */ -grpc_channel *grpc_insecure_channel_create(const char *target, - const grpc_channel_args *args, - void *reserved) { +grpc_channel* grpc_insecure_channel_create(const char* target, + const grpc_channel_args* args, + void* reserved) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GRPC_API_TRACE( "grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3, @@ -90,15 +90,16 @@ grpc_channel *grpc_insecure_channel_create(const char *target, // Add channel arg containing the client channel factory. grpc_arg arg = grpc_client_channel_factory_create_channel_arg(&client_channel_factory); - grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1); + grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1); // Create channel. - grpc_channel *channel = client_channel_factory_create_channel( + grpc_channel* channel = client_channel_factory_create_channel( &exec_ctx, &client_channel_factory, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args); // Clean up. grpc_channel_args_destroy(&exec_ctx, new_args); grpc_exec_ctx_finish(&exec_ctx); - return channel != NULL ? channel : grpc_lame_client_channel_create( - target, GRPC_STATUS_INTERNAL, - "Failed to create client channel"); + return channel != NULL ? channel + : grpc_lame_client_channel_create( + target, GRPC_STATUS_INTERNAL, + "Failed to create client channel"); } diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc index dd88136f7b..0974a7c393 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -35,42 +35,43 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport.h" -grpc_channel *grpc_insecure_channel_create_from_fd( - const char *target, int fd, const grpc_channel_args *args) { +grpc_channel* grpc_insecure_channel_create_from_fd( + const char* target, int fd, const grpc_channel_args* args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3, (target, fd, args)); grpc_arg default_authority_arg = grpc_channel_arg_string_create( - (char *)GRPC_ARG_DEFAULT_AUTHORITY, (char *)"test.authority"); - grpc_channel_args *final_args = + (char*)GRPC_ARG_DEFAULT_AUTHORITY, (char*)"test.authority"); + grpc_channel_args* final_args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); int flags = fcntl(fd, F_GETFL, 0); GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); - grpc_endpoint *client = grpc_tcp_client_create_from_fd( + grpc_endpoint* client = grpc_tcp_client_create_from_fd( &exec_ctx, grpc_fd_create(fd, "client"), args, "fd-client"); - grpc_transport *transport = + grpc_transport* transport = grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1); GPR_ASSERT(transport); - grpc_channel *channel = grpc_channel_create( + grpc_channel* channel = grpc_channel_create( &exec_ctx, target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); grpc_channel_args_destroy(&exec_ctx, final_args); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); grpc_exec_ctx_finish(&exec_ctx); - return channel != NULL ? channel : grpc_lame_client_channel_create( - target, GRPC_STATUS_INTERNAL, - "Failed to create client channel"); + return channel != NULL ? channel + : grpc_lame_client_channel_create( + target, GRPC_STATUS_INTERNAL, + "Failed to create client channel"); } #else // !GPR_SUPPORT_CHANNELS_FROM_FD -grpc_channel *grpc_insecure_channel_create_from_fd( - const char *target, int fd, const grpc_channel_args *args) { +grpc_channel* grpc_insecure_channel_create_from_fd( + const char* target, int fd, const grpc_channel_args* args) { GPR_ASSERT(0); return NULL; } diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index fe296cf4ff..68c1e1868c 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -38,14 +38,14 @@ #include "src/core/lib/surface/channel.h" static void client_channel_factory_ref( - grpc_client_channel_factory *cc_factory) {} + grpc_client_channel_factory* cc_factory) {} static void client_channel_factory_unref( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory) {} + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {} -static grpc_subchannel_args *get_secure_naming_subchannel_args( - grpc_exec_ctx *exec_ctx, const grpc_subchannel_args *args) { - grpc_channel_credentials *channel_credentials = +static grpc_subchannel_args* get_secure_naming_subchannel_args( + grpc_exec_ctx* exec_ctx, const grpc_subchannel_args* args) { + grpc_channel_credentials* channel_credentials = grpc_channel_credentials_find_in_args(args->args); if (channel_credentials == NULL) { gpr_log(GPR_ERROR, @@ -61,33 +61,33 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args( return NULL; } // To which address are we connecting? By default, use the server URI. - const grpc_arg *server_uri_arg = + const grpc_arg* server_uri_arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI); GPR_ASSERT(server_uri_arg != NULL); GPR_ASSERT(server_uri_arg->type == GRPC_ARG_STRING); - const char *server_uri_str = server_uri_arg->value.string; + const char* server_uri_str = server_uri_arg->value.string; GPR_ASSERT(server_uri_str != NULL); - grpc_uri *server_uri = + grpc_uri* server_uri = grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */); GPR_ASSERT(server_uri != NULL); - const char *server_uri_path; + const char* server_uri_path; server_uri_path = server_uri->path[0] == '/' ? server_uri->path + 1 : server_uri->path; - const grpc_slice_hash_table *targets_info = + const grpc_slice_hash_table* targets_info = grpc_lb_targets_info_find_in_args(args->args); - char *target_name_to_check = NULL; + char* target_name_to_check = NULL; if (targets_info != NULL) { // LB channel // Find the balancer name for the target. - const char *target_uri_str = + const char* target_uri_str = grpc_get_subchannel_address_uri_arg(args->args); - grpc_uri *target_uri = + grpc_uri* target_uri = grpc_uri_parse(exec_ctx, target_uri_str, false /* suppress errors */); GPR_ASSERT(target_uri != NULL); if (target_uri->path[0] != '\0') { // "path" may be empty const grpc_slice key = grpc_slice_from_static_string( target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path); - const char *value = - (const char *)grpc_slice_hash_table_get(targets_info, key); + const char* value = + (const char*)grpc_slice_hash_table_get(targets_info, key); if (value != NULL) target_name_to_check = gpr_strdup(value); grpc_slice_unref_internal(exec_ctx, key); } @@ -102,9 +102,9 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args( } grpc_uri_destroy(server_uri); GPR_ASSERT(target_name_to_check != NULL); - grpc_channel_security_connector *subchannel_security_connector = NULL; + grpc_channel_security_connector* subchannel_security_connector = NULL; // Create the security connector using the credentials and target name. - grpc_channel_args *new_args_from_connector = NULL; + grpc_channel_args* new_args_from_connector = NULL; const grpc_security_status security_status = grpc_channel_credentials_create_security_connector( exec_ctx, channel_credentials, target_name_to_check, args->args, @@ -120,7 +120,7 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args( grpc_arg new_security_connector_arg = grpc_security_connector_to_arg(&subchannel_security_connector->base); - grpc_channel_args *new_args = grpc_channel_args_copy_and_add( + grpc_channel_args* new_args = grpc_channel_args_copy_and_add( new_args_from_connector != NULL ? new_args_from_connector : args->args, &new_security_connector_arg, 1); GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base, @@ -128,17 +128,17 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args( if (new_args_from_connector != NULL) { grpc_channel_args_destroy(exec_ctx, new_args_from_connector); } - grpc_subchannel_args *final_sc_args = - (grpc_subchannel_args *)gpr_malloc(sizeof(*final_sc_args)); + grpc_subchannel_args* final_sc_args = + (grpc_subchannel_args*)gpr_malloc(sizeof(*final_sc_args)); memcpy(final_sc_args, args, sizeof(*args)); final_sc_args->args = new_args; return final_sc_args; } -static grpc_subchannel *client_channel_factory_create_subchannel( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory, - const grpc_subchannel_args *args) { - grpc_subchannel_args *subchannel_args = +static grpc_subchannel* client_channel_factory_create_subchannel( + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory, + const grpc_subchannel_args* args) { + grpc_subchannel_args* subchannel_args = get_secure_naming_subchannel_args(exec_ctx, args); if (subchannel_args == NULL) { gpr_log( @@ -146,33 +146,33 @@ static grpc_subchannel *client_channel_factory_create_subchannel( "Failed to create subchannel arguments during subchannel creation."); return NULL; } - grpc_connector *connector = grpc_chttp2_connector_create(); - grpc_subchannel *s = + grpc_connector* connector = grpc_chttp2_connector_create(); + grpc_subchannel* s = grpc_subchannel_create(exec_ctx, connector, subchannel_args); grpc_connector_unref(exec_ctx, connector); grpc_channel_args_destroy(exec_ctx, - (grpc_channel_args *)subchannel_args->args); + (grpc_channel_args*)subchannel_args->args); gpr_free(subchannel_args); return s; } -static grpc_channel *client_channel_factory_create_channel( - grpc_exec_ctx *exec_ctx, grpc_client_channel_factory *cc_factory, - const char *target, grpc_client_channel_type type, - const grpc_channel_args *args) { +static grpc_channel* client_channel_factory_create_channel( + grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory, + const char* target, grpc_client_channel_type type, + const grpc_channel_args* args) { if (target == NULL) { gpr_log(GPR_ERROR, "cannot create channel with NULL target name"); return NULL; } // Add channel arg containing the server URI. grpc_arg arg = grpc_channel_arg_string_create( - (char *)GRPC_ARG_SERVER_URI, + (char*)GRPC_ARG_SERVER_URI, grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target)); - const char *to_remove[] = {GRPC_ARG_SERVER_URI}; - grpc_channel_args *new_args = + const char* to_remove[] = {GRPC_ARG_SERVER_URI}; + grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); gpr_free(arg.value.string); - grpc_channel *channel = grpc_channel_create(exec_ctx, target, new_args, + grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args, GRPC_CLIENT_CHANNEL, NULL); grpc_channel_args_destroy(exec_ctx, new_args); return channel; @@ -190,24 +190,24 @@ static grpc_client_channel_factory client_channel_factory = { // Asynchronously: - resolve target // - connect to it (trying alternatives as presented) // - perform handshakes -grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds, - const char *target, - const grpc_channel_args *args, - void *reserved) { +grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds, + const char* target, + const grpc_channel_args* args, + void* reserved) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GRPC_API_TRACE( "grpc_secure_channel_create(creds=%p, target=%s, args=%p, " "reserved=%p)", - 4, ((void *)creds, target, (void *)args, (void *)reserved)); + 4, ((void*)creds, target, (void*)args, (void*)reserved)); GPR_ASSERT(reserved == NULL); - grpc_channel *channel = NULL; + grpc_channel* channel = NULL; if (creds != NULL) { // Add channel args containing the client channel factory and channel // credentials. grpc_arg args_to_add[] = { grpc_client_channel_factory_create_channel_arg(&client_channel_factory), grpc_channel_credentials_to_arg(creds)}; - grpc_channel_args *new_args = grpc_channel_args_copy_and_add( + grpc_channel_args* new_args = grpc_channel_args_copy_and_add( args, args_to_add, GPR_ARRAY_SIZE(args_to_add)); // Create channel. channel = client_channel_factory_create_channel( |