diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-10-13 16:07:13 -0700 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-10-18 17:12:19 -0700 |
commit | 0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch) | |
tree | e43d5de442fdcc3d39cd5af687f319fa39612d3f /src/core/ext/filters/load_reporting | |
parent | 6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (diff) |
Removing instances of exec_ctx being passed around in functions in
src/core. exec_ctx is now a thread_local pointer of type ExecCtx instead of
grpc_exec_ctx which is initialized whenever ExecCtx is instantiated. ExecCtx
also keeps track of the previous exec_ctx so that nesting of exec_ctx is
allowed. This means that there is only one exec_ctx being used at any
time. Also, grpc_exec_ctx_finish is called in the destructor of the
object, and the previous exec_ctx is restored to avoid breaking current
functionality. The code still explicitly calls grpc_exec_ctx_finish
because removing all such instances causes the code to break.
Diffstat (limited to 'src/core/ext/filters/load_reporting')
-rw-r--r-- | src/core/ext/filters/load_reporting/server_load_reporting_filter.cc | 33 | ||||
-rw-r--r-- | src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc | 2 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index ca8a3b2a13..6c93d0e821 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -54,8 +54,7 @@ typedef struct channel_data { intptr_t id; /**< an id unique to the channel */ } channel_data; -static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *err) { +static void on_initial_md_ready(void *user_data, grpc_error *err) { grpc_call_element *elem = (grpc_call_element *)user_data; call_data *calld = (call_data *)elem->call_data; @@ -73,20 +72,19 @@ static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data, GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.lb_token->md)); calld->have_initial_md_string = true; grpc_metadata_batch_remove( - exec_ctx, calld->recv_initial_metadata, + calld->recv_initial_metadata, calld->recv_initial_metadata->idx.named.lb_token); } } else { GRPC_ERROR_REF(err); } calld->ops_recv_initial_metadata_ready->cb( - exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err); + calld->ops_recv_initial_metadata_ready->cb_arg, err); GRPC_ERROR_UNREF(err); } /* 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->id = (intptr_t)args->call_stack; @@ -108,7 +106,7 @@ 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) { call_data *calld = (call_data *)elem->call_data; @@ -125,19 +123,18 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, */ if (calld->have_initial_md_string) { - grpc_slice_unref_internal(exec_ctx, calld->initial_md_string); + grpc_slice_unref_internal(calld->initial_md_string); } if (calld->have_trailing_md_string) { - grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string); + grpc_slice_unref_internal(calld->trailing_md_string); } if (calld->have_service_method) { - grpc_slice_unref_internal(exec_ctx, calld->service_method); + grpc_slice_unref_internal(calld->service_method); } } /* 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); @@ -158,8 +155,7 @@ 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) { /* TODO(dgq): do something with the data channel_data *chand = elem->channel_data; grpc_load_reporting_call_data lr_call_data = { @@ -173,8 +169,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, */ } -static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, - void *user_data, +static grpc_filtered_mdelem lr_trailing_md_filter(void *user_data, grpc_mdelem md) { grpc_call_element *elem = (grpc_call_element *)user_data; call_data *calld = (call_data *)elem->call_data; @@ -186,8 +181,7 @@ static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, } static void lr_start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { + grpc_call_element *elem, grpc_transport_stream_op_batch *op) { GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0); call_data *calld = (call_data *)elem->call_data; @@ -203,12 +197,11 @@ static void lr_start_transport_stream_op_batch( GRPC_LOG_IF_ERROR( "grpc_metadata_batch_filter", grpc_metadata_batch_filter( - exec_ctx, op->payload->send_trailing_metadata.send_trailing_metadata, lr_trailing_md_filter, elem, "LR trailing metadata filtering error")); } - grpc_call_next_op(exec_ctx, elem, op); + grpc_call_next_op(elem, op); GPR_TIMER_END("lr_start_transport_stream_op_batch", 0); } diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc index 223fb3ee8b..6a38b71832 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc @@ -38,7 +38,7 @@ static bool is_load_reporting_enabled(const grpc_channel_args *a) { } static bool maybe_add_server_load_reporting_filter( - grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) { + grpc_channel_stack_builder *builder, void *arg) { const grpc_channel_args *args = grpc_channel_stack_builder_get_channel_arguments(builder); const grpc_channel_filter *filter = (const grpc_channel_filter *)arg; |