Przeglądaj źródła

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.

Guantao Liu 6 lat temu
rodzic
commit
d61e37111d

+ 5 - 4
src/core/ext/filters/client_channel/backup_poller.cc

@@ -16,18 +16,19 @@
  *
  */
 
-#include <grpc/support/port_platform.h>
-
 #include "src/core/ext/filters/client_channel/backup_poller.h"
 
 #include <grpc/grpc.h>
 #include <grpc/support/alloc.h>
 #include <grpc/support/log.h>
+#include <grpc/support/port_platform.h>
 #include <grpc/support/sync.h>
+
 #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);

+ 4 - 0
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 */

+ 2 - 0
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