diff options
author | Yuchen Zeng <zyc@google.com> | 2017-10-05 23:22:11 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2017-10-30 12:06:52 -0700 |
commit | dd77922d271684b64908493181b2bb0559d97c96 (patch) | |
tree | b09604660b3f69d5820f7f7fb98bc9ba1db1e5ce | |
parent | b41014eeefa682c80d8bf48c720b23d00de29e03 (diff) |
Add comments, fix backup_poller_shutdown_unref
-rw-r--r-- | src/core/ext/filters/client_channel/backup_poller.cc | 21 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/backup_poller.h | 4 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 784e75624b..9d6719d47c 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -60,14 +60,13 @@ static void init_g_poller_mu() { gpr_free(env); } -static bool backup_poller_shutdown_unref(grpc_exec_ctx* exec_ctx, +static void backup_poller_shutdown_unref(grpc_exec_ctx* exec_ctx, backup_poller* p) { if (gpr_unref(&p->shutdown_refs)) { grpc_pollset_destroy(exec_ctx, p->pollset); gpr_free(p->pollset); gpr_free(p); } - return true; } static void done_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { @@ -90,6 +89,13 @@ static void g_poller_unref(grpc_exec_ctx* exec_ctx) { } } +static void schedule_polling_timer(gpr_timespec now) { + grpc_timer_init( + exec_ctx, &p->polling_timer, + gpr_time_add(now, gpr_time_from_millis(g_poll_interval_ms, GPR_TIMESPAN)), + &p->run_poller_closure, now); +} + static void run_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { backup_poller* p = (backup_poller*)arg; if (error != GRPC_ERROR_NONE) { @@ -105,10 +111,7 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { gpr_inf_past(GPR_CLOCK_MONOTONIC)); gpr_mu_unlock(p->pollset_mu); GRPC_LOG_IF_ERROR("Run client channel backup poller", err); - grpc_timer_init( - exec_ctx, &p->polling_timer, - gpr_time_add(now, gpr_time_from_millis(g_poll_interval_ms, GPR_TIMESPAN)), - &p->run_poller_closure, now); + schedule_polling_timer(now); } void grpc_client_channel_start_backup_polling( @@ -127,11 +130,7 @@ void grpc_client_channel_start_backup_polling( gpr_ref_init(&g_poller->shutdown_refs, 2); GRPC_CLOSURE_INIT(&g_poller->run_poller_closure, run_poller, g_poller, grpc_schedule_on_exec_ctx); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - grpc_timer_init(exec_ctx, &g_poller->polling_timer, - gpr_time_add(now, gpr_time_from_millis(g_poll_interval_ms, - GPR_TIMESPAN)), - &g_poller->run_poller_closure, now); + schedule_polling_timer(gpr_now(GPR_CLOCK_MONOTONIC)); } gpr_ref(&g_poller->refs); gpr_mu_unlock(&g_poller_mu); diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 3044f75711..e993d50639 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -23,11 +23,11 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/iomgr/exec_ctx.h" -/* Constantly watches client channel connectivity status to reconnect a - * transiently disconnected channel */ +/* Start polling \a interested_parties periodically in the timer thread */ void grpc_client_channel_start_backup_polling( grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties); +/* Stop polling \a interested_parties */ void grpc_client_channel_stop_backup_polling( grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties); |