From 88e3e7ad901524fea59cb8ab761226f4f7d72c08 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 6 Dec 2016 15:10:24 -0800 Subject: port cronet --- src/core/ext/transport/cronet/transport/cronet_transport.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/core/ext/transport/cronet') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index a4c110101e..c8f2e34ccc 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -418,6 +418,7 @@ static void on_response_headers_received( cronet_bidirectional_stream *stream, const cronet_bidirectional_stream_header_array *headers, const char *negotiated_protocol) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; CRONET_LOG(GPR_DEBUG, "R: on_response_headers_received(%p, %p, %s)", stream, headers, negotiated_protocol); stream_obj *s = (stream_obj *)stream->annotation; @@ -428,12 +429,13 @@ static void on_response_headers_received( for (size_t i = 0; i < headers->count; i++) { grpc_chttp2_incoming_metadata_buffer_add( &s->state.rs.initial_metadata, - grpc_mdelem_from_metadata_strings( + grpc_mdelem_from_metadata_strings(&exec_ctx, grpc_mdstr_from_string(headers->headers[i].key), grpc_mdstr_from_string(headers->headers[i].value))); } s->state.state_callback_received[OP_RECV_INITIAL_METADATA] = true; gpr_mu_unlock(&s->mu); + grpc_exec_ctx_finish(&exec_ctx); execute_from_storage(s); } @@ -491,6 +493,7 @@ static void on_read_completed(cronet_bidirectional_stream *stream, char *data, static void on_response_trailers_received( cronet_bidirectional_stream *stream, const cronet_bidirectional_stream_header_array *trailers) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream, trailers); stream_obj *s = (stream_obj *)stream->annotation; @@ -504,13 +507,14 @@ static void on_response_trailers_received( trailers->headers[i].value); grpc_chttp2_incoming_metadata_buffer_add( &s->state.rs.trailing_metadata, - grpc_mdelem_from_metadata_strings( + grpc_mdelem_from_metadata_strings(&exec_ctx, grpc_mdstr_from_string(trailers->headers[i].key), grpc_mdstr_from_string(trailers->headers[i].value))); s->state.rs.trailing_metadata_valid = true; } s->state.state_callback_received[OP_RECV_TRAILING_METADATA] = true; gpr_mu_unlock(&s->mu); + grpc_exec_ctx_finish(&exec_ctx); execute_from_storage(s); } -- cgit v1.2.3 From b6821f68b208871c41f888e33425e05657cf5c78 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 6 Dec 2016 15:10:42 -0800 Subject: clang-format --- .../ext/client_channel/http_connect_handshaker.c | 2 +- .../chttp2/client/secure/secure_channel_create.c | 4 ++-- .../chttp2/server/secure/server_secure_chttp2.c | 4 ++-- .../transport/cronet/transport/cronet_transport.c | 8 +++---- src/core/lib/http/httpcli_security_connector.c | 12 ++++++---- .../lib/security/transport/security_connector.c | 27 ++++++++++++++-------- .../lib/security/transport/security_handshaker.c | 3 ++- 7 files changed, 36 insertions(+), 24 deletions(-) (limited to 'src/core/ext/transport/cronet') diff --git a/src/core/ext/client_channel/http_connect_handshaker.c b/src/core/ext/client_channel/http_connect_handshaker.c index 520e79fdf6..76e2c627ef 100644 --- a/src/core/ext/client_channel/http_connect_handshaker.c +++ b/src/core/ext/client_channel/http_connect_handshaker.c @@ -97,7 +97,7 @@ static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx, // Set args fields to NULL, saving the endpoint and read buffer for // later destruction. static void cleanup_args_for_failure_locked( - grpc_exec_ctx *exec_ctx, http_connect_handshaker* handshaker) { + grpc_exec_ctx* exec_ctx, http_connect_handshaker* handshaker) { handshaker->endpoint_to_destroy = handshaker->args->endpoint; handshaker->args->endpoint = NULL; handshaker->read_buffer_to_destroy = handshaker->args->read_buffer; 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 880fa28c22..a39f73e90f 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 @@ -137,8 +137,8 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds, grpc_channel_security_connector *security_connector; grpc_channel_args *new_args_from_connector; if (grpc_channel_credentials_create_security_connector( - &exec_ctx, creds, target, args, &security_connector, &new_args_from_connector) != - GRPC_SECURITY_OK) { + &exec_ctx, creds, target, args, &security_connector, + &new_args_from_connector) != GRPC_SECURITY_OK) { grpc_exec_ctx_finish(&exec_ctx); return grpc_lame_client_channel_create( target, GRPC_STATUS_INTERNAL, "Failed to create security connector."); diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c index df80407c5d..a08fb2a18e 100644 --- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c @@ -67,8 +67,8 @@ static void server_security_handshaker_factory_destroy( grpc_exec_ctx *exec_ctx, grpc_chttp2_server_handshaker_factory *hf) { server_security_handshaker_factory *handshaker_factory = (server_security_handshaker_factory *)hf; - GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &handshaker_factory->security_connector->base, - "server"); + GRPC_SECURITY_CONNECTOR_UNREF( + exec_ctx, &handshaker_factory->security_connector->base, "server"); gpr_free(hf); } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index c8f2e34ccc..f9dae9e302 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -429,8 +429,8 @@ static void on_response_headers_received( for (size_t i = 0; i < headers->count; i++) { grpc_chttp2_incoming_metadata_buffer_add( &s->state.rs.initial_metadata, - grpc_mdelem_from_metadata_strings(&exec_ctx, - grpc_mdstr_from_string(headers->headers[i].key), + grpc_mdelem_from_metadata_strings( + &exec_ctx, grpc_mdstr_from_string(headers->headers[i].key), grpc_mdstr_from_string(headers->headers[i].value))); } s->state.state_callback_received[OP_RECV_INITIAL_METADATA] = true; @@ -507,8 +507,8 @@ static void on_response_trailers_received( trailers->headers[i].value); grpc_chttp2_incoming_metadata_buffer_add( &s->state.rs.trailing_metadata, - grpc_mdelem_from_metadata_strings(&exec_ctx, - grpc_mdstr_from_string(trailers->headers[i].key), + grpc_mdelem_from_metadata_strings( + &exec_ctx, grpc_mdstr_from_string(trailers->headers[i].key), grpc_mdstr_from_string(trailers->headers[i].value))); s->state.rs.trailing_metadata_valid = true; } diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c index c7c3b5df81..0a456ccc09 100644 --- a/src/core/lib/http/httpcli_security_connector.c +++ b/src/core/lib/http/httpcli_security_connector.c @@ -50,7 +50,8 @@ typedef struct { char *secure_peer_name; } grpc_httpcli_ssl_channel_security_connector; -static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { +static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { grpc_httpcli_ssl_channel_security_connector *c = (grpc_httpcli_ssl_channel_security_connector *)sc; if (c->handshaker_factory != NULL) { @@ -103,8 +104,9 @@ static grpc_security_connector_vtable httpcli_ssl_vtable = { httpcli_ssl_destroy, httpcli_ssl_check_peer}; static grpc_security_status httpcli_ssl_channel_security_connector_create( - grpc_exec_ctx *exec_ctx, const unsigned char *pem_root_certs, size_t pem_root_certs_size, - const char *secure_peer_name, grpc_channel_security_connector **sc) { + grpc_exec_ctx *exec_ctx, const unsigned char *pem_root_certs, + size_t pem_root_certs_size, const char *secure_peer_name, + grpc_channel_security_connector **sc) { tsi_result result = TSI_OK; grpc_httpcli_ssl_channel_security_connector *c; @@ -183,14 +185,14 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg, c->arg = arg; c->handshake_mgr = grpc_handshake_manager_create(); GPR_ASSERT(httpcli_ssl_channel_security_connector_create( - exec_ctx, pem_root_certs, pem_root_certs_size, host, &sc) == + exec_ctx, pem_root_certs, pem_root_certs_size, host, &sc) == GRPC_SECURITY_OK); grpc_channel_security_connector_create_handshakers(exec_ctx, sc, c->handshake_mgr); grpc_handshake_manager_do_handshake( exec_ctx, c->handshake_mgr, tcp, NULL /* channel_args */, deadline, NULL /* acceptor */, on_handshake_done, c /* user_data */); - GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx,&sc->base, "httpcli"); + GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "httpcli"); } const grpc_httpcli_handshaker grpc_httpcli_ssl = {"https", ssl_handshake}; diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c index fc34442a63..d9c2361ae0 100644 --- a/src/core/lib/security/transport/security_connector.c +++ b/src/core/lib/security/transport/security_connector.c @@ -171,7 +171,8 @@ grpc_security_connector *grpc_security_connector_ref( } #ifdef GRPC_SECURITY_CONNECTOR_REFCOUNT_DEBUG -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, +void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc, const char *file, int line, const char *reason) { if (sc == NULL) return; @@ -179,7 +180,8 @@ void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, grpc_security_connec "SECURITY_CONNECTOR:%p unref %d -> %d %s", sc, (int)sc->refcount.count, (int)sc->refcount.count - 1, reason); #else -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { +void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { if (sc == NULL) return; #endif if (gpr_unref(&sc->refcount)) sc->vtable->destroy(exec_ctx, sc); @@ -232,13 +234,17 @@ grpc_security_connector *grpc_find_security_connector_in_args( /* -- Fake implementation. -- */ -static void fake_channel_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { +static void fake_channel_destroy(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { grpc_channel_security_connector *c = (grpc_channel_security_connector *)sc; grpc_call_credentials_unref(exec_ctx, c->request_metadata_creds); gpr_free(sc); } -static void fake_server_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { gpr_free(sc); } +static void fake_server_destroy(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { + gpr_free(sc); +} static void fake_check_peer(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, tsi_peer peer, @@ -346,7 +352,8 @@ typedef struct { tsi_ssl_handshaker_factory *handshaker_factory; } grpc_ssl_server_security_connector; -static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { +static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { grpc_ssl_channel_security_connector *c = (grpc_ssl_channel_security_connector *)sc; grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds); @@ -358,7 +365,8 @@ static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector gpr_free(sc); } -static void ssl_server_destroy(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc) { +static void ssl_server_destroy(grpc_exec_ctx *exec_ctx, + grpc_security_connector *sc) { grpc_ssl_server_security_connector *c = (grpc_ssl_server_security_connector *)sc; if (c->handshaker_factory != NULL) { @@ -661,8 +669,8 @@ size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) { return GRPC_SLICE_LENGTH(default_pem_root_certs); } -grpc_security_status grpc_ssl_channel_security_connector_create(grpc_exec_ctx *exec_ctx, - grpc_call_credentials *request_metadata_creds, +grpc_security_status grpc_ssl_channel_security_connector_create( + grpc_exec_ctx *exec_ctx, grpc_call_credentials *request_metadata_creds, const grpc_ssl_config *config, const char *target_name, const char *overridden_target_name, grpc_channel_security_connector **sc) { size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); @@ -739,7 +747,8 @@ error: } grpc_security_status grpc_ssl_server_security_connector_create( -grpc_exec_ctx *exec_ctx, const grpc_ssl_server_config *config, grpc_server_security_connector **sc) { + grpc_exec_ctx *exec_ctx, const grpc_ssl_server_config *config, + grpc_server_security_connector **sc) { size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); const unsigned char **alpn_protocol_strings = gpr_malloc(sizeof(const char *) * num_alpn_protocols); diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.c index c46e7e0f87..4a5bbb5402 100644 --- a/src/core/lib/security/transport/security_handshaker.c +++ b/src/core/lib/security/transport/security_handshaker.c @@ -100,7 +100,8 @@ static void security_handshaker_unref(grpc_exec_ctx *exec_ctx, // Set args fields to NULL, saving the endpoint and read buffer for // later destruction. -static void cleanup_args_for_failure_locked(grpc_exec_ctx *exec_ctx, security_handshaker *h) { +static void cleanup_args_for_failure_locked(grpc_exec_ctx *exec_ctx, + security_handshaker *h) { h->endpoint_to_destroy = h->args->endpoint; h->args->endpoint = NULL; h->read_buffer_to_destroy = h->args->read_buffer; -- cgit v1.2.3