[init] Move client backup poller init to be directly called by init.cc (#30893)

* [init] Move backup poller init out of client channel path

* fix

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/29598/head
Craig Tiller 3 years ago committed by GitHub
parent bf1856d2cc
commit 3502837c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 3
      src/core/ext/filters/client_channel/backup_poller.cc
  3. 2
      src/core/ext/filters/client_channel/client_channel_plugin.cc
  4. 2
      src/core/lib/surface/init.cc

@ -523,6 +523,7 @@ grpc_cc_library(
"gpr",
"grpc_authorization_base",
"grpc_base",
"grpc_client_channel",
"grpc_common",
"grpc_http_filters",
"grpc_security_base",

@ -54,7 +54,6 @@ struct backup_poller {
};
} // namespace
static gpr_once g_once = GPR_ONCE_INIT;
static gpr_mu g_poller_mu;
static backup_poller* g_poller = nullptr; // guarded by g_poller_mu
// g_poll_interval_ms is set only once at the first time
@ -73,7 +72,7 @@ GPR_GLOBAL_CONFIG_DEFINE_INT32(
"turn off the backup polls.");
void grpc_client_channel_global_init_backup_polling() {
gpr_once_init(&g_once, [] { gpr_mu_init(&g_poller_mu); });
gpr_mu_init(&g_poller_mu);
int32_t poll_interval_ms =
GPR_GLOBAL_CONFIG_GET(grpc_client_channel_backup_poll_interval_ms);
if (poll_interval_ms < 0) {

@ -18,7 +18,6 @@
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/client_channel/backup_poller.h"
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/http_proxy.h"
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
@ -32,7 +31,6 @@
void grpc_client_channel_init(void) {
grpc_core::ProxyMapperRegistry::Init();
grpc_core::RegisterHttpProxyMapper();
grpc_client_channel_global_init_backup_polling();
}
void grpc_client_channel_shutdown(void) {

@ -33,6 +33,7 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/ext/filters/client_channel/backup_poller.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
@ -126,6 +127,7 @@ static void do_basic_init(void) {
grpc_event_engine::experimental::RegisterForkHandlers();
grpc_fork_handlers_auto_register();
grpc_tracer_init();
grpc_client_channel_global_init_backup_polling();
}
typedef struct grpc_plugin {

Loading…
Cancel
Save