diff options
-rw-r--r-- | src/core/ext/filters/client_channel/backup_poller.cc | 19 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/backup_poller.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index e7d72d1fde..3e2faa57bc 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015 gRPC authors. + * Copyright 2017 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,13 +127,7 @@ static void run_poller(void* arg, grpc_error* error) { &p->run_poller_closure); } -void grpc_client_channel_start_backup_polling( - grpc_pollset_set* interested_parties) { - gpr_once_init(&g_once, init_globals); - if (g_poll_interval_ms == 0) { - return; - } - gpr_mu_lock(&g_poller_mu); +static void g_poller_init_locked() { if (g_poller == nullptr) { g_poller = static_cast<backup_poller*>(gpr_zalloc(sizeof(backup_poller))); g_poller->pollset = @@ -149,7 +143,16 @@ void grpc_client_channel_start_backup_polling( grpc_core::ExecCtx::Get()->Now() + g_poll_interval_ms, &g_poller->run_poller_closure); } +} +void grpc_client_channel_start_backup_polling( + grpc_pollset_set* interested_parties) { + gpr_once_init(&g_once, init_globals); + if (g_poll_interval_ms == 0) { + return; + } + gpr_mu_lock(&g_poller_mu); + g_poller_init_locked(); gpr_ref(&g_poller->refs); /* Get a reference to g_poller->pollset before releasing g_poller_mu to make * TSAN happy. Otherwise, reading from g_poller (i.e g_poller->pollset) after diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 45bdf10d6c..7285b9b93e 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015 gRPC authors. + * Copyright 2017 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |