From d61e37111d914eda867b455c94ebedf21b9e7612 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Mon, 24 Jun 2019 14:58:30 -0700 Subject: [PATCH] Disable the backup poller in the client channel when using the background poller. Also, add the missing implementations of grpc_iomgr_run_in_background() for cfstream and libuv. --- src/core/ext/filters/client_channel/backup_poller.cc | 9 +++++---- src/core/lib/iomgr/iomgr_posix_cfstream.cc | 4 ++++ src/core/lib/iomgr/iomgr_uv.cc | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 9e51a83415e..06a241aa8c6 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -16,18 +16,19 @@ * */ -#include - #include "src/core/ext/filters/client_channel/backup_poller.h" #include #include #include +#include #include + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/global_config.h" #include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/surface/channel.h" @@ -153,7 +154,7 @@ static void g_poller_init_locked() { void grpc_client_channel_start_backup_polling( grpc_pollset_set* interested_parties) { - if (g_poll_interval_ms == 0) { + if (g_poll_interval_ms == 0 || grpc_iomgr_run_in_background()) { return; } gpr_mu_lock(&g_poller_mu); @@ -171,7 +172,7 @@ void grpc_client_channel_start_backup_polling( void grpc_client_channel_stop_backup_polling( grpc_pollset_set* interested_parties) { - if (g_poll_interval_ms == 0) { + if (g_poll_interval_ms == 0 || grpc_iomgr_run_in_background()) { return; } grpc_pollset_set_del_pollset(interested_parties, g_poller->pollset); diff --git a/src/core/lib/iomgr/iomgr_posix_cfstream.cc b/src/core/lib/iomgr/iomgr_posix_cfstream.cc index cf4d05318ea..ac9a4497f77 100644 --- a/src/core/lib/iomgr/iomgr_posix_cfstream.cc +++ b/src/core/lib/iomgr/iomgr_posix_cfstream.cc @@ -90,4 +90,8 @@ void grpc_set_default_iomgr_platform() { grpc_set_iomgr_platform_vtable(&vtable); } +bool grpc_iomgr_run_in_background() { + return grpc_event_engine_run_in_background(); +} + #endif /* GRPC_CFSTREAM_IOMGR */ diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc index 4a984446dba..d00bfa4d46e 100644 --- a/src/core/lib/iomgr/iomgr_uv.cc +++ b/src/core/lib/iomgr/iomgr_uv.cc @@ -37,4 +37,6 @@ void grpc_set_default_iomgr_platform() { grpc_custom_iomgr_init(&grpc_uv_socket_vtable, &uv_resolver_vtable, &uv_timer_vtable, &uv_pollset_vtable); } + +bool grpc_iomgr_run_in_background() { return false; } #endif