diff options
Diffstat (limited to 'src')
30 files changed, 145 insertions, 146 deletions
diff --git a/src/core/ext/client_config/initial_connect_string.c b/src/core/ext/client_config/initial_connect_string.c index 61683dd635..ae54e2d016 100644 --- a/src/core/ext/client_config/initial_connect_string.c +++ b/src/core/ext/client_config/initial_connect_string.c @@ -35,8 +35,8 @@ #include <stddef.h> -extern void grpc_set_default_initial_connect_string(grpc_resolved_address **addr, - gpr_slice *initial_str); +extern void grpc_set_default_initial_connect_string( + grpc_resolved_address **addr, gpr_slice *initial_str); static grpc_set_initial_connect_string_func g_set_initial_connect_string_func = grpc_set_default_initial_connect_string; diff --git a/src/core/ext/client_config/initial_connect_string.h b/src/core/ext/client_config/initial_connect_string.h index 6d5301fde5..44ddc3af9d 100644 --- a/src/core/ext/client_config/initial_connect_string.h +++ b/src/core/ext/client_config/initial_connect_string.h @@ -38,8 +38,8 @@ #include "src/core/lib/iomgr/resolve_address.h" -typedef void (*grpc_set_initial_connect_string_func)(grpc_resolved_address **addr, - gpr_slice *initial_str); +typedef void (*grpc_set_initial_connect_string_func)( + grpc_resolved_address **addr, gpr_slice *initial_str); void grpc_test_set_initial_connect_string_function( grpc_set_initial_connect_string_func func); diff --git a/src/core/ext/client_config/parse_address.c b/src/core/ext/client_config/parse_address.c index 13f1f4da97..785e6bec51 100644 --- a/src/core/ext/client_config/parse_address.c +++ b/src/core/ext/client_config/parse_address.c @@ -31,8 +31,8 @@ * */ -#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/ext/client_config/parse_address.h" +#include "src/core/lib/iomgr/sockaddr.h" #include <stdio.h> #include <string.h> @@ -59,9 +59,7 @@ int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) { #else /* GRPC_HAVE_UNIX_SOCKET */ -int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) { - abort(); -} +int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) { abort(); } #endif /* GRPC_HAVE_UNIX_SOCKET */ diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c index 66feac65c3..6818e92404 100644 --- a/src/core/ext/client_config/subchannel.c +++ b/src/core/ext/client_config/subchannel.c @@ -320,7 +320,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, c->filters = NULL; } c->addr = gpr_malloc(sizeof(grpc_resolved_address)); - if (args->addr->len) memcpy(c->addr, args->addr, sizeof(grpc_resolved_address)); + if (args->addr->len) + memcpy(c->addr, args->addr, sizeof(grpc_resolved_address)); c->pollset_set = grpc_pollset_set_create(); grpc_set_initial_connect_string(&c->addr, &c->initial_connect_string); c->args = grpc_channel_args_copy(args->args); diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c index 8a2fe6d72e..8f8eaffcb4 100644 --- a/src/core/ext/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/lb_policy/grpclb/grpclb.c @@ -582,13 +582,12 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx, } if (args->addresses->addresses[i].is_balancer) { if (addr_index == 0) { - addr_strs[addr_index++] = grpc_sockaddr_to_uri( - &args->addresses->addresses[i].address); + addr_strs[addr_index++] = + grpc_sockaddr_to_uri(&args->addresses->addresses[i].address); } else { GPR_ASSERT(grpc_sockaddr_to_string( &addr_strs[addr_index++], - &args->addresses->addresses[i].address, - true) == 0); + &args->addresses->addresses[i].address, true) == 0); } } } diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 446586e33b..a58dab10fc 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -161,9 +161,10 @@ char *unix_get_default_authority(grpc_resolver_factory *factory, static void do_nothing(void *ignored) {} -static grpc_resolver *sockaddr_create( - grpc_resolver_args *args, const char *default_lb_policy_name, - int parse(grpc_uri *uri, grpc_resolved_address *dst)) { +static grpc_resolver *sockaddr_create(grpc_resolver_args *args, + const char *default_lb_policy_name, + int parse(grpc_uri *uri, + grpc_resolved_address *dst)) { bool errors_found = false; sockaddr_resolver *r; gpr_slice path_slice; diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c index 0d34247ae3..e3c68f6c00 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -150,8 +150,7 @@ static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con, c->tcp = NULL; grpc_closure_init(&c->connected, connected, c); grpc_tcp_client_connect(exec_ctx, &c->connected, &c->tcp, - args->interested_parties, args->addr, - args->deadline); + args->interested_parties, args->addr, args->deadline); } static const grpc_connector_vtable connector_vtable = { diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c index 4240827c29..1285eb3f8b 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c @@ -208,9 +208,9 @@ static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con, GPR_ASSERT(c->connecting_endpoint == NULL); gpr_mu_unlock(&c->mu); grpc_closure_init(&c->connected_closure, connected, c); - grpc_tcp_client_connect( - exec_ctx, &c->connected_closure, &c->newly_connecting_endpoint, - args->interested_parties, args->addr, args->deadline); + grpc_tcp_client_connect(exec_ctx, &c->connected_closure, + &c->newly_connecting_endpoint, + args->interested_parties, args->addr, args->deadline); } static const grpc_connector_vtable connector_vtable = { diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c index a7c70e2091..55de1b5990 100644 --- a/src/core/lib/http/httpcli.c +++ b/src/core/lib/http/httpcli.c @@ -223,9 +223,8 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req, } addr = &req->addresses->addrs[req->next_address++]; grpc_closure_init(&req->connected, on_connected, req); - grpc_tcp_client_connect( - exec_ctx, &req->connected, &req->ep, req->context->pollset_set, - addr, req->deadline); + grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep, + req->context->pollset_set, addr, req->deadline); } static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { diff --git a/src/core/lib/iomgr/iomgr_uv.c b/src/core/lib/iomgr/iomgr_uv.c index 4c8acfbd96..96516ff167 100644 --- a/src/core/lib/iomgr/iomgr_uv.c +++ b/src/core/lib/iomgr/iomgr_uv.c @@ -44,8 +44,6 @@ void grpc_iomgr_platform_init(void) { grpc_register_tracer("tcp", &grpc_tcp_trace); } void grpc_iomgr_platform_flush(void) {} -void grpc_iomgr_platform_shutdown(void) { - grpc_pollset_global_shutdown(); -} +void grpc_iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); } #endif /* GRPC_UV */ diff --git a/src/core/lib/iomgr/pollset_set_windows.c b/src/core/lib/iomgr/pollset_set_windows.c index 293893f18e..645650db9b 100644 --- a/src/core/lib/iomgr/pollset_set_windows.c +++ b/src/core/lib/iomgr/pollset_set_windows.c @@ -31,8 +31,8 @@ * */ -#include "src/core/lib/iomgr/port.h" #include <stdint.h> +#include "src/core/lib/iomgr/port.h" #ifdef GRPC_WINSOCK_SOCKET diff --git a/src/core/lib/iomgr/pollset_uv.c b/src/core/lib/iomgr/pollset_uv.c index 2c41a58c30..b304eb64de 100644 --- a/src/core/lib/iomgr/pollset_uv.c +++ b/src/core/lib/iomgr/pollset_uv.c @@ -42,13 +42,9 @@ gpr_mu grpc_polling_mu; -size_t grpc_pollset_size() { - return 1; -} +size_t grpc_pollset_size() { return 1; } -void grpc_pollset_global_init(void) { - gpr_mu_init(&grpc_polling_mu); -} +void grpc_pollset_global_init(void) { gpr_mu_init(&grpc_polling_mu); } void grpc_pollset_global_shutdown(void) { gpr_mu_destroy(&grpc_polling_mu); } @@ -57,7 +53,7 @@ void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) { } void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - grpc_closure *closure) { + grpc_closure *closure) { grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL); } diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index fd300082d7..c0bb3b5a23 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -123,7 +123,7 @@ #endif #if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ - defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_UV) != \ + defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_UV) != \ 1 #error Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GPR_CUSTOM_SOCKET #endif diff --git a/src/core/lib/iomgr/resolve_address_uv.c b/src/core/lib/iomgr/resolve_address_uv.c index f206c63d79..76170722f2 100644 --- a/src/core/lib/iomgr/resolve_address_uv.c +++ b/src/core/lib/iomgr/resolve_address_uv.c @@ -56,18 +56,16 @@ typedef struct request { struct addrinfo *hints; } request; -static grpc_error *handle_addrinfo_result(int status, - struct addrinfo *result, +static grpc_error *handle_addrinfo_result(int status, struct addrinfo *result, grpc_resolved_addresses **addresses) { - struct addrinfo *resp; size_t i; if (status != 0) { grpc_error *error; *addresses = NULL; error = GRPC_ERROR_CREATE("getaddrinfo failed"); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); return error; } (*addresses) = gpr_malloc(sizeof(grpc_resolved_addresses)); @@ -168,8 +166,6 @@ done: return err; } - - grpc_error *(*grpc_blocking_resolve_address)( const char *name, const char *default_port, grpc_resolved_addresses **addresses) = blocking_resolve_address_impl; @@ -217,8 +213,7 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name, if (s != 0) { *addrs = NULL; err = GRPC_ERROR_CREATE("getaddrinfo failed"); - err = grpc_error_set_str(err, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(s)); + err = grpc_error_set_str(err, GRPC_ERROR_STR_OS_ERROR, uv_strerror(s)); grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); gpr_free(r); gpr_free(req); diff --git a/src/core/lib/iomgr/sockaddr_utils.c b/src/core/lib/iomgr/sockaddr_utils.c index 0333e7aaf5..44bc2f968b 100644 --- a/src/core/lib/iomgr/sockaddr_utils.c +++ b/src/core/lib/iomgr/sockaddr_utils.c @@ -54,7 +54,8 @@ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address *resolved_addr, grpc_resolved_address *resolved_addr4_out) { GPR_ASSERT(resolved_addr != resolved_addr4_out); const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; - struct sockaddr_in *addr4_out = (struct sockaddr_in *)resolved_addr4_out->addr; + struct sockaddr_in *addr4_out = + (struct sockaddr_in *)resolved_addr4_out->addr; if (addr->sa_family == AF_INET6) { const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr; if (memcmp(addr6->sin6_addr.s6_addr, kV4MappedPrefix, @@ -78,7 +79,8 @@ int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *resolved_addr, grpc_resolved_address *resolved_addr6_out) { GPR_ASSERT(resolved_addr != resolved_addr6_out); const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; - struct sockaddr_in6 *addr6_out = (struct sockaddr_in6 *)resolved_addr6_out->addr; + struct sockaddr_in6 *addr6_out = + (struct sockaddr_in6 *)resolved_addr6_out->addr; if (addr->sa_family == AF_INET) { const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr; memset(resolved_addr6_out, 0, sizeof(*resolved_addr6_out)); @@ -92,7 +94,8 @@ int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *resolved_addr, return 0; } -int grpc_sockaddr_is_wildcard(const grpc_resolved_address *resolved_addr, int *port_out) { +int grpc_sockaddr_is_wildcard(const grpc_resolved_address *resolved_addr, + int *port_out) { const struct sockaddr *addr; grpc_resolved_address addr4_normalized; if (grpc_sockaddr_is_v4mapped(resolved_addr, &addr4_normalized)) { @@ -129,7 +132,8 @@ void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address *wild4_out, grpc_sockaddr_make_wildcard6(port, wild6_out); } -void grpc_sockaddr_make_wildcard4(int port, grpc_resolved_address *resolved_wild_out) { +void grpc_sockaddr_make_wildcard4(int port, + grpc_resolved_address *resolved_wild_out) { struct sockaddr_in *wild_out = (struct sockaddr_in *)resolved_wild_out->addr; GPR_ASSERT(port >= 0 && port < 65536); memset(resolved_wild_out, 0, sizeof(*resolved_wild_out)); @@ -138,8 +142,10 @@ void grpc_sockaddr_make_wildcard4(int port, grpc_resolved_address *resolved_wild resolved_wild_out->len = sizeof(struct sockaddr_in); } -void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address *resolved_wild_out) { - struct sockaddr_in6 *wild_out = (struct sockaddr_in6 *)resolved_wild_out->addr; +void grpc_sockaddr_make_wildcard6(int port, + grpc_resolved_address *resolved_wild_out) { + struct sockaddr_in6 *wild_out = + (struct sockaddr_in6 *)resolved_wild_out->addr; GPR_ASSERT(port >= 0 && port < 65536); memset(resolved_wild_out, 0, sizeof(*resolved_wild_out)); wild_out->sin6_family = AF_INET6; @@ -147,7 +153,8 @@ void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address *resolved_wild resolved_wild_out->len = sizeof(struct sockaddr_in6); } -int grpc_sockaddr_to_string(char **out, const grpc_resolved_address *resolved_addr, +int grpc_sockaddr_to_string(char **out, + const grpc_resolved_address *resolved_addr, int normalize) { const struct sockaddr *addr; const int save_errno = errno; @@ -227,7 +234,8 @@ int grpc_sockaddr_get_port(const grpc_resolved_address *resolved_addr) { } } -int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, int port) { +int grpc_sockaddr_set_port(const grpc_resolved_address *resolved_addr, + int port) { const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; switch (addr->sa_family) { case AF_INET: diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c index 239b9b8876..bc28bbe316 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.c +++ b/src/core/lib/iomgr/socket_utils_common_posix.c @@ -264,11 +264,9 @@ static grpc_error *error_for_fd(int fd, const grpc_resolved_address *addr) { return err; } -grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *resolved_addr, - int type, - int protocol, - grpc_dualstack_mode *dsmode, - int *newfd) { +grpc_error *grpc_create_dualstack_socket( + const grpc_resolved_address *resolved_addr, int type, int protocol, + grpc_dualstack_mode *dsmode, int *newfd) { const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; int family = addr->sa_family; if (family == AF_INET6) { diff --git a/src/core/lib/iomgr/socket_utils_linux.c b/src/core/lib/iomgr/socket_utils_linux.c index 627b9d6f9c..bf6e9e4f55 100644 --- a/src/core/lib/iomgr/socket_utils_linux.c +++ b/src/core/lib/iomgr/socket_utils_linux.c @@ -43,14 +43,15 @@ #include <sys/socket.h> #include <sys/types.h> -int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, - int nonblock, int cloexec) { +int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock, + int cloexec) { int flags = 0; GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t)); GPR_ASSERT(resolved_addr->len <= (socklen_t)-1); flags |= nonblock ? SOCK_NONBLOCK : 0; flags |= cloexec ? SOCK_CLOEXEC : 0; - return accept4(sockfd, (struct sockaddr *)resolved_addr->addr, (socklen_t *)&resolved_addr->len, flags); + return accept4(sockfd, (struct sockaddr *)resolved_addr->addr, + (socklen_t *)&resolved_addr->len, flags); } #endif diff --git a/src/core/lib/iomgr/socket_utils_posix.c b/src/core/lib/iomgr/socket_utils_posix.c index 0f2622eed6..9e95c276da 100644 --- a/src/core/lib/iomgr/socket_utils_posix.c +++ b/src/core/lib/iomgr/socket_utils_posix.c @@ -44,12 +44,13 @@ #include <grpc/support/log.h> #include "src/core/lib/iomgr/sockaddr.h" -int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, - int nonblock, int cloexec) { +int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock, + int cloexec) { int fd, flags; GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t)); GPR_ASSERT(resolved_addr->len <= (socklen_t)-1); - fd = accept(sockfd, (struct sockaddr *)resolved_addr->addr, (socklen_t)resolved_addr->len); + fd = accept(sockfd, (struct sockaddr *)resolved_addr->addr, + (socklen_t)resolved_addr->len); if (fd >= 0) { if (nonblock) { flags = fcntl(fd, F_GETFL, 0); diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h index 432cba452d..175fb2b717 100644 --- a/src/core/lib/iomgr/socket_utils_posix.h +++ b/src/core/lib/iomgr/socket_utils_posix.h @@ -42,8 +42,8 @@ #include "src/core/lib/iomgr/error.h" /* a wrapper for accept or accept4 */ -int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, - int nonblock, int cloexec); +int grpc_accept4(int sockfd, grpc_resolved_address *resolved_addr, int nonblock, + int cloexec); /* set a socket to non blocking mode */ grpc_error *grpc_set_socket_nonblocking(int fd, int non_blocking); @@ -127,8 +127,8 @@ extern int grpc_forbid_dualstack_sockets_for_testing; IPv4, so that bind() or connect() see the correct family. Also, it's important to distinguish between DUALSTACK and IPV6 when listening on the [::] wildcard address. */ -grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *addr, int type, - int protocol, +grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *addr, + int type, int protocol, grpc_dualstack_mode *dsmode, int *newfd); diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.c index eda3279659..0c04e23bca 100644 --- a/src/core/lib/iomgr/tcp_client_posix.c +++ b/src/core/lib/iomgr/tcp_client_posix.c @@ -264,7 +264,8 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, do { GPR_ASSERT(addr->len < ~(socklen_t)0); - err = connect(fd, (const struct sockaddr *)addr->addr, (socklen_t)addr->len); + err = + connect(fd, (const struct sockaddr *)addr->addr, (socklen_t)addr->len); } while (err < 0 && errno == EINTR); addr_str = grpc_sockaddr_to_uri(addr); diff --git a/src/core/lib/iomgr/tcp_client_uv.c b/src/core/lib/iomgr/tcp_client_uv.c index bed64ebe0b..3a2cca5392 100644 --- a/src/core/lib/iomgr/tcp_client_uv.c +++ b/src/core/lib/iomgr/tcp_client_uv.c @@ -65,7 +65,8 @@ static void tcp_close_callback(uv_handle_t *handle) { gpr_free(handle); } -static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { +static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, + grpc_error *error) { int done; grpc_uv_tcp_connect *connect = acp; if (error == GRPC_ERROR_NONE) { @@ -89,13 +90,13 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) { grpc_closure *closure = connect->closure; grpc_timer_cancel(&exec_ctx, &connect->alarm); if (status == 0) { - *connect->endpoint = grpc_tcp_create(connect->tcp_handle, - connect->addr_name); + *connect->endpoint = + grpc_tcp_create(connect->tcp_handle, connect->addr_name); } else { error = GRPC_ERROR_CREATE("Failed to connect to remote host"); error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, -status); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); if (status == UV_ECANCELED) { error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, "Timeout occurred"); @@ -115,8 +116,8 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) { grpc_exec_ctx_finish(&exec_ctx); } -void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, - grpc_closure *closure, grpc_endpoint **ep, +void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, + grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_resolved_address *resolved_addr, gpr_timespec deadline) { diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index c987a3c0c5..fdd8c1a1f8 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -177,7 +177,8 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_done, grpc_sockaddr_make_wildcard6(0, &local_address); - status = bind(sock, (struct sockaddr *)&local_address.addr, local_address.len); + status = + bind(sock, (struct sockaddr *)&local_address.addr, local_address.len); if (status != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "bind"); goto failure; @@ -185,8 +186,8 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_done, socket = grpc_winsocket_create(sock, "client"); info = &socket->write_info; - success = - ConnectEx(sock, (struct sockaddr *)&addr->addr, (int)addr->len, NULL, 0, NULL, &info->overlapped); + success = ConnectEx(sock, (struct sockaddr *)&addr->addr, (int)addr->len, + NULL, 0, NULL, &info->overlapped); /* It wouldn't be unusual to get a success immediately. But we'll still get an IOCP notification, so let's ignore it. */ diff --git a/src/core/lib/iomgr/tcp_server_posix.c b/src/core/lib/iomgr/tcp_server_posix.c index 6ef7a719c4..3be70726b7 100644 --- a/src/core/lib/iomgr/tcp_server_posix.c +++ b/src/core/lib/iomgr/tcp_server_posix.c @@ -343,7 +343,8 @@ static grpc_error *prepare_socket(int fd, const grpc_resolved_address *addr, sockname_temp.len = sizeof(struct sockaddr_storage); - if (getsockname(fd, (struct sockaddr *)sockname_temp.addr, (socklen_t *)&sockname_temp.len) < 0) { + if (getsockname(fd, (struct sockaddr *)sockname_temp.addr, + (socklen_t *)&sockname_temp.len) < 0) { err = GRPC_OS_ERROR(errno, "getsockname"); goto error; } @@ -443,8 +444,7 @@ error: static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd, const grpc_resolved_address *addr, - unsigned port_index, - unsigned fd_index, + unsigned port_index, unsigned fd_index, grpc_tcp_listener **listener) { grpc_tcp_listener *sp = NULL; int port = -1; @@ -503,8 +503,8 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) { int fd = -1; int port = -1; grpc_dualstack_mode dsmode; - err = grpc_create_dualstack_socket(&listener->addr, SOCK_STREAM, 0, - &dsmode, &fd); + err = grpc_create_dualstack_socket(&listener->addr, SOCK_STREAM, 0, &dsmode, + &fd); if (err != GRPC_ERROR_NONE) return err; err = prepare_socket(fd, &listener->addr, true, &port); if (err != GRPC_ERROR_NONE) return err; diff --git a/src/core/lib/iomgr/tcp_server_uv.c b/src/core/lib/iomgr/tcp_server_uv.c index 2d57715ba2..a9eaf206d0 100644 --- a/src/core/lib/iomgr/tcp_server_uv.c +++ b/src/core/lib/iomgr/tcp_server_uv.c @@ -140,7 +140,7 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { if (s->open_ports == 0) { immediately_done = 1; } - for (sp = s->head; sp; sp = sp->next){ + for (sp = s->head; sp; sp = sp->next) { gpr_log(GPR_DEBUG, "Closing uv_tcp_t handle %p", sp->handle); uv_close((uv_handle_t *)sp->handle, handle_close_callback); } @@ -192,12 +192,11 @@ static void on_connect(uv_stream_t *server, int status) { memset(&peer_name, 0, sizeof(grpc_resolved_address)); peer_name.len = sizeof(struct sockaddr_storage); err = uv_tcp_getpeername(client, (struct sockaddr *)&peer_name.addr, - (int*)&peer_name.len); + (int *)&peer_name.len); if (err == 0) { peer_name_string = grpc_sockaddr_to_uri(&peer_name); } else { - gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", - uv_strerror(status)); + gpr_log(GPR_INFO, "uv_tcp_getpeername error: %s", uv_strerror(status)); } ep = grpc_tcp_create(client, peer_name_string); gpr_log(GPR_DEBUG, "Calling on_accept_cb for server %p", sp->server); @@ -206,8 +205,7 @@ static void on_connect(uv_stream_t *server, int status) { grpc_exec_ctx_finish(&exec_ctx); } -static grpc_error *add_socket_to_server(grpc_tcp_server *s, - uv_tcp_t *handle, +static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle, const grpc_resolved_address *addr, unsigned port_index, grpc_tcp_listener **listener) { @@ -221,8 +219,8 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, status = uv_tcp_bind(handle, (struct sockaddr *)addr->addr, 0); if (status != 0) { error = GRPC_ERROR_CREATE("Failed to bind to port"); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); return error; } @@ -231,8 +229,8 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, (int *)&sockname_temp.len); if (status != 0) { error = GRPC_ERROR_CREATE("getsockname failed"); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); return error; } @@ -283,7 +281,8 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s, if (grpc_sockaddr_get_port(addr) == 0) { for (sp = s->head; sp; sp = sp->next) { sockname_temp.len = sizeof(struct sockaddr_storage); - if (0 == uv_tcp_getsockname(sp->handle, (struct sockaddr *)&sockname_temp.addr, + if (0 == uv_tcp_getsockname(sp->handle, + (struct sockaddr *)&sockname_temp.addr, (int *)&sockname_temp.len)) { *port = grpc_sockaddr_get_port(&sockname_temp); if (*port > 0) { @@ -315,8 +314,8 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s, error = add_socket_to_server(s, handle, addr, port_index, &sp); } else { error = GRPC_ERROR_CREATE("Failed to initialize UV tcp handle"); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); } gpr_free(allocated_addr); @@ -344,13 +343,13 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server, GPR_ASSERT(!server->on_accept_cb); server->on_accept_cb = on_accept_cb; server->on_accept_cb_arg = cb_arg; - for(sp = server->head; sp; sp = sp->next) { - GPR_ASSERT(uv_listen((uv_stream_t *) sp->handle, SOMAXCONN, on_connect) == 0); + for (sp = server->head; sp; sp = sp->next) { + GPR_ASSERT(uv_listen((uv_stream_t *)sp->handle, SOMAXCONN, on_connect) == + 0); } } void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {} - #endif /* GRPC_UV */ diff --git a/src/core/lib/iomgr/tcp_server_windows.c b/src/core/lib/iomgr/tcp_server_windows.c index 0e2a52bdfc..3de720168b 100644 --- a/src/core/lib/iomgr/tcp_server_windows.c +++ b/src/core/lib/iomgr/tcp_server_windows.c @@ -193,9 +193,9 @@ void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { } /* Prepare (bind) a recently-created socket for listening. */ -static grpc_error *prepare_socket(SOCKET sock, const grpc_resolved_address *addr, +static grpc_error *prepare_socket(SOCKET sock, + const grpc_resolved_address *addr, int *port) { - grpc_resolved_address sockname_temp; grpc_error *error = GRPC_ERROR_NONE; @@ -204,7 +204,8 @@ static grpc_error *prepare_socket(SOCKET sock, const grpc_resolved_address *addr goto failure; } - if (bind(sock, (const struct sockaddr *)addr->addr, (int)addr->len) == SOCKET_ERROR) { + if (bind(sock, (const struct sockaddr *)addr->addr, (int)addr->len) == + SOCKET_ERROR) { error = GRPC_WSA_ERROR(WSAGetLastError(), "bind"); goto failure; } @@ -215,8 +216,8 @@ static grpc_error *prepare_socket(SOCKET sock, const grpc_resolved_address *addr } sockname_temp.len = sizeof(struct sockaddr_storage); - if (getsockname(sock, (struct sockaddr *)sockname_temp.addr, &sockname_temp.len) == - SOCKET_ERROR) { + if (getsockname(sock, (struct sockaddr *)sockname_temp.addr, + &sockname_temp.len) == SOCKET_ERROR) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getsockname"); goto failure; } @@ -364,7 +365,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_log(GPR_ERROR, "setsockopt error: %s", utf8_message); gpr_free(utf8_message); } - err = getpeername(sock, (struct sockaddr *)peer_name.addr, &peer_name.len); + err = + getpeername(sock, (struct sockaddr *)peer_name.addr, &peer_name.len); if (!err) { peer_name_string = grpc_sockaddr_to_uri(&peer_name); } else { @@ -453,7 +455,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, SOCKET sock, } grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s, - const grpc_resolved_address *addr, + const grpc_resolved_address *addr, int *port) { grpc_tcp_listener *sp = NULL; SOCKET sock; @@ -474,7 +476,8 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s, for (sp = s->head; sp; sp = sp->next) { sockname_temp.len = sizeof(struct sockaddr_storage); if (0 == getsockname(sp->socket->socket, - (struct sockaddr *)sockname_temp.addr, &sockname_temp.len)) { + (struct sockaddr *)sockname_temp.addr, + &sockname_temp.len)) { *port = grpc_sockaddr_get_port(&sockname_temp); if (*port > 0) { allocated_addr = gpr_malloc(sizeof(grpc_resolved_address)); diff --git a/src/core/lib/iomgr/tcp_uv.c b/src/core/lib/iomgr/tcp_uv.c index fa198fd8e1..270708bd29 100644 --- a/src/core/lib/iomgr/tcp_uv.c +++ b/src/core/lib/iomgr/tcp_uv.c @@ -74,14 +74,11 @@ static void uv_close_callback(uv_handle_t *handle) { gpr_free(handle); } -static void tcp_free(grpc_tcp *tcp) { - gpr_free(tcp); -} +static void tcp_free(grpc_tcp *tcp) { gpr_free(tcp); } /*#define GRPC_TCP_REFCOUNT_DEBUG*/ #ifdef GRPC_TCP_REFCOUNT_DEBUG -#define TCP_UNREF(tcp, reason) \ - tcp_unref((tcp), (reason), __FILE__, __LINE__) +#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__) #define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__) static void tcp_unref(grpc_tcp *tcp, const char *reason, const char *file, int line) { @@ -110,7 +107,8 @@ static void tcp_unref(grpc_tcp *tcp) { static void tcp_ref(grpc_tcp *tcp) { gpr_ref(&tcp->refcount); } #endif -static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { +static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size, + uv_buf_t *buf) { grpc_tcp *tcp = handle->data; (void)suggested_size; tcp->read_slice = gpr_slice_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE); @@ -118,7 +116,8 @@ static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size, uv_buf_t *b buf->len = GPR_SLICE_LENGTH(tcp->read_slice); } -static void read_callback(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { +static void read_callback(uv_stream_t *stream, ssize_t nread, + const uv_buf_t *buf) { gpr_slice sub; grpc_error *error; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -147,7 +146,8 @@ static void read_callback(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu for (i = 0; i < tcp->read_slices->count; i++) { char *dump = gpr_dump_slice(tcp->read_slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); + gpr_log(GPR_DEBUG, "READ %p (peer=%s): %s", tcp, tcp->peer_string, + dump); gpr_free(dump); } } @@ -170,11 +170,12 @@ static void uv_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_slice_buffer_reset_and_unref(read_slices); TCP_REF(tcp, "read"); // TODO(murgatroid99): figure out what the return value here means - status = uv_read_start((uv_stream_t *)tcp->handle, alloc_uv_buf, read_callback); + status = + uv_read_start((uv_stream_t *)tcp->handle, alloc_uv_buf, read_callback); if (status != 0) { error = GRPC_ERROR_CREATE("TCP Read failed at start"); - error = grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, - uv_strerror(status)); + error = + grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR, uv_strerror(status)); grpc_exec_ctx_sched(exec_ctx, cb, error, NULL); } if (grpc_tcp_trace) { @@ -219,8 +220,8 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, size_t i; for (i = 0; i < write_slices->count; i++) { - char *data = - gpr_dump_slice(write_slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *data = gpr_dump_slice(write_slices->slices[i], + GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_DEBUG, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data); gpr_free(data); } @@ -261,24 +262,22 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, static void uv_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_pollset *pollset) { // No-op. We're ignoring pollsets currently - (void) exec_ctx; - (void) ep; - (void) pollset; - grpc_tcp *tcp = (grpc_tcp *) ep; + (void)exec_ctx; + (void)ep; + (void)pollset; + grpc_tcp *tcp = (grpc_tcp *)ep; tcp->pollset = pollset; } static void uv_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_pollset_set *pollset) { // No-op. We're ignoring pollsets currently - (void) exec_ctx; - (void) ep; - (void) pollset; + (void)exec_ctx; + (void)ep; + (void)pollset; } -static void shutdown_callback(uv_shutdown_t *req, int status) { - gpr_free(req); -} +static void shutdown_callback(uv_shutdown_t *req, int status) { gpr_free(req); } static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { grpc_tcp *tcp = (grpc_tcp *)ep; @@ -299,7 +298,7 @@ static char *uv_get_peer(grpc_endpoint *ep) { return gpr_strdup(tcp->peer_string); } -static grpc_workqueue *uv_get_workqueue(grpc_endpoint *ep) {return NULL; } +static grpc_workqueue *uv_get_workqueue(grpc_endpoint *ep) { return NULL; } static grpc_endpoint_vtable vtable = {uv_endpoint_read, uv_endpoint_write, diff --git a/src/core/lib/iomgr/timer_uv.c b/src/core/lib/iomgr/timer_uv.c index d280c8b2c8..222f1554a3 100644 --- a/src/core/lib/iomgr/timer_uv.c +++ b/src/core/lib/iomgr/timer_uv.c @@ -42,19 +42,17 @@ #include <uv.h> -static void timer_close_callback(uv_handle_t *handle) { - gpr_free(handle); -} +static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); } static void stop_uv_timer(uv_timer_t *handle) { uv_timer_stop(handle); - uv_unref((uv_handle_t*) handle); + uv_unref((uv_handle_t *)handle); gpr_log(GPR_DEBUG, "Closing uv_timer_t handle %p", handle); - uv_close((uv_handle_t*) handle, timer_close_callback); + uv_close((uv_handle_t *)handle, timer_close_callback); } void run_expired_timer(uv_timer_t *handle) { - grpc_timer *timer = (grpc_timer*)handle->data; + grpc_timer *timer = (grpc_timer *)handle->data; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_DEBUG, "Timer callback: %p", timer); GPR_ASSERT(!timer->triggered); @@ -90,7 +88,7 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) { gpr_log(GPR_DEBUG, "Running cancelled timer callback"); timer->triggered = 1; grpc_exec_ctx_sched(exec_ctx, &timer->closure, GRPC_ERROR_CANCELLED, NULL); - stop_uv_timer((uv_timer_t*)timer->uv_timer); + stop_uv_timer((uv_timer_t *)timer->uv_timer); } } diff --git a/src/core/lib/iomgr/unix_sockets_posix.c b/src/core/lib/iomgr/unix_sockets_posix.c index 830a0c96ff..030acd9811 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.c +++ b/src/core/lib/iomgr/unix_sockets_posix.c @@ -69,7 +69,8 @@ int grpc_is_unix_socket(const grpc_resolved_address *resolved_addr) { return addr->sa_family == AF_UNIX; } -void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address *resolved_addr) { +void grpc_unlink_if_unix_domain_socket( + const grpc_resolved_address *resolved_addr) { const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; if (addr->sa_family != AF_UNIX) { return; @@ -82,15 +83,15 @@ void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address *resolved_add } } -char *grpc_sockaddr_to_uri_unix_if_possible(const grpc_resolved_address *resolved_addr) { +char *grpc_sockaddr_to_uri_unix_if_possible( + const grpc_resolved_address *resolved_addr) { const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr; if (addr->sa_family != AF_UNIX) { return NULL; } char *result; - gpr_asprintf(&result, "unix:%s", - ((struct sockaddr_un *)addr)->sun_path); + gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path); return result; } diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h index 0ce483119c..21afd3aa15 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.h +++ b/src/core/lib/iomgr/unix_sockets_posix.h @@ -47,8 +47,10 @@ grpc_error *grpc_resolve_unix_domain_address( int grpc_is_unix_socket(const grpc_resolved_address *resolved_addr); -void grpc_unlink_if_unix_domain_socket(const grpc_resolved_address *resolved_addr); +void grpc_unlink_if_unix_domain_socket( + const grpc_resolved_address *resolved_addr); -char *grpc_sockaddr_to_uri_unix_if_possible(const grpc_resolved_address *resolved_addr); +char *grpc_sockaddr_to_uri_unix_if_possible( + const grpc_resolved_address *resolved_addr); #endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ diff --git a/src/core/lib/tsi/ssl_transport_security.c b/src/core/lib/tsi/ssl_transport_security.c index e59b661fa7..749b46e19f 100644 --- a/src/core/lib/tsi/ssl_transport_security.c +++ b/src/core/lib/tsi/ssl_transport_security.c @@ -33,8 +33,8 @@ #include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/tsi/ssl_transport_security.h" #include "src/core/lib/iomgr/socket_utils.h" +#include "src/core/lib/tsi/ssl_transport_security.h" #include <grpc/support/port_platform.h> |