diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-12-06 09:05:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 09:05:05 -0800 |
commit | ad4d2dde0052efbbf49d64b0843c45f0381cfeb3 (patch) | |
tree | 6a657f8c6179d873b34505cdc24bce9462ca68eb /src/core/ext/filters/client_channel/channel_connectivity.cc | |
parent | a3df36cc2505a89c2f481eea4a66a87b3002844a (diff) |
Revert "All instances of exec_ctx being passed around in src/core removed"
Diffstat (limited to 'src/core/ext/filters/client_channel/channel_connectivity.cc')
-rw-r--r-- | src/core/ext/filters/client_channel/channel_connectivity.cc | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc index 20693ba419..7eaf5d98cd 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.cc +++ b/src/core/ext/filters/client_channel/channel_connectivity.cc @@ -33,22 +33,22 @@ grpc_connectivity_state grpc_channel_check_connectivity_state( /* forward through to the underlying client channel */ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel)); - grpc_core::ExecCtx exec_ctx; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_connectivity_state state; GRPC_API_TRACE( "grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2, (channel, try_to_connect)); if (client_channel_elem->filter == &grpc_client_channel_filter) { - state = grpc_client_channel_check_connectivity_state(client_channel_elem, - try_to_connect); - + state = grpc_client_channel_check_connectivity_state( + &exec_ctx, client_channel_elem, try_to_connect); + grpc_exec_ctx_finish(&exec_ctx); return state; } gpr_log(GPR_ERROR, "grpc_channel_check_connectivity_state called on something that is " "not a client channel, but '%s'", client_channel_elem->filter->name); - + grpc_exec_ctx_finish(&exec_ctx); return GRPC_CHANNEL_SHUTDOWN; } @@ -73,11 +73,12 @@ typedef struct { void* tag; } state_watcher; -static void delete_state_watcher(state_watcher* w) { +static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element( grpc_channel_get_channel_stack(w->channel)); if (client_channel_elem->filter == &grpc_client_channel_filter) { - GRPC_CHANNEL_INTERNAL_UNREF(w->channel, "watch_channel_connectivity"); + GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel, + "watch_channel_connectivity"); } else { abort(); } @@ -85,7 +86,8 @@ static void delete_state_watcher(state_watcher* w) { gpr_free(w); } -static void finished_completion(void* pw, grpc_cq_completion* ignored) { +static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw, + grpc_cq_completion* ignored) { bool should_delete = false; state_watcher* w = (state_watcher*)pw; gpr_mu_lock(&w->mu); @@ -100,19 +102,19 @@ static void finished_completion(void* pw, grpc_cq_completion* ignored) { gpr_mu_unlock(&w->mu); if (should_delete) { - delete_state_watcher(w); + delete_state_watcher(exec_ctx, w); } } -static void partly_done(state_watcher* w, bool due_to_completion, - grpc_error* error) { +static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w, + bool due_to_completion, grpc_error* error) { if (due_to_completion) { - grpc_timer_cancel(&w->alarm); + grpc_timer_cancel(exec_ctx, &w->alarm); } else { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element( grpc_channel_get_channel_stack(w->channel)); grpc_client_channel_watch_connectivity_state( - client_channel_elem, + exec_ctx, client_channel_elem, grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)), nullptr, &w->on_complete, nullptr); } @@ -147,7 +149,7 @@ static void partly_done(state_watcher* w, bool due_to_completion, w->error = error; } w->phase = CALLING_BACK_AND_FINISHED; - grpc_cq_end_op(w->cq, w->tag, w->error, finished_completion, w, + grpc_cq_end_op(exec_ctx, w->cq, w->tag, w->error, finished_completion, w, &w->completion_storage); break; case CALLING_BACK_AND_FINISHED: @@ -159,12 +161,14 @@ static void partly_done(state_watcher* w, bool due_to_completion, GRPC_ERROR_UNREF(error); } -static void watch_complete(void* pw, grpc_error* error) { - partly_done((state_watcher*)pw, true, GRPC_ERROR_REF(error)); +static void watch_complete(grpc_exec_ctx* exec_ctx, void* pw, + grpc_error* error) { + partly_done(exec_ctx, (state_watcher*)pw, true, GRPC_ERROR_REF(error)); } -static void timeout_complete(void* pw, grpc_error* error) { - partly_done((state_watcher*)pw, false, GRPC_ERROR_REF(error)); +static void timeout_complete(grpc_exec_ctx* exec_ctx, void* pw, + grpc_error* error) { + partly_done(exec_ctx, (state_watcher*)pw, false, GRPC_ERROR_REF(error)); } int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) { @@ -179,10 +183,12 @@ typedef struct watcher_timer_init_arg { gpr_timespec deadline; } watcher_timer_init_arg; -static void watcher_timer_init(void* arg, grpc_error* error_ignored) { +static void watcher_timer_init(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error_ignored) { watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg; - grpc_timer_init(&wa->w->alarm, grpc_timespec_to_millis_round_up(wa->deadline), + grpc_timer_init(exec_ctx, &wa->w->alarm, + grpc_timespec_to_millis_round_up(wa->deadline), &wa->w->on_timeout); gpr_free(wa); } @@ -198,7 +204,7 @@ void grpc_channel_watch_connectivity_state( gpr_timespec deadline, grpc_completion_queue* cq, void* tag) { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel)); - grpc_core::ExecCtx exec_ctx; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w)); GRPC_API_TRACE( @@ -235,10 +241,12 @@ void grpc_channel_watch_connectivity_state( if (client_channel_elem->filter == &grpc_client_channel_filter) { GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity"); grpc_client_channel_watch_connectivity_state( - client_channel_elem, + &exec_ctx, client_channel_elem, grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &w->state, &w->on_complete, &w->watcher_timer_init); } else { abort(); } + + grpc_exec_ctx_finish(&exec_ctx); } |