diff options
-rw-r--r-- | src/core/ext/client_config/http_connect_handshaker.c | 22 | ||||
-rw-r--r-- | src/core/ext/client_config/resolver_registry.c | 3 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/client/insecure/channel_create.c | 7 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/client/secure/secure_channel_create.c | 7 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/chttp2_transport.c | 4 | ||||
-rw-r--r-- | src/core/lib/http/parser.c | 7 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_http_proxy.c | 2 | ||||
-rw-r--r-- | test/core/end2end/fixtures/http_proxy.c | 34 | ||||
-rw-r--r-- | test/core/end2end/fixtures/http_proxy.h | 4 | ||||
-rw-r--r-- | test/core/http/parser_test.c | 8 |
10 files changed, 46 insertions, 52 deletions
diff --git a/src/core/ext/client_config/http_connect_handshaker.c b/src/core/ext/client_config/http_connect_handshaker.c index e6660fe2d4..54f592ef61 100644 --- a/src/core/ext/client_config/http_connect_handshaker.c +++ b/src/core/ext/client_config/http_connect_handshaker.c @@ -31,6 +31,8 @@ * */ +#include "src/core/ext/client_config/http_connect_handshaker.h" + #include <string.h> #include <grpc/impl/codegen/alloc.h> @@ -40,7 +42,6 @@ #include "src/core/lib/http/format_request.h" #include "src/core/lib/http/parser.h" -#include "src/core/ext/client_config/http_connect_handshaker.h" typedef struct http_connect_handshaker { // Base class. Must be first. @@ -91,10 +92,9 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, for (size_t i = 0; i < h->read_buffer->count; ++i) { if (GPR_SLICE_LENGTH(h->read_buffer->slices[i]) > 0) { size_t body_start_offset = 0; - error = grpc_http_parser_parse( - &h->http_parser, h->read_buffer->slices[i], &body_start_offset); - if (error != GRPC_ERROR_NONE) - goto done; + error = grpc_http_parser_parse(&h->http_parser, h->read_buffer->slices[i], + &body_start_offset); + if (error != GRPC_ERROR_NONE) goto done; if (h->http_parser.state == GRPC_HTTP_BODY) { // Remove the data we've already read from the read buffer, // leaving only the leftover bytes (if any). @@ -138,7 +138,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, error = GRPC_ERROR_CREATE(msg); gpr_free(msg); } - done: +done: // Invoke handshake-done callback. h->cb(exec_ctx, h->endpoint, h->args, h->read_buffer, h->user_data, error); } @@ -159,8 +159,7 @@ static void http_connect_handshaker_destroy(grpc_exec_ctx* exec_ctx, } static void http_connect_handshaker_shutdown(grpc_exec_ctx* exec_ctx, - grpc_handshaker* handshaker) { -} + grpc_handshaker* handshaker) {} // FIXME BEFORE MERGING: apply deadline static void http_connect_handshaker_do_handshake( @@ -180,11 +179,10 @@ static void http_connect_handshaker_do_handshake( h->read_buffer = read_buffer; grpc_closure_init(&h->request_done_closure, on_write_done, h); grpc_closure_init(&h->response_read_closure, on_read_done, h); - grpc_http_parser_init(&h->http_parser, GRPC_HTTP_RESPONSE, - &h->http_response); + grpc_http_parser_init(&h->http_parser, GRPC_HTTP_RESPONSE, &h->http_response); // Send HTTP CONNECT request. - gpr_log(GPR_INFO, "Connecting to server %s via HTTP proxy %s", - h->server_name, h->proxy_server); + gpr_log(GPR_INFO, "Connecting to server %s via HTTP proxy %s", h->server_name, + h->proxy_server); grpc_httpcli_request request; memset(&request, 0, sizeof(request)); request.host = h->proxy_server; diff --git a/src/core/ext/client_config/resolver_registry.c b/src/core/ext/client_config/resolver_registry.c index 13f08e9fe6..5a8f137103 100644 --- a/src/core/ext/client_config/resolver_registry.c +++ b/src/core/ext/client_config/resolver_registry.c @@ -140,8 +140,7 @@ grpc_resolver *grpc_resolver_create( args.client_channel_factory = client_channel_factory; resolver = grpc_resolver_factory_create_resolver(factory, &args); const char *proxy = grpc_uri_get_query_arg(uri, "http_proxy"); - if (proxy != NULL) - *http_proxy = gpr_strdup(proxy); + if (proxy != NULL) *http_proxy = gpr_strdup(proxy); grpc_uri_destroy(uri); return resolver; } 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 7f0b13e321..475224effd 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -180,8 +180,7 @@ static void client_channel_factory_unref( "client_channel_factory"); } grpc_channel_args_destroy(f->merge_args); - if (f->http_proxy != NULL) - gpr_free(f->http_proxy); + if (f->http_proxy != NULL) gpr_free(f->http_proxy); gpr_free(f); } } @@ -219,8 +218,8 @@ static grpc_channel *client_channel_factory_create_channel( grpc_channel *channel = grpc_channel_create(exec_ctx, target, final_args, GRPC_CLIENT_CHANNEL, NULL); grpc_channel_args_destroy(final_args); - grpc_resolver *resolver = grpc_resolver_create(target, &f->base, - &f->http_proxy); + grpc_resolver *resolver = + grpc_resolver_create(target, &f->base, &f->http_proxy); if (!resolver) { GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, "client_channel_factory_create_channel"); 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 73c093fcd2..e06ae9e02c 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 @@ -242,8 +242,7 @@ static void client_channel_factory_unref( "client_channel_factory"); } grpc_channel_args_destroy(f->merge_args); - if (f->http_proxy != NULL) - gpr_free(f->http_proxy); + if (f->http_proxy != NULL) gpr_free(f->http_proxy); gpr_free(f); } } @@ -285,8 +284,8 @@ static grpc_channel *client_channel_factory_create_channel( GRPC_CLIENT_CHANNEL, NULL); grpc_channel_args_destroy(final_args); - grpc_resolver *resolver = grpc_resolver_create(target, &f->base, - &f->http_proxy); + grpc_resolver *resolver = + grpc_resolver_create(target, &f->base, &f->http_proxy); if (resolver != NULL) { grpc_client_channel_set_resolver( exec_ctx, grpc_channel_get_channel_stack(channel), resolver); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 6c608c8013..0a28f7b5e8 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1987,8 +1987,8 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx, grpc_error *parse_error = GRPC_ERROR_NONE; for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) { - parse_error = grpc_http_parser_parse(&parser, t->read_buffer.slices[i], - NULL); + parse_error = + grpc_http_parser_parse(&parser, t->read_buffer.slices[i], NULL); } if (parse_error == GRPC_ERROR_NONE && (parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) { diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c index cbf26811f7..be9e9b6b63 100644 --- a/src/core/lib/http/parser.c +++ b/src/core/lib/http/parser.c @@ -337,11 +337,10 @@ grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice, size_t *start_of_body) { for (size_t i = 0; i < GPR_SLICE_LENGTH(slice); i++) { bool found_body_start = false; - grpc_error *err = addbyte(parser, GPR_SLICE_START_PTR(slice)[i], - &found_body_start); + grpc_error *err = + addbyte(parser, GPR_SLICE_START_PTR(slice)[i], &found_body_start); if (err != GRPC_ERROR_NONE) return err; - if (found_body_start && start_of_body != NULL) - *start_of_body = i + 1; + if (found_body_start && start_of_body != NULL) *start_of_body = i + 1; } return GRPC_ERROR_NONE; } diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index d84f0b8cb9..612a3dbb83 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -38,10 +38,10 @@ #include <grpc/support/alloc.h> #include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> #include <grpc/support/useful.h> -#include <grpc/support/string_util.h> #include "src/core/ext/client_config/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/core/end2end/fixtures/http_proxy.c b/test/core/end2end/fixtures/http_proxy.c index 0cdb2884ee..53132c1636 100644 --- a/test/core/end2end/fixtures/http_proxy.c +++ b/test/core/end2end/fixtures/http_proxy.c @@ -281,8 +281,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, // Read request and feed it to the parser. for (size_t i = 0; i < conn->client_read_buffer.count; ++i) { if (GPR_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) { - error = grpc_http_parser_parse( - &conn->http_parser, conn->client_read_buffer.slices[i], NULL); + error = grpc_http_parser_parse(&conn->http_parser, + conn->client_read_buffer.slices[i], NULL); if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, true /* is_client */, "HTTP proxy request parse", error); @@ -368,17 +368,17 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, // static void thread_main(void* arg) { - grpc_end2end_http_proxy *proxy = arg; + grpc_end2end_http_proxy* proxy = arg; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; do { const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); const gpr_timespec deadline = gpr_time_add(now, gpr_time_from_seconds(1, GPR_TIMESPAN)); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(proxy->mu); - GRPC_LOG_IF_ERROR("grpc_pollset_work", - grpc_pollset_work(&exec_ctx, proxy->pollset, &worker, - now, deadline)); + GRPC_LOG_IF_ERROR( + "grpc_pollset_work", + grpc_pollset_work(&exec_ctx, proxy->pollset, &worker, now, deadline)); gpr_mu_unlock(proxy->mu); grpc_exec_ctx_flush(&exec_ctx); } while (!proxy->shutdown); @@ -394,8 +394,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create() { gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name); // Create TCP server. proxy->channel_args = grpc_channel_args_copy(NULL); - grpc_error* error = grpc_tcp_server_create( - NULL, proxy->channel_args, &proxy->server); + grpc_error* error = + grpc_tcp_server_create(NULL, proxy->channel_args, &proxy->server); GPR_ASSERT(error == GRPC_ERROR_NONE); // Bind to port. struct sockaddr_in addr; @@ -403,16 +403,16 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create() { addr.sin_family = AF_INET; grpc_sockaddr_set_port((struct sockaddr*)&addr, proxy_port); int port; - error = grpc_tcp_server_add_port( - proxy->server, (struct sockaddr*)&addr, sizeof(addr), &port); + error = grpc_tcp_server_add_port(proxy->server, (struct sockaddr*)&addr, + sizeof(addr), &port); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(port == proxy_port); // Start server. proxy->pollset = gpr_malloc(grpc_pollset_size()); grpc_pollset_init(proxy->pollset, &proxy->mu); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, - on_accept, proxy); + grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept, + proxy); grpc_exec_ctx_finish(&exec_ctx); // Start proxy thread. gpr_thd_options opt = gpr_thd_options_default(); @@ -421,8 +421,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create() { return proxy; } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { grpc_pollset* pollset = arg; grpc_pollset_destroy(pollset); gpr_free(pollset); @@ -442,7 +442,7 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { grpc_exec_ctx_finish(&exec_ctx); } -const char *grpc_end2end_http_proxy_get_proxy_name( - grpc_end2end_http_proxy *proxy) { +const char* grpc_end2end_http_proxy_get_proxy_name( + grpc_end2end_http_proxy* proxy) { return proxy->proxy_name; } diff --git a/test/core/end2end/fixtures/http_proxy.h b/test/core/end2end/fixtures/http_proxy.h index 7af2ea92d0..cd47b432af 100644 --- a/test/core/end2end/fixtures/http_proxy.h +++ b/test/core/end2end/fixtures/http_proxy.h @@ -37,5 +37,5 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(); void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy); -const char *grpc_end2end_http_proxy_get_proxy_name( - grpc_end2end_http_proxy *proxy); +const char* grpc_end2end_http_proxy_get_proxy_name( + grpc_end2end_http_proxy* proxy); diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.c index 211690eff9..2fc354d9ee 100644 --- a/test/core/http/parser_test.c +++ b/test/core/http/parser_test.c @@ -62,8 +62,8 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); for (i = 0; i < num_slices; i++) { - GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) - == GRPC_ERROR_NONE); + GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) == + GRPC_ERROR_NONE); gpr_slice_unref(slices[i]); } GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE); @@ -119,8 +119,8 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); for (i = 0; i < num_slices; i++) { - GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) - == GRPC_ERROR_NONE); + GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) == + GRPC_ERROR_NONE); gpr_slice_unref(slices[i]); } GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE); |