diff options
Diffstat (limited to 'src/core/lib/security/transport')
8 files changed, 284 insertions, 366 deletions
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index a8464dbf9e..8e1853b9ec 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -90,8 +90,7 @@ static void add_error(grpc_error **combined, grpc_error *error) { *combined = grpc_error_add_child(*combined, error); } -static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *input_error) { +static void on_credentials_metadata(void *arg, grpc_error *input_error) { grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg; grpc_call_element *elem = (grpc_call_element *)batch->handler_private.extra_arg; @@ -105,16 +104,16 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg, batch->payload->send_initial_metadata.send_initial_metadata; for (size_t i = 0; i < calld->md_array.size; ++i) { add_error(&error, grpc_metadata_batch_add_tail( - exec_ctx, mdb, &calld->md_links[i], + mdb, &calld->md_links[i], GRPC_MDELEM_REF(calld->md_array.md[i]))); } } if (error == GRPC_ERROR_NONE) { - grpc_call_next_op(exec_ctx, elem, batch); + grpc_call_next_op(elem, batch); } else { error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED); - grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error, + grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); } } @@ -149,20 +148,17 @@ void build_auth_metadata_context(grpc_security_connector *sc, gpr_free(host); } -static void cancel_get_request_metadata(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void cancel_get_request_metadata(void *arg, grpc_error *error) { grpc_call_element *elem = (grpc_call_element *)arg; call_data *calld = (call_data *)elem->call_data; if (error != GRPC_ERROR_NONE) { grpc_call_credentials_cancel_get_request_metadata( - exec_ctx, calld->creds, &calld->md_array, GRPC_ERROR_REF(error)); + calld->creds, &calld->md_array, GRPC_ERROR_REF(error)); } - GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, - "cancel_get_request_metadata"); + GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_get_request_metadata"); } -static void send_security_metadata(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, +static void send_security_metadata(grpc_call_element *elem, grpc_transport_stream_op_batch *batch) { call_data *calld = (call_data *)elem->call_data; channel_data *chand = (channel_data *)elem->channel_data; @@ -176,7 +172,7 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx, if (channel_call_creds == NULL && !call_creds_has_md) { /* Skip sending metadata altogether. */ - grpc_call_next_op(exec_ctx, elem, batch); + grpc_call_next_op(elem, batch); return; } @@ -185,11 +181,10 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx, ctx->creds, NULL); if (calld->creds == NULL) { grpc_transport_stream_op_batch_finish_with_failure( - exec_ctx, batch, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Incompatible credentials set on channel and call."), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED), + batch, grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Incompatible credentials set on channel and call."), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED), calld->call_combiner); return; } @@ -207,30 +202,29 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx, batch, grpc_schedule_on_exec_ctx); grpc_error *error = GRPC_ERROR_NONE; if (grpc_call_credentials_get_request_metadata( - exec_ctx, calld->creds, calld->pollent, calld->auth_md_context, + calld->creds, calld->pollent, calld->auth_md_context, &calld->md_array, &calld->async_result_closure, &error)) { // Synchronous return; invoke on_credentials_metadata() directly. - on_credentials_metadata(exec_ctx, batch, error); + on_credentials_metadata(batch, error); GRPC_ERROR_UNREF(error); } else { // Async return; register cancellation closure with call combiner. GRPC_CALL_STACK_REF(calld->owning_call, "cancel_get_request_metadata"); grpc_call_combiner_set_notify_on_cancel( - exec_ctx, calld->call_combiner, + calld->call_combiner, GRPC_CLOSURE_INIT(&calld->get_request_metadata_cancel_closure, cancel_get_request_metadata, elem, grpc_schedule_on_exec_ctx)); } } -static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void on_host_checked(void *arg, grpc_error *error) { grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg; grpc_call_element *elem = (grpc_call_element *)batch->handler_private.extra_arg; call_data *calld = (call_data *)elem->call_data; if (error == GRPC_ERROR_NONE) { - send_security_metadata(exec_ctx, elem, batch); + send_security_metadata(elem, batch); } else { char *error_msg; char *host = grpc_slice_to_c_string(calld->host); @@ -238,31 +232,28 @@ static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg, host); gpr_free(host); grpc_transport_stream_op_batch_finish_with_failure( - exec_ctx, batch, - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg), - GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_UNAUTHENTICATED), + batch, grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED), calld->call_combiner); gpr_free(error_msg); } } -static void cancel_check_call_host(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void cancel_check_call_host(void *arg, grpc_error *error) { grpc_call_element *elem = (grpc_call_element *)arg; call_data *calld = (call_data *)elem->call_data; channel_data *chand = (channel_data *)elem->channel_data; if (error != GRPC_ERROR_NONE) { grpc_channel_security_connector_cancel_check_call_host( - exec_ctx, chand->security_connector, &calld->async_result_closure, + chand->security_connector, &calld->async_result_closure, GRPC_ERROR_REF(error)); } - GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_check_call_host"); + GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_check_call_host"); } static void auth_start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *batch) { + grpc_call_element *elem, grpc_transport_stream_op_batch *batch) { GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0); /* grab pointers to our data from the call element */ @@ -295,13 +286,13 @@ static void auth_start_transport_stream_op_batch( */ if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY)) { if (calld->have_host) { - grpc_slice_unref_internal(exec_ctx, calld->host); + grpc_slice_unref_internal(calld->host); } calld->host = grpc_slice_ref_internal(GRPC_MDVALUE(md)); calld->have_host = true; } else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_PATH)) { if (calld->have_method) { - grpc_slice_unref_internal(exec_ctx, calld->method); + grpc_slice_unref_internal(calld->method); } calld->method = grpc_slice_ref_internal(GRPC_MDVALUE(md)); calld->have_method = true; @@ -314,16 +305,16 @@ static void auth_start_transport_stream_op_batch( char *call_host = grpc_slice_to_c_string(calld->host); grpc_error *error = GRPC_ERROR_NONE; if (grpc_channel_security_connector_check_call_host( - exec_ctx, chand->security_connector, call_host, - chand->auth_context, &calld->async_result_closure, &error)) { + chand->security_connector, call_host, chand->auth_context, + &calld->async_result_closure, &error)) { // Synchronous return; invoke on_host_checked() directly. - on_host_checked(exec_ctx, batch, error); + on_host_checked(batch, error); GRPC_ERROR_UNREF(error); } else { // Async return; register cancellation closure with call combiner. GRPC_CALL_STACK_REF(calld->owning_call, "cancel_check_call_host"); grpc_call_combiner_set_notify_on_cancel( - exec_ctx, calld->call_combiner, + calld->call_combiner, GRPC_CLOSURE_INIT(&calld->check_call_host_cancel_closure, cancel_check_call_host, elem, grpc_schedule_on_exec_ctx)); @@ -335,13 +326,12 @@ static void auth_start_transport_stream_op_batch( } /* pass control down the stack */ - grpc_call_next_op(exec_ctx, elem, batch); + grpc_call_next_op(elem, batch); GPR_TIMER_END("auth_start_transport_stream_op_batch", 0); } /* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, +static grpc_error *init_call_elem(grpc_call_element *elem, const grpc_call_element_args *args) { call_data *calld = (call_data *)elem->call_data; calld->owning_call = args->call_stack; @@ -349,32 +339,30 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, return GRPC_ERROR_NONE; } -static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, +static void set_pollset_or_pollset_set(grpc_call_element *elem, grpc_polling_entity *pollent) { call_data *calld = (call_data *)elem->call_data; calld->pollent = pollent; } /* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, +static void destroy_call_elem(grpc_call_element *elem, const grpc_call_final_info *final_info, grpc_closure *ignored) { call_data *calld = (call_data *)elem->call_data; - grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array); - grpc_call_credentials_unref(exec_ctx, calld->creds); + grpc_credentials_mdelem_array_destroy(&calld->md_array); + grpc_call_credentials_unref(calld->creds); if (calld->have_host) { - grpc_slice_unref_internal(exec_ctx, calld->host); + grpc_slice_unref_internal(calld->host); } if (calld->have_method) { - grpc_slice_unref_internal(exec_ctx, calld->method); + grpc_slice_unref_internal(calld->method); } reset_auth_metadata_context(&calld->auth_md_context); } /* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, +static grpc_error *init_channel_elem(grpc_channel_element *elem, grpc_channel_element_args *args) { grpc_security_connector *sc = grpc_security_connector_find_in_args(args->channel_args); @@ -407,13 +395,12 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) { +static void destroy_channel_elem(grpc_channel_element *elem) { /* grab pointers to our data from the channel element */ channel_data *chand = (channel_data *)elem->channel_data; grpc_channel_security_connector *sc = chand->security_connector; if (sc != NULL) { - GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter"); + GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "client_auth_filter"); } GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "client_auth_filter"); } diff --git a/src/core/lib/security/transport/lb_targets_info.cc b/src/core/lib/security/transport/lb_targets_info.cc index 947fc1addf..aa01e911d9 100644 --- a/src/core/lib/security/transport/lb_targets_info.cc +++ b/src/core/lib/security/transport/lb_targets_info.cc @@ -28,8 +28,8 @@ static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref((grpc_slice_hash_table *)p); } -static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) { - grpc_slice_hash_table_unref(exec_ctx, (grpc_slice_hash_table *)p); +static void targets_info_destroy(void *p) { + grpc_slice_hash_table_unref((grpc_slice_hash_table *)p); } static int targets_info_cmp(void *a, void *b) { return grpc_slice_hash_table_cmp((const grpc_slice_hash_table *)a, diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index ae5633b82c..c784f2390f 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -64,28 +64,27 @@ typedef struct { grpc_tracer_flag grpc_trace_secure_endpoint = GRPC_TRACER_INITIALIZER(false, "secure_endpoint"); -static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) { +static void destroy(secure_endpoint *secure_ep) { secure_endpoint *ep = secure_ep; - grpc_endpoint_destroy(exec_ctx, ep->wrapped_ep); + grpc_endpoint_destroy(ep->wrapped_ep); tsi_frame_protector_destroy(ep->protector); - tsi_zero_copy_grpc_protector_destroy(exec_ctx, ep->zero_copy_protector); - grpc_slice_buffer_destroy_internal(exec_ctx, &ep->leftover_bytes); - grpc_slice_unref_internal(exec_ctx, ep->read_staging_buffer); - grpc_slice_unref_internal(exec_ctx, ep->write_staging_buffer); - grpc_slice_buffer_destroy_internal(exec_ctx, &ep->output_buffer); - grpc_slice_buffer_destroy_internal(exec_ctx, &ep->source_buffer); + tsi_zero_copy_grpc_protector_destroy(ep->zero_copy_protector); + grpc_slice_buffer_destroy_internal(&ep->leftover_bytes); + grpc_slice_unref_internal(ep->read_staging_buffer); + grpc_slice_unref_internal(ep->write_staging_buffer); + grpc_slice_buffer_destroy_internal(&ep->output_buffer); + grpc_slice_buffer_destroy_internal(&ep->source_buffer); gpr_mu_destroy(&ep->protector_mu); gpr_free(ep); } #ifndef NDEBUG -#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \ - secure_endpoint_unref((exec_ctx), (ep), (reason), __FILE__, __LINE__) +#define SECURE_ENDPOINT_UNREF(ep, reason) \ + secure_endpoint_unref((ep), (reason), __FILE__, __LINE__) #define SECURE_ENDPOINT_REF(ep, reason) \ secure_endpoint_ref((ep), (reason), __FILE__, __LINE__) -static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, - const char *reason, const char *file, - int line) { +static void secure_endpoint_unref(secure_endpoint *ep, const char *reason, + const char *file, int line) { if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) { gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -93,7 +92,7 @@ static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, val - 1); } if (gpr_unref(&ep->ref)) { - destroy(exec_ctx, ep); + destroy(ep); } } @@ -108,13 +107,11 @@ static void secure_endpoint_ref(secure_endpoint *ep, const char *reason, gpr_ref(&ep->ref); } #else -#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \ - secure_endpoint_unref((exec_ctx), (ep)) +#define SECURE_ENDPOINT_UNREF(ep, reason) secure_endpoint_unref((ep)) #define SECURE_ENDPOINT_REF(ep, reason) secure_endpoint_ref((ep)) -static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx, - secure_endpoint *ep) { +static void secure_endpoint_unref(secure_endpoint *ep) { if (gpr_unref(&ep->ref)) { - destroy(exec_ctx, ep); + destroy(ep); } } @@ -129,8 +126,7 @@ static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur, *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer); } -static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, - grpc_error *error) { +static void call_read_cb(secure_endpoint *ep, grpc_error *error) { if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) { size_t i; for (i = 0; i < ep->read_buffer->count; i++) { @@ -141,12 +137,11 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, } } ep->read_buffer = NULL; - GRPC_CLOSURE_SCHED(exec_ctx, ep->read_cb, error); - SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read"); + GRPC_CLOSURE_SCHED(ep->read_cb, error); + SECURE_ENDPOINT_UNREF(ep, "read"); } -static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *error) { +static void on_read(void *user_data, grpc_error *error) { unsigned i; uint8_t keep_looping = 0; tsi_result result = TSI_OK; @@ -155,16 +150,16 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, uint8_t *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer); if (error != GRPC_ERROR_NONE) { - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer); - call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Secure read failed", &error, 1)); + grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer); + call_read_cb(ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( + "Secure read failed", &error, 1)); return; } if (ep->zero_copy_protector != NULL) { // Use zero-copy grpc protector to unprotect. result = tsi_zero_copy_grpc_protector_unprotect( - exec_ctx, ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer); + ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer); } else { // Use frame protector to unprotect. /* TODO(yangg) check error, maybe bail out early */ @@ -217,37 +212,35 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, /* TODO(yangg) experiment with moving this block after read_cb to see if it helps latency */ - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->source_buffer); + grpc_slice_buffer_reset_and_unref_internal(&ep->source_buffer); if (result != TSI_OK) { - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer); + grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer); call_read_cb( - exec_ctx, ep, - grpc_set_tsi_error_result( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result)); + ep, grpc_set_tsi_error_result( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result)); return; } - call_read_cb(exec_ctx, ep, GRPC_ERROR_NONE); + call_read_cb(ep, GRPC_ERROR_NONE); } -static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, - grpc_slice_buffer *slices, grpc_closure *cb) { +static void endpoint_read(grpc_endpoint *secure_ep, grpc_slice_buffer *slices, + grpc_closure *cb) { secure_endpoint *ep = (secure_endpoint *)secure_ep; ep->read_cb = cb; ep->read_buffer = slices; - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer); + grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer); SECURE_ENDPOINT_REF(ep, "read"); if (ep->leftover_bytes.count) { grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer); GPR_ASSERT(ep->leftover_bytes.count == 0); - on_read(exec_ctx, ep, GRPC_ERROR_NONE); + on_read(ep, GRPC_ERROR_NONE); return; } - grpc_endpoint_read(exec_ctx, ep->wrapped_ep, &ep->source_buffer, - &ep->on_read); + grpc_endpoint_read(ep->wrapped_ep, &ep->source_buffer, &ep->on_read); } static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur, @@ -258,8 +251,8 @@ static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur, *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer); } -static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, - grpc_slice_buffer *slices, grpc_closure *cb) { +static void endpoint_write(grpc_endpoint *secure_ep, grpc_slice_buffer *slices, + grpc_closure *cb) { GPR_TIMER_BEGIN("secure_endpoint.endpoint_write", 0); unsigned i; @@ -268,7 +261,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, uint8_t *cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer); uint8_t *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer); - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer); + grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer); if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) { for (i = 0; i < slices->count; i++) { @@ -281,8 +274,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, if (ep->zero_copy_protector != NULL) { // Use zero-copy grpc protector to protect. - result = tsi_zero_copy_grpc_protector_protect( - exec_ctx, ep->zero_copy_protector, slices, &ep->output_buffer); + result = tsi_zero_copy_grpc_protector_protect(ep->zero_copy_protector, + slices, &ep->output_buffer); } else { // Use frame protector to protect. for (i = 0; i < slices->count; i++) { @@ -340,43 +333,38 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, if (result != TSI_OK) { /* TODO(yangg) do different things according to the error type? */ - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer); + grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer); GRPC_CLOSURE_SCHED( - exec_ctx, cb, - grpc_set_tsi_error_result( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result)); + cb, grpc_set_tsi_error_result( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result)); GPR_TIMER_END("secure_endpoint.endpoint_write", 0); return; } - grpc_endpoint_write(exec_ctx, ep->wrapped_ep, &ep->output_buffer, cb); + grpc_endpoint_write(ep->wrapped_ep, &ep->output_buffer, cb); GPR_TIMER_END("secure_endpoint.endpoint_write", 0); } -static void endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, - grpc_error *why) { +static void endpoint_shutdown(grpc_endpoint *secure_ep, grpc_error *why) { secure_endpoint *ep = (secure_endpoint *)secure_ep; - grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep, why); + grpc_endpoint_shutdown(ep->wrapped_ep, why); } -static void endpoint_destroy(grpc_exec_ctx *exec_ctx, - grpc_endpoint *secure_ep) { +static void endpoint_destroy(grpc_endpoint *secure_ep) { secure_endpoint *ep = (secure_endpoint *)secure_ep; - SECURE_ENDPOINT_UNREF(exec_ctx, ep, "destroy"); + SECURE_ENDPOINT_UNREF(ep, "destroy"); } -static void endpoint_add_to_pollset(grpc_exec_ctx *exec_ctx, - grpc_endpoint *secure_ep, +static void endpoint_add_to_pollset(grpc_endpoint *secure_ep, grpc_pollset *pollset) { secure_endpoint *ep = (secure_endpoint *)secure_ep; - grpc_endpoint_add_to_pollset(exec_ctx, ep->wrapped_ep, pollset); + grpc_endpoint_add_to_pollset(ep->wrapped_ep, pollset); } -static void endpoint_add_to_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *secure_ep, +static void endpoint_add_to_pollset_set(grpc_endpoint *secure_ep, grpc_pollset_set *pollset_set) { secure_endpoint *ep = (secure_endpoint *)secure_ep; - grpc_endpoint_add_to_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set); + grpc_endpoint_add_to_pollset_set(ep->wrapped_ep, pollset_set); } static char *endpoint_get_peer(grpc_endpoint *secure_ep) { diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index 80d9a7b77f..d8259dd130 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -106,33 +106,32 @@ const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer, } void grpc_channel_security_connector_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector, + grpc_channel_security_connector *connector, grpc_handshake_manager *handshake_mgr) { if (connector != NULL) { - connector->add_handshakers(exec_ctx, connector, handshake_mgr); + connector->add_handshakers(connector, handshake_mgr); } } void grpc_server_security_connector_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector, + grpc_server_security_connector *connector, grpc_handshake_manager *handshake_mgr) { if (connector != NULL) { - connector->add_handshakers(exec_ctx, connector, handshake_mgr); + connector->add_handshakers(connector, handshake_mgr); } } -void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, +void grpc_security_connector_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { if (sc == NULL) { - GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, + GRPC_CLOSURE_SCHED(on_peer_checked, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "cannot check peer -- no security connector")); tsi_peer_destruct(&peer); } else { - sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked); + sc->vtable->check_peer(sc, peer, auth_context, on_peer_checked); } } @@ -170,26 +169,26 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector *sc1, } bool grpc_channel_security_connector_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - const char *host, grpc_auth_context *auth_context, - grpc_closure *on_call_host_checked, grpc_error **error) { + grpc_channel_security_connector *sc, const char *host, + grpc_auth_context *auth_context, grpc_closure *on_call_host_checked, + grpc_error **error) { if (sc == NULL || sc->check_call_host == NULL) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "cannot check call host -- no security connector"); return true; } - return sc->check_call_host(exec_ctx, sc, host, auth_context, - on_call_host_checked, error); + return sc->check_call_host(sc, host, auth_context, on_call_host_checked, + error); } void grpc_channel_security_connector_cancel_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - grpc_closure *on_call_host_checked, grpc_error *error) { + grpc_channel_security_connector *sc, grpc_closure *on_call_host_checked, + grpc_error *error) { if (sc == NULL || sc->cancel_check_call_host == NULL) { GRPC_ERROR_UNREF(error); return; } - sc->cancel_check_call_host(exec_ctx, sc, on_call_host_checked, error); + sc->cancel_check_call_host(sc, on_call_host_checked, error); } #ifndef NDEBUG @@ -213,8 +212,7 @@ grpc_security_connector *grpc_security_connector_ref( } #ifndef NDEBUG -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, +void grpc_security_connector_unref(grpc_security_connector *sc, const char *file, int line, const char *reason) { if (sc == NULL) return; @@ -225,15 +223,14 @@ void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, val, val - 1, reason); } #else -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc) { +void grpc_security_connector_unref(grpc_security_connector *sc) { if (sc == NULL) return; #endif - if (gpr_unref(&sc->refcount)) sc->vtable->destroy(exec_ctx, sc); + if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc); } -static void connector_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) { - GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, (grpc_security_connector *)p, +static void connector_arg_destroy(void *p) { + GRPC_SECURITY_CONNECTOR_UNREF((grpc_security_connector *)p, "connector_arg_destroy"); } @@ -286,20 +283,16 @@ typedef struct { bool is_lb_channel; } grpc_fake_channel_security_connector; -static void fake_channel_destroy(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc) { +static void fake_channel_destroy(grpc_security_connector *sc) { grpc_fake_channel_security_connector *c = (grpc_fake_channel_security_connector *)sc; - grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds); + grpc_call_credentials_unref(c->base.request_metadata_creds); gpr_free(c->target); gpr_free(c->expected_targets); gpr_free(c); } -static void fake_server_destroy(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc) { - gpr_free(sc); -} +static void fake_server_destroy(grpc_security_connector *sc) { gpr_free(sc); } static bool fake_check_target(const char *target_type, const char *target, const char *set_str) { @@ -363,8 +356,7 @@ done: if (!success) abort(); } -static void fake_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, tsi_peer peer, +static void fake_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { const char *prop_name; @@ -396,25 +388,23 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx, *auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME, GRPC_FAKE_TRANSPORT_SECURITY_TYPE); end: - GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error); + GRPC_CLOSURE_SCHED(on_peer_checked, error); tsi_peer_destruct(&peer); } -static void fake_channel_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, tsi_peer peer, +static void fake_channel_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { - fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked); + fake_check_peer(sc, peer, auth_context, on_peer_checked); grpc_fake_channel_security_connector *c = (grpc_fake_channel_security_connector *)sc; fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel); } -static void fake_server_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, tsi_peer peer, +static void fake_server_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { - fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked); + fake_check_peer(sc, peer, auth_context, on_peer_checked); } static int fake_channel_cmp(grpc_security_connector *sc1, @@ -443,8 +433,7 @@ static int fake_server_cmp(grpc_security_connector *sc1, (grpc_server_security_connector *)sc2); } -static bool fake_channel_check_call_host(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, +static bool fake_channel_check_call_host(grpc_channel_security_connector *sc, const char *host, grpc_auth_context *auth_context, grpc_closure *on_call_host_checked, @@ -453,29 +442,26 @@ static bool fake_channel_check_call_host(grpc_exec_ctx *exec_ctx, } static void fake_channel_cancel_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - grpc_closure *on_call_host_checked, grpc_error *error) { + grpc_channel_security_connector *sc, grpc_closure *on_call_host_checked, + grpc_error *error) { GRPC_ERROR_UNREF(error); } static void fake_channel_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, + grpc_channel_security_connector *sc, grpc_handshake_manager *handshake_mgr) { grpc_handshake_manager_add( handshake_mgr, grpc_security_handshaker_create( - exec_ctx, tsi_create_fake_handshaker(true /* is_client */), - &sc->base)); + tsi_create_fake_handshaker(true /* is_client */), &sc->base)); } -static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx, - grpc_server_security_connector *sc, +static void fake_server_add_handshakers(grpc_server_security_connector *sc, grpc_handshake_manager *handshake_mgr) { grpc_handshake_manager_add( handshake_mgr, grpc_security_handshaker_create( - exec_ctx, tsi_create_fake_handshaker(false /* is_client */), - &sc->base)); + tsi_create_fake_handshaker(false /* is_client */), &sc->base)); } static grpc_security_connector_vtable fake_channel_vtable = { @@ -533,12 +519,11 @@ typedef struct { tsi_ssl_server_handshaker_factory *server_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_security_connector *sc) { grpc_ssl_channel_security_connector *c = (grpc_ssl_channel_security_connector *)sc; - grpc_channel_credentials_unref(exec_ctx, c->base.channel_creds); - grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds); + grpc_channel_credentials_unref(c->base.channel_creds); + grpc_call_credentials_unref(c->base.request_metadata_creds); tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory); c->client_handshaker_factory = NULL; if (c->target_name != NULL) gpr_free(c->target_name); @@ -546,18 +531,16 @@ static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx, gpr_free(sc); } -static void ssl_server_destroy(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc) { +static void ssl_server_destroy(grpc_security_connector *sc) { grpc_ssl_server_security_connector *c = (grpc_ssl_server_security_connector *)sc; - grpc_server_credentials_unref(exec_ctx, c->base.server_creds); + grpc_server_credentials_unref(c->base.server_creds); tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory); c->server_handshaker_factory = NULL; gpr_free(sc); } -static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, +static void ssl_channel_add_handshakers(grpc_channel_security_connector *sc, grpc_handshake_manager *handshake_mgr) { grpc_ssl_channel_security_connector *c = (grpc_ssl_channel_security_connector *)sc; @@ -576,13 +559,11 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx, // Create handshakers. grpc_handshake_manager_add( - handshake_mgr, - grpc_security_handshaker_create( - exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base)); + handshake_mgr, grpc_security_handshaker_create( + tsi_create_adapter_handshaker(tsi_hs), &sc->base)); } -static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx, - grpc_server_security_connector *sc, +static void ssl_server_add_handshakers(grpc_server_security_connector *sc, grpc_handshake_manager *handshake_mgr) { grpc_ssl_server_security_connector *c = (grpc_ssl_server_security_connector *)sc; @@ -598,9 +579,8 @@ static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx, // Create handshakers. grpc_handshake_manager_add( - handshake_mgr, - grpc_security_handshaker_create( - exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base)); + handshake_mgr, grpc_security_handshaker_create( + tsi_create_adapter_handshaker(tsi_hs), &sc->base)); } static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) { @@ -684,8 +664,7 @@ static grpc_error *ssl_check_peer(grpc_security_connector *sc, return GRPC_ERROR_NONE; } -static void ssl_channel_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, tsi_peer peer, +static void ssl_channel_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { grpc_ssl_channel_security_connector *c = @@ -694,17 +673,16 @@ static void ssl_channel_check_peer(grpc_exec_ctx *exec_ctx, ? c->overridden_target_name : c->target_name, &peer, auth_context); - GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error); + GRPC_CLOSURE_SCHED(on_peer_checked, error); tsi_peer_destruct(&peer); } -static void ssl_server_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, tsi_peer peer, +static void ssl_server_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked) { grpc_error *error = ssl_check_peer(sc, NULL, &peer, auth_context); tsi_peer_destruct(&peer); - GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error); + GRPC_CLOSURE_SCHED(on_peer_checked, error); } static int ssl_channel_cmp(grpc_security_connector *sc1, @@ -774,8 +752,7 @@ void tsi_shallow_peer_destruct(tsi_peer *peer) { if (peer->properties != NULL) gpr_free(peer->properties); } -static bool ssl_channel_check_call_host(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, +static bool ssl_channel_check_call_host(grpc_channel_security_connector *sc, const char *host, grpc_auth_context *auth_context, grpc_closure *on_call_host_checked, @@ -800,8 +777,8 @@ static bool ssl_channel_check_call_host(grpc_exec_ctx *exec_ctx, } static void ssl_channel_cancel_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - grpc_closure *on_call_host_checked, grpc_error *error) { + grpc_channel_security_connector *sc, grpc_closure *on_call_host_checked, + grpc_error *error) { GRPC_ERROR_UNREF(error); } @@ -893,7 +870,7 @@ const char *grpc_get_default_ssl_roots(void) { } grpc_security_status grpc_ssl_channel_security_connector_create( - grpc_exec_ctx *exec_ctx, grpc_channel_credentials *channel_creds, + grpc_channel_credentials *channel_creds, 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) { @@ -951,7 +928,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create( if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); - ssl_channel_destroy(exec_ctx, &c->base.base); + ssl_channel_destroy(&c->base.base); *sc = NULL; goto error; } @@ -965,8 +942,8 @@ error: } grpc_security_status grpc_ssl_server_security_connector_create( - grpc_exec_ctx *exec_ctx, grpc_server_credentials *server_creds, - const grpc_ssl_server_config *config, grpc_server_security_connector **sc) { + grpc_server_credentials *server_creds, const grpc_ssl_server_config *config, + grpc_server_security_connector **sc) { size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); const char **alpn_protocol_strings = (const char **)gpr_malloc(sizeof(const char *) * num_alpn_protocols); @@ -998,7 +975,7 @@ grpc_security_status grpc_ssl_server_security_connector_create( if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); - ssl_server_destroy(exec_ctx, &c->base.base); + ssl_server_destroy(&c->base.base); *sc = NULL; goto error; } diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h index 216bb35e81..7834045772 100644 --- a/src/core/lib/security/transport/security_connector.h +++ b/src/core/lib/security/transport/security_connector.h @@ -56,9 +56,9 @@ typedef struct grpc_security_connector grpc_security_connector; #define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector" typedef struct { - void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc); - void (*check_peer)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, - tsi_peer peer, grpc_auth_context **auth_context, + void (*destroy)(grpc_security_connector *sc); + void (*check_peer)(grpc_security_connector *sc, tsi_peer peer, + grpc_auth_context **auth_context, grpc_closure *on_peer_checked); int (*cmp)(grpc_security_connector *sc, grpc_security_connector *other); } grpc_security_connector_vtable; @@ -73,29 +73,25 @@ struct grpc_security_connector { #ifndef NDEBUG #define GRPC_SECURITY_CONNECTOR_REF(p, r) \ grpc_security_connector_ref((p), __FILE__, __LINE__, (r)) -#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \ - grpc_security_connector_unref((exec_ctx), (p), __FILE__, __LINE__, (r)) +#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \ + grpc_security_connector_unref((p), __FILE__, __LINE__, (r)) grpc_security_connector *grpc_security_connector_ref( grpc_security_connector *policy, const char *file, int line, const char *reason); -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, - grpc_security_connector *policy, +void grpc_security_connector_unref(grpc_security_connector *policy, const char *file, int line, const char *reason); #else #define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p)) -#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \ - grpc_security_connector_unref((exec_ctx), (p)) +#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p)) grpc_security_connector *grpc_security_connector_ref( grpc_security_connector *policy); -void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx, - grpc_security_connector *policy); +void grpc_security_connector_unref(grpc_security_connector *policy); #endif /* Check the peer. Callee takes ownership of the peer object. When done, sets *auth_context and invokes on_peer_checked. */ -void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx, - grpc_security_connector *sc, +void grpc_security_connector_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_auth_context **auth_context, grpc_closure *on_peer_checked); @@ -125,17 +121,14 @@ struct grpc_channel_security_connector { grpc_security_connector base; grpc_channel_credentials *channel_creds; grpc_call_credentials *request_metadata_creds; - bool (*check_call_host)(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, const char *host, + bool (*check_call_host)(grpc_channel_security_connector *sc, const char *host, grpc_auth_context *auth_context, grpc_closure *on_call_host_checked, grpc_error **error); - void (*cancel_check_call_host)(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, + void (*cancel_check_call_host)(grpc_channel_security_connector *sc, grpc_closure *on_call_host_checked, grpc_error *error); - void (*add_handshakers)(grpc_exec_ctx *exec_ctx, - grpc_channel_security_connector *sc, + void (*add_handshakers)(grpc_channel_security_connector *sc, grpc_handshake_manager *handshake_mgr); }; @@ -148,20 +141,20 @@ int grpc_channel_security_connector_cmp(grpc_channel_security_connector *sc1, /// be set to indicate the result. Otherwise, \a on_call_host_checked /// will be invoked when complete. bool grpc_channel_security_connector_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - const char *host, grpc_auth_context *auth_context, - grpc_closure *on_call_host_checked, grpc_error **error); + grpc_channel_security_connector *sc, const char *host, + grpc_auth_context *auth_context, grpc_closure *on_call_host_checked, + grpc_error **error); /// Cancels a pending asychronous call to /// grpc_channel_security_connector_check_call_host() with /// \a on_call_host_checked as its callback. void grpc_channel_security_connector_cancel_check_call_host( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - grpc_closure *on_call_host_checked, grpc_error *error); + grpc_channel_security_connector *sc, grpc_closure *on_call_host_checked, + grpc_error *error); /* Registers handshakers with \a handshake_mgr. */ void grpc_channel_security_connector_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector, + grpc_channel_security_connector *connector, grpc_handshake_manager *handshake_mgr); /* --- server_security_connector object. --- @@ -174,8 +167,7 @@ typedef struct grpc_server_security_connector grpc_server_security_connector; struct grpc_server_security_connector { grpc_security_connector base; grpc_server_credentials *server_creds; - void (*add_handshakers)(grpc_exec_ctx *exec_ctx, - grpc_server_security_connector *sc, + void (*add_handshakers)(grpc_server_security_connector *sc, grpc_handshake_manager *handshake_mgr); }; @@ -184,7 +176,8 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector *sc1, grpc_server_security_connector *sc2); void grpc_server_security_connector_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc, + grpc_server_security_connector *sc, + grpc_handshake_manager *handshake_mgr); /* --- Creation security connectors. --- */ @@ -222,7 +215,7 @@ typedef struct { specific error code otherwise. */ grpc_security_status grpc_ssl_channel_security_connector_create( - grpc_exec_ctx *exec_ctx, grpc_channel_credentials *channel_creds, + grpc_channel_credentials *channel_creds, 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); @@ -248,8 +241,8 @@ typedef struct { specific error code otherwise. */ grpc_security_status grpc_ssl_server_security_connector_create( - grpc_exec_ctx *exec_ctx, grpc_server_credentials *server_creds, - const grpc_ssl_server_config *config, grpc_server_security_connector **sc); + grpc_server_credentials *server_creds, const grpc_ssl_server_config *config, + grpc_server_security_connector **sc); /* Util. */ const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer, diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 3d19605617..ff0fc09817 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -65,43 +65,40 @@ typedef struct { tsi_handshaker_result *handshaker_result; } security_handshaker; -static void security_handshaker_unref(grpc_exec_ctx *exec_ctx, - security_handshaker *h) { +static void security_handshaker_unref(security_handshaker *h) { if (gpr_unref(&h->refs)) { gpr_mu_destroy(&h->mu); tsi_handshaker_destroy(h->handshaker); tsi_handshaker_result_destroy(h->handshaker_result); if (h->endpoint_to_destroy != NULL) { - grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy); + grpc_endpoint_destroy(h->endpoint_to_destroy); } if (h->read_buffer_to_destroy != NULL) { - grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy); + grpc_slice_buffer_destroy_internal(h->read_buffer_to_destroy); gpr_free(h->read_buffer_to_destroy); } gpr_free(h->handshake_buffer); - grpc_slice_buffer_destroy_internal(exec_ctx, &h->outgoing); + grpc_slice_buffer_destroy_internal(&h->outgoing); GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake"); - GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, h->connector, "handshake"); + GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake"); gpr_free(h); } } // 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(security_handshaker *h) { h->endpoint_to_destroy = h->args->endpoint; h->args->endpoint = NULL; h->read_buffer_to_destroy = h->args->read_buffer; h->args->read_buffer = NULL; - grpc_channel_args_destroy(exec_ctx, h->args->args); + grpc_channel_args_destroy(h->args->args); h->args->args = NULL; } // If the handshake failed or we're shutting down, clean up and invoke the // callback with the error. -static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx, - security_handshaker *h, +static void security_handshake_failed_locked(security_handshaker *h, grpc_error *error) { if (error == GRPC_ERROR_NONE) { // If we were shut down after the handshake succeeded but before an @@ -116,34 +113,33 @@ static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx, // before destroying them, even if we know that there are no // pending read/write callbacks. This should be fixed, at which // point this can be removed. - grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(error)); + grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(error)); // Not shutting down, so the write failed. Clean up before // invoking the callback. - cleanup_args_for_failure_locked(exec_ctx, h); + cleanup_args_for_failure_locked(h); // Set shutdown to true so that subsequent calls to // security_handshaker_shutdown() do nothing. h->shutdown = true; } // Invoke callback. - GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, error); + GRPC_CLOSURE_SCHED(h->on_handshake_done, error); } -static void on_peer_checked_inner(grpc_exec_ctx *exec_ctx, - security_handshaker *h, grpc_error *error) { +static void on_peer_checked_inner(security_handshaker *h, grpc_error *error) { if (error != GRPC_ERROR_NONE || h->shutdown) { - security_handshake_failed_locked(exec_ctx, h, GRPC_ERROR_REF(error)); + security_handshake_failed_locked(h, GRPC_ERROR_REF(error)); return; } // Create zero-copy frame protector, if implemented. tsi_zero_copy_grpc_protector *zero_copy_protector = NULL; tsi_result result = tsi_handshaker_result_create_zero_copy_grpc_protector( - exec_ctx, h->handshaker_result, NULL, &zero_copy_protector); + h->handshaker_result, NULL, &zero_copy_protector); if (result != TSI_OK && result != TSI_UNIMPLEMENTED) { error = grpc_set_tsi_error_result( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Zero-copy frame protector creation failed"), result); - security_handshake_failed_locked(exec_ctx, h, error); + security_handshake_failed_locked(h, error); return; } // Create frame protector if zero-copy frame protector is NULL. @@ -155,7 +151,7 @@ static void on_peer_checked_inner(grpc_exec_ctx *exec_ctx, error = grpc_set_tsi_error_result(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Frame protector creation failed"), result); - security_handshake_failed_locked(exec_ctx, h, error); + security_handshake_failed_locked(h, error); return; } } @@ -170,7 +166,7 @@ static void on_peer_checked_inner(grpc_exec_ctx *exec_ctx, grpc_slice_from_copied_buffer((char *)unused_bytes, unused_bytes_size); h->args->endpoint = grpc_secure_endpoint_create( protector, zero_copy_protector, h->args->endpoint, &slice, 1); - grpc_slice_unref_internal(exec_ctx, slice); + grpc_slice_unref_internal(slice); } else { h->args->endpoint = grpc_secure_endpoint_create( protector, zero_copy_protector, h->args->endpoint, NULL, 0); @@ -178,31 +174,29 @@ static void on_peer_checked_inner(grpc_exec_ctx *exec_ctx, tsi_handshaker_result_destroy(h->handshaker_result); h->handshaker_result = NULL; // Clear out the read buffer before it gets passed to the transport. - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, h->args->read_buffer); + grpc_slice_buffer_reset_and_unref_internal(h->args->read_buffer); // Add auth context to channel args. grpc_arg auth_context_arg = grpc_auth_context_to_arg(h->auth_context); grpc_channel_args *tmp_args = h->args->args; h->args->args = grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1); - grpc_channel_args_destroy(exec_ctx, tmp_args); + grpc_channel_args_destroy(tmp_args); // Invoke callback. - GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(h->on_handshake_done, GRPC_ERROR_NONE); // Set shutdown to true so that subsequent calls to // security_handshaker_shutdown() do nothing. h->shutdown = true; } -static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void on_peer_checked(void *arg, grpc_error *error) { security_handshaker *h = (security_handshaker *)arg; gpr_mu_lock(&h->mu); - on_peer_checked_inner(exec_ctx, h, error); + on_peer_checked_inner(h, error); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); } -static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx, - security_handshaker *h) { +static grpc_error *check_peer_locked(security_handshaker *h) { tsi_peer peer; tsi_result result = tsi_handshaker_result_extract_peer(h->handshaker_result, &peer); @@ -210,20 +204,20 @@ static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx, return grpc_set_tsi_error_result( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result); } - grpc_security_connector_check_peer(exec_ctx, h->connector, peer, - &h->auth_context, &h->on_peer_checked); + grpc_security_connector_check_peer(h->connector, peer, &h->auth_context, + &h->on_peer_checked); return GRPC_ERROR_NONE; } static grpc_error *on_handshake_next_done_locked( - grpc_exec_ctx *exec_ctx, security_handshaker *h, tsi_result result, + security_handshaker *h, tsi_result result, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result) { grpc_error *error = GRPC_ERROR_NONE; // Read more if we need to. if (result == TSI_INCOMPLETE_DATA) { GPR_ASSERT(bytes_to_send_size == 0); - grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer, + grpc_endpoint_read(h->args->endpoint, h->args->read_buffer, &h->on_handshake_data_received_from_peer); return error; } @@ -240,17 +234,17 @@ static grpc_error *on_handshake_next_done_locked( // Send data to peer, if needed. grpc_slice to_send = grpc_slice_from_copied_buffer( (const char *)bytes_to_send, bytes_to_send_size); - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing); + grpc_slice_buffer_reset_and_unref_internal(&h->outgoing); grpc_slice_buffer_add(&h->outgoing, to_send); - grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing, + grpc_endpoint_write(h->args->endpoint, &h->outgoing, &h->on_handshake_data_sent_to_peer); } else if (handshaker_result == NULL) { // There is nothing to send, but need to read from peer. - grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer, + grpc_endpoint_read(h->args->endpoint, h->args->read_buffer, &h->on_handshake_data_received_from_peer); } else { // Handshake has finished, check peer and so on. - error = check_peer_locked(exec_ctx, h); + error = check_peer_locked(h); } return error; } @@ -261,24 +255,23 @@ static void on_handshake_next_done_grpc_wrapper( security_handshaker *h = (security_handshaker *)user_data; // This callback will be invoked by TSI in a non-grpc thread, so it's // safe to create our own exec_ctx here. - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + ExecCtx _local_exec_ctx; gpr_mu_lock(&h->mu); - grpc_error *error = - on_handshake_next_done_locked(&exec_ctx, h, result, bytes_to_send, - bytes_to_send_size, handshaker_result); + grpc_error *error = on_handshake_next_done_locked( + h, result, bytes_to_send, bytes_to_send_size, handshaker_result); if (error != GRPC_ERROR_NONE) { - security_handshake_failed_locked(&exec_ctx, h, error); + security_handshake_failed_locked(h, error); gpr_mu_unlock(&h->mu); - security_handshaker_unref(&exec_ctx, h); + security_handshaker_unref(h); } else { gpr_mu_unlock(&h->mu); } - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_finish(); } static grpc_error *do_handshaker_next_locked( - grpc_exec_ctx *exec_ctx, security_handshaker *h, - const unsigned char *bytes_received, size_t bytes_received_size) { + security_handshaker *h, const unsigned char *bytes_received, + size_t bytes_received_size) { // Invoke TSI handshaker. const unsigned char *bytes_to_send = NULL; size_t bytes_to_send_size = 0; @@ -293,21 +286,20 @@ static grpc_error *do_handshaker_next_locked( return GRPC_ERROR_NONE; } // Handshaker returned synchronously. Invoke callback directly in - // this thread with our existing exec_ctx. - return on_handshake_next_done_locked(exec_ctx, h, result, bytes_to_send, + // this thread with our existing exec_ctx-> + return on_handshake_next_done_locked(h, result, bytes_to_send, bytes_to_send_size, handshaker_result); } -static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, - void *arg, grpc_error *error) { +static void on_handshake_data_received_from_peer(void *arg, grpc_error *error) { security_handshaker *h = (security_handshaker *)arg; gpr_mu_lock(&h->mu); if (error != GRPC_ERROR_NONE || h->shutdown) { security_handshake_failed_locked( - exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Handshake read failed", &error, 1)); + h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( + "Handshake read failed", &error, 1)); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); return; } // Copy all slices received. @@ -329,40 +321,39 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, offset += slice_size; } // Call TSI handshaker. - error = do_handshaker_next_locked(exec_ctx, h, h->handshake_buffer, - bytes_received_size); + error = + do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size); if (error != GRPC_ERROR_NONE) { - security_handshake_failed_locked(exec_ctx, h, error); + security_handshake_failed_locked(h, error); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); } else { gpr_mu_unlock(&h->mu); } } -static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void on_handshake_data_sent_to_peer(void *arg, grpc_error *error) { security_handshaker *h = (security_handshaker *)arg; gpr_mu_lock(&h->mu); if (error != GRPC_ERROR_NONE || h->shutdown) { security_handshake_failed_locked( - exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "Handshake write failed", &error, 1)); + h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( + "Handshake write failed", &error, 1)); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); return; } // We may be done. if (h->handshaker_result == NULL) { - grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer, + grpc_endpoint_read(h->args->endpoint, h->args->read_buffer, &h->on_handshake_data_received_from_peer); } else { - error = check_peer_locked(exec_ctx, h); + error = check_peer_locked(h); if (error != GRPC_ERROR_NONE) { - security_handshake_failed_locked(exec_ctx, h, error); + security_handshake_failed_locked(h, error); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); return; } } @@ -373,28 +364,25 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg, // public handshaker API // -static void security_handshaker_destroy(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker) { +static void security_handshaker_destroy(grpc_handshaker *handshaker) { security_handshaker *h = (security_handshaker *)handshaker; - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); } -static void security_handshaker_shutdown(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker, +static void security_handshaker_shutdown(grpc_handshaker *handshaker, grpc_error *why) { security_handshaker *h = (security_handshaker *)handshaker; gpr_mu_lock(&h->mu); if (!h->shutdown) { h->shutdown = true; - grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(why)); - cleanup_args_for_failure_locked(exec_ctx, h); + grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(why)); + cleanup_args_for_failure_locked(h); } gpr_mu_unlock(&h->mu); GRPC_ERROR_UNREF(why); } -static void security_handshaker_do_handshake(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker, +static void security_handshaker_do_handshake(grpc_handshaker *handshaker, grpc_tcp_server_acceptor *acceptor, grpc_closure *on_handshake_done, grpc_handshaker_args *args) { @@ -403,11 +391,11 @@ static void security_handshaker_do_handshake(grpc_exec_ctx *exec_ctx, h->args = args; h->on_handshake_done = on_handshake_done; gpr_ref(&h->refs); - grpc_error *error = do_handshaker_next_locked(exec_ctx, h, NULL, 0); + grpc_error *error = do_handshaker_next_locked(h, NULL, 0); if (error != GRPC_ERROR_NONE) { - security_handshake_failed_locked(exec_ctx, h, error); + security_handshake_failed_locked(h, error); gpr_mu_unlock(&h->mu); - security_handshaker_unref(exec_ctx, h); + security_handshaker_unref(h); return; } gpr_mu_unlock(&h->mu); @@ -418,8 +406,7 @@ static const grpc_handshaker_vtable security_handshaker_vtable = { security_handshaker_do_handshake}; static grpc_handshaker *security_handshaker_create( - grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker, - grpc_security_connector *connector) { + tsi_handshaker *handshaker, grpc_security_connector *connector) { security_handshaker *h = (security_handshaker *)gpr_zalloc(sizeof(security_handshaker)); grpc_handshaker_init(&security_handshaker_vtable, &h->base); @@ -445,23 +432,20 @@ static grpc_handshaker *security_handshaker_create( // fail_handshaker // -static void fail_handshaker_destroy(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker) { +static void fail_handshaker_destroy(grpc_handshaker *handshaker) { gpr_free(handshaker); } -static void fail_handshaker_shutdown(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker, +static void fail_handshaker_shutdown(grpc_handshaker *handshaker, grpc_error *why) { GRPC_ERROR_UNREF(why); } -static void fail_handshaker_do_handshake(grpc_exec_ctx *exec_ctx, - grpc_handshaker *handshaker, +static void fail_handshaker_do_handshake(grpc_handshaker *handshaker, grpc_tcp_server_acceptor *acceptor, grpc_closure *on_handshake_done, grpc_handshaker_args *args) { - GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done, + GRPC_CLOSURE_SCHED(on_handshake_done, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Failed to create security handshaker")); } @@ -481,27 +465,27 @@ static grpc_handshaker *fail_handshaker_create() { // static void client_handshaker_factory_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory, - const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) { + grpc_handshaker_factory *handshaker_factory, const grpc_channel_args *args, + grpc_handshake_manager *handshake_mgr) { grpc_channel_security_connector *security_connector = (grpc_channel_security_connector *)grpc_security_connector_find_in_args( args); - grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector, + grpc_channel_security_connector_add_handshakers(security_connector, handshake_mgr); } static void server_handshaker_factory_add_handshakers( - grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *hf, - const grpc_channel_args *args, grpc_handshake_manager *handshake_mgr) { + grpc_handshaker_factory *hf, const grpc_channel_args *args, + grpc_handshake_manager *handshake_mgr) { grpc_server_security_connector *security_connector = (grpc_server_security_connector *)grpc_security_connector_find_in_args( args); - grpc_server_security_connector_add_handshakers(exec_ctx, security_connector, + grpc_server_security_connector_add_handshakers(security_connector, handshake_mgr); } static void handshaker_factory_destroy( - grpc_exec_ctx *exec_ctx, grpc_handshaker_factory *handshaker_factory) {} + grpc_handshaker_factory *handshaker_factory) {} static const grpc_handshaker_factory_vtable client_handshaker_factory_vtable = { client_handshaker_factory_add_handshakers, handshaker_factory_destroy}; @@ -520,14 +504,13 @@ static grpc_handshaker_factory server_handshaker_factory = { // grpc_handshaker *grpc_security_handshaker_create( - grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker, - grpc_security_connector *connector) { + tsi_handshaker *handshaker, grpc_security_connector *connector) { // If no TSI handshaker was created, return a handshaker that always fails. // Otherwise, return a real security handshaker. if (handshaker == NULL) { return fail_handshaker_create(); } else { - return security_handshaker_create(exec_ctx, handshaker, connector); + return security_handshaker_create(handshaker, connector); } } diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index 178099bb94..b555a72a65 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -29,8 +29,7 @@ extern "C" { /// Creates a security handshaker using \a handshaker. grpc_handshaker *grpc_security_handshaker_create( - grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker, - grpc_security_connector *connector); + tsi_handshaker *handshaker, grpc_security_connector *connector); /// Registers security handshaker factories. void grpc_security_register_handshaker_factories(); diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index f5e02f42fe..36d0b7612b 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -73,8 +73,7 @@ static grpc_metadata_array metadata_batch_to_md_array( return result; } -static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx, - void *user_data, +static grpc_filtered_mdelem remove_consumed_md(void *user_data, grpc_mdelem md) { grpc_call_element *elem = (grpc_call_element *)user_data; call_data *calld = (call_data *)elem->call_data; @@ -88,8 +87,7 @@ static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx, return GRPC_FILTERED_MDELEM(md); } -static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, +static void on_md_processing_done_inner(grpc_call_element *elem, const grpc_metadata *consumed_md, size_t num_consumed_md, const grpc_metadata *response_md, @@ -107,11 +105,10 @@ static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx, calld->consumed_md = consumed_md; calld->num_consumed_md = num_consumed_md; error = grpc_metadata_batch_filter( - exec_ctx, batch->payload->recv_initial_metadata.recv_initial_metadata, + batch->payload->recv_initial_metadata.recv_initial_metadata, remove_consumed_md, elem, "Response metadata filtering error"); } - GRPC_CLOSURE_SCHED(exec_ctx, calld->original_recv_initial_metadata_ready, - error); + GRPC_CLOSURE_SCHED(calld->original_recv_initial_metadata_ready, error); } // Called from application code. @@ -121,7 +118,7 @@ static void on_md_processing_done( grpc_status_code status, const char *error_details) { grpc_call_element *elem = (grpc_call_element *)user_data; call_data *calld = (call_data *)elem->call_data; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + ExecCtx _local_exec_ctx; // If the call was not cancelled while we were in flight, process the result. if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT, (gpr_atm)STATE_DONE)) { @@ -134,34 +131,32 @@ static void on_md_processing_done( GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details), GRPC_ERROR_INT_GRPC_STATUS, status); } - on_md_processing_done_inner(&exec_ctx, elem, consumed_md, num_consumed_md, - response_md, num_response_md, error); + on_md_processing_done_inner(elem, consumed_md, num_consumed_md, response_md, + num_response_md, error); } // Clean up. for (size_t i = 0; i < calld->md.count; i++) { - grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].key); - grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].value); + grpc_slice_unref_internal(calld->md.metadata[i].key); + grpc_slice_unref_internal(calld->md.metadata[i].value); } grpc_metadata_array_destroy(&calld->md); - GRPC_CALL_STACK_UNREF(&exec_ctx, calld->owning_call, "server_auth_metadata"); - grpc_exec_ctx_finish(&exec_ctx); + GRPC_CALL_STACK_UNREF(calld->owning_call, "server_auth_metadata"); + grpc_exec_ctx_finish(); } -static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void cancel_call(void *arg, grpc_error *error) { grpc_call_element *elem = (grpc_call_element *)arg; call_data *calld = (call_data *)elem->call_data; // If the result was not already processed, invoke the callback now. if (error != GRPC_ERROR_NONE && gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT, (gpr_atm)STATE_CANCELLED)) { - on_md_processing_done_inner(exec_ctx, elem, NULL, 0, NULL, 0, - GRPC_ERROR_REF(error)); + on_md_processing_done_inner(elem, NULL, 0, NULL, 0, GRPC_ERROR_REF(error)); } - GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call"); + GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_call"); } -static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void recv_initial_metadata_ready(void *arg, grpc_error *error) { grpc_call_element *elem = (grpc_call_element *)arg; channel_data *chand = (channel_data *)elem->channel_data; call_data *calld = (call_data *)elem->call_data; @@ -173,7 +168,7 @@ static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg, GRPC_CALL_STACK_REF(calld->owning_call, "cancel_call"); GRPC_CLOSURE_INIT(&calld->cancel_closure, cancel_call, elem, grpc_schedule_on_exec_ctx); - grpc_call_combiner_set_notify_on_cancel(exec_ctx, calld->call_combiner, + grpc_call_combiner_set_notify_on_cancel(calld->call_combiner, &calld->cancel_closure); GRPC_CALL_STACK_REF(calld->owning_call, "server_auth_metadata"); calld->md = metadata_batch_to_md_array( @@ -184,13 +179,12 @@ static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg, return; } } - GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready, + GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready, GRPC_ERROR_REF(error)); } static void auth_start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *batch) { + grpc_call_element *elem, grpc_transport_stream_op_batch *batch) { call_data *calld = (call_data *)elem->call_data; if (batch->recv_initial_metadata) { // Inject our callback. @@ -200,12 +194,11 @@ static void auth_start_transport_stream_op_batch( batch->payload->recv_initial_metadata.recv_initial_metadata_ready = &calld->recv_initial_metadata_ready; } - grpc_call_next_op(exec_ctx, elem, batch); + grpc_call_next_op(elem, batch); } /* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, +static grpc_error *init_call_elem(grpc_call_element *elem, const grpc_call_element_args *args) { call_data *calld = (call_data *)elem->call_data; channel_data *chand = (channel_data *)elem->channel_data; @@ -231,13 +224,12 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, } /* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, +static void destroy_call_elem(grpc_call_element *elem, const grpc_call_final_info *final_info, grpc_closure *ignored) {} /* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, +static grpc_error *init_channel_elem(grpc_channel_element *elem, grpc_channel_element_args *args) { GPR_ASSERT(!args->is_last); channel_data *chand = (channel_data *)elem->channel_data; @@ -253,11 +245,10 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, } /* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) { +static void destroy_channel_elem(grpc_channel_element *elem) { channel_data *chand = (channel_data *)elem->channel_data; GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter"); - grpc_server_credentials_unref(exec_ctx, chand->creds); + grpc_server_credentials_unref(chand->creds); } const grpc_channel_filter grpc_server_auth_filter = { |