Merge branch 'master' into revert-20610-revert-20277-grpc-19871/unary_unary_client_aio-implement-timeout

pull/20617/head
Lidi Zheng 5 years ago
commit 9c8657d6c0
  1. 3
      .gitmodules
  2. 60
      Makefile
  3. 3
      bazel/grpc_deps.bzl
  4. 17
      config.m4
  5. 17
      config.w32
  6. 34
      grpc.gemspec
  7. 14
      grpc.gyp
  8. 4
      include/grpcpp/impl/codegen/call_op_set.h
  9. 7
      include/grpcpp/impl/codegen/client_context_impl.h
  10. 34
      package.xml
  11. 2338
      src/boringssl/crypto_test_data.cc
  12. 1345
      src/boringssl/err_data.c
  13. 52
      src/core/ext/filters/client_channel/client_channel.cc
  14. 5
      src/core/ext/filters/client_channel/lb_policy.cc
  15. 6
      src/core/ext/filters/client_channel/lb_policy.h
  16. 126
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  17. 268
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  18. 3
      src/core/ext/filters/client_channel/resolver.cc
  19. 6
      src/core/ext/filters/client_channel/resolver.h
  20. 26
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  21. 56
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
  22. 6
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
  23. 13
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc
  24. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  25. 87
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  26. 24
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  27. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
  28. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
  29. 31
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
  30. 48
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  31. 2
      src/core/ext/filters/client_channel/resolver_factory.h
  32. 2
      src/core/ext/filters/client_channel/resolver_registry.cc
  33. 2
      src/core/ext/filters/client_channel/resolver_registry.h
  34. 10
      src/core/ext/filters/client_channel/xds/xds_api.cc
  35. 146
      src/core/ext/filters/client_channel/xds/xds_client.cc
  36. 15
      src/core/ext/filters/client_channel/xds/xds_client.h
  37. 290
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  38. 5
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  39. 8
      src/core/ext/transport/chttp2/transport/internal.h
  40. 3
      src/core/ext/transport/chttp2/transport/writing.cc
  41. 116
      src/core/lib/iomgr/combiner.cc
  42. 39
      src/core/lib/iomgr/combiner.h
  43. 5
      src/core/lib/iomgr/exec_ctx.h
  44. 46
      src/core/lib/iomgr/resource_quota.cc
  45. 2
      src/core/lib/iomgr/tcp_posix.cc
  46. 16
      src/core/lib/transport/connectivity_state.cc
  47. 9
      src/core/lib/transport/connectivity_state.h
  48. 2567
      src/core/tsi/grpc_shadow_boringssl.h
  49. 3914
      src/objective-c/BoringSSL-GRPC.podspec
  50. 2569
      src/objective-c/grpc_shadow_boringssl_symbol_list
  51. 98
      src/python/grpcio/grpc/experimental/aio/__init__.py
  52. 59
      src/python/grpcio/grpc/experimental/aio/_channel.py
  53. 13
      src/python/grpcio/grpc_core_dependencies.py
  54. 1349
      templates/src/objective-c/BoringSSL-GRPC.podspec.template
  55. 4
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
  56. 12
      test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
  57. 2
      test/core/client_channel/resolvers/dns_resolver_test.cc
  58. 4
      test/core/client_channel/resolvers/fake_resolver_test.cc
  59. 2
      test/core/client_channel/resolvers/sockaddr_resolver_test.cc
  60. 2
      test/core/end2end/fixtures/h2_sockpair+trace.cc
  61. 2
      test/core/end2end/fixtures/h2_sockpair.cc
  62. 2
      test/core/end2end/fixtures/h2_sockpair_1byte.cc
  63. 11
      test/core/end2end/fixtures/h2_spiffe.cc
  64. 7
      test/core/end2end/fixtures/h2_ssl.cc
  65. 7
      test/core/end2end/fixtures/h2_ssl_cred_reload.cc
  66. 5
      test/core/end2end/fixtures/h2_ssl_proxy.cc
  67. 2
      test/core/end2end/fixtures/h2_uds.cc
  68. 123
      test/core/end2end/fixtures/http_proxy_fixture.cc
  69. 2
      test/core/end2end/fixtures/inproc.cc
  70. 24
      test/core/end2end/fuzzers/api_fuzzer.cc
  71. 4
      test/core/end2end/goaway_server_test.cc
  72. 33
      test/core/iomgr/combiner_test.cc
  73. 4
      test/core/iomgr/threadpool_test.cc
  74. 8
      test/core/iomgr/udp_server_test.cc
  75. 2
      test/core/memory_usage/memory_usage_test.cc
  76. 2
      test/core/memory_usage/server.cc
  77. 5
      test/core/nanopb/fuzzer_response.cc
  78. 5
      test/core/nanopb/fuzzer_serverlist.cc
  79. 2
      test/core/security/alts_credentials_fuzzer.cc
  80. 2
      test/core/security/alts_security_connector_test.cc
  81. 60
      test/core/security/credentials_test.cc
  82. 23
      test/core/security/jwt_verifier_test.cc
  83. 2
      test/core/transport/chttp2/bin_decoder_test.cc
  84. 2
      test/core/transport/chttp2/context_list_test.cc
  85. 4
      test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
  86. 2
      test/core/transport/chttp2/hpack_table_test.cc
  87. 2
      test/core/transport/chttp2/settings_timeout_test.cc
  88. 2
      test/core/transport/stream_owned_slice_test.cc
  89. 2
      test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc
  90. 25
      test/core/tsi/alts/handshaker/alts_handshaker_client_test.cc
  91. 18
      test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
  92. 2
      test/core/tsi/alts/handshaker/alts_tsi_utils_test.cc
  93. 3
      test/core/util/one_corpus_entry_fuzzer.cc
  94. 4
      test/cpp/end2end/BUILD
  95. 3
      test/cpp/end2end/end2end_test.cc
  96. 4
      test/cpp/end2end/thread_stress_test.cc
  97. 22
      test/cpp/end2end/xds_bootstrap.json
  98. 12
      test/cpp/end2end/xds_bootstrap_bad.json
  99. 316
      test/cpp/end2end/xds_end2end_test.cc
  100. 2
      test/cpp/interop/client_helper.cc
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitmodules vendored

@ -43,9 +43,6 @@
[submodule "third_party/protoc-gen-validate"]
path = third_party/protoc-gen-validate
url = https://github.com/envoyproxy/protoc-gen-validate.git
[submodule "third_party/upb"]
path = third_party/upb
url = https://github.com/protocolbuffers/upb.git
[submodule "third_party/udpa"]
path = third_party/udpa
url = https://github.com/cncf/udpa.git

@ -7740,6 +7740,7 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/bytestring/ber.c \
third_party/boringssl/crypto/bytestring/cbb.c \
third_party/boringssl/crypto/bytestring/cbs.c \
third_party/boringssl/crypto/bytestring/unicode.c \
third_party/boringssl/crypto/chacha/chacha.c \
third_party/boringssl/crypto/cipher_extra/cipher_extra.c \
third_party/boringssl/crypto/cipher_extra/derive_key.c \
@ -7750,7 +7751,6 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/cipher_extra/e_null.c \
third_party/boringssl/crypto/cipher_extra/e_rc2.c \
third_party/boringssl/crypto/cipher_extra/e_rc4.c \
third_party/boringssl/crypto/cipher_extra/e_ssl3.c \
third_party/boringssl/crypto/cipher_extra/e_tls.c \
third_party/boringssl/crypto/cipher_extra/tls_cbc.c \
third_party/boringssl/crypto/cmac/cmac.c \
@ -7771,7 +7771,8 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/dsa/dsa.c \
third_party/boringssl/crypto/dsa/dsa_asn1.c \
third_party/boringssl/crypto/ec_extra/ec_asn1.c \
third_party/boringssl/crypto/ecdh/ecdh.c \
third_party/boringssl/crypto/ec_extra/ec_derive.c \
third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c \
third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c \
third_party/boringssl/crypto/engine/engine.c \
third_party/boringssl/crypto/err/err.c \
@ -7786,14 +7787,18 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/evp/p_ed25519_asn1.c \
third_party/boringssl/crypto/evp/p_rsa.c \
third_party/boringssl/crypto/evp/p_rsa_asn1.c \
third_party/boringssl/crypto/evp/p_x25519.c \
third_party/boringssl/crypto/evp/p_x25519_asn1.c \
third_party/boringssl/crypto/evp/pbkdf.c \
third_party/boringssl/crypto/evp/print.c \
third_party/boringssl/crypto/evp/scrypt.c \
third_party/boringssl/crypto/evp/sign.c \
third_party/boringssl/crypto/ex_data.c \
third_party/boringssl/crypto/fipsmodule/bcm.c \
third_party/boringssl/crypto/fipsmodule/fips_shared_support.c \
third_party/boringssl/crypto/fipsmodule/is_fips.c \
third_party/boringssl/crypto/hkdf/hkdf.c \
third_party/boringssl/crypto/hrss/hrss.c \
third_party/boringssl/crypto/lhash/lhash.c \
third_party/boringssl/crypto/mem.c \
third_party/boringssl/crypto/obj/obj.c \
@ -7824,6 +7829,8 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/refcount_c11.c \
third_party/boringssl/crypto/refcount_lock.c \
third_party/boringssl/crypto/rsa_extra/rsa_asn1.c \
third_party/boringssl/crypto/rsa_extra/rsa_print.c \
third_party/boringssl/crypto/siphash/siphash.c \
third_party/boringssl/crypto/stack/stack.c \
third_party/boringssl/crypto/thread.c \
third_party/boringssl/crypto/thread_none.c \
@ -7900,6 +7907,7 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/x509v3/v3_int.c \
third_party/boringssl/crypto/x509v3/v3_lib.c \
third_party/boringssl/crypto/x509v3/v3_ncons.c \
third_party/boringssl/crypto/x509v3/v3_ocsp.c \
third_party/boringssl/crypto/x509v3/v3_pci.c \
third_party/boringssl/crypto/x509v3/v3_pcia.c \
third_party/boringssl/crypto/x509v3/v3_pcons.c \
@ -7911,7 +7919,6 @@ LIBBORINGSSL_SRC = \
third_party/boringssl/crypto/x509v3/v3_sxnet.c \
third_party/boringssl/crypto/x509v3/v3_utl.c \
third_party/boringssl/ssl/bio_ssl.cc \
third_party/boringssl/ssl/custom_extensions.cc \
third_party/boringssl/ssl/d1_both.cc \
third_party/boringssl/ssl/d1_lib.cc \
third_party/boringssl/ssl/d1_pkt.cc \
@ -7978,6 +7985,7 @@ LIBBORINGSSL_TEST_UTIL_SRC = \
third_party/boringssl/crypto/test/file_test.cc \
third_party/boringssl/crypto/test/malloc.cc \
third_party/boringssl/crypto/test/test_util.cc \
third_party/boringssl/crypto/test/wycheproof_util.cc \
PUBLIC_HEADERS_CXX += \
@ -20163,8 +20171,10 @@ endif
BORINGSSL_SSL_TEST_SRC = \
third_party/boringssl/crypto/test/abi_test.cc \
third_party/boringssl/crypto/test/gtest_main.cc \
third_party/boringssl/ssl/span_test.cc \
third_party/boringssl/ssl/ssl_c_test.c \
third_party/boringssl/ssl/ssl_test.cc \
BORINGSSL_SSL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BORINGSSL_SSL_TEST_SRC))))
@ -20195,10 +20205,14 @@ endif
$(BORINGSSL_SSL_TEST_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
$(BORINGSSL_SSL_TEST_OBJS): CXXFLAGS += -fno-exceptions
$(BORINGSSL_SSL_TEST_OBJS): CFLAGS += -g
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/abi_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/gtest_main.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/ssl/span_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/ssl/ssl_c_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/ssl/ssl_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
deps_boringssl_ssl_test: $(BORINGSSL_SSL_TEST_OBJS:.o=.dep)
@ -20210,6 +20224,7 @@ endif
BORINGSSL_CRYPTO_TEST_SRC = \
src/boringssl/crypto_test_data.cc \
third_party/boringssl/crypto/abi_self_test.cc \
third_party/boringssl/crypto/asn1/asn1_test.cc \
third_party/boringssl/crypto/base64/base64_test.cc \
third_party/boringssl/crypto/bio/bio_test.cc \
@ -20221,13 +20236,14 @@ BORINGSSL_CRYPTO_TEST_SRC = \
third_party/boringssl/crypto/cmac/cmac_test.cc \
third_party/boringssl/crypto/compiler_test.cc \
third_party/boringssl/crypto/constant_time_test.cc \
third_party/boringssl/crypto/cpu-arm-linux_test.cc \
third_party/boringssl/crypto/curve25519/ed25519_test.cc \
third_party/boringssl/crypto/curve25519/spake25519_test.cc \
third_party/boringssl/crypto/curve25519/x25519_test.cc \
third_party/boringssl/crypto/dh/dh_test.cc \
third_party/boringssl/crypto/digest_extra/digest_test.cc \
third_party/boringssl/crypto/dsa/dsa_test.cc \
third_party/boringssl/crypto/ecdh/ecdh_test.cc \
third_party/boringssl/crypto/ecdh_extra/ecdh_test.cc \
third_party/boringssl/crypto/err/err_test.cc \
third_party/boringssl/crypto/evp/evp_extra_test.cc \
third_party/boringssl/crypto/evp/evp_test.cc \
@ -20238,24 +20254,34 @@ BORINGSSL_CRYPTO_TEST_SRC = \
third_party/boringssl/crypto/fipsmodule/ec/ec_test.cc \
third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64_test.cc \
third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa_test.cc \
third_party/boringssl/crypto/fipsmodule/md5/md5_test.cc \
third_party/boringssl/crypto/fipsmodule/modes/gcm_test.cc \
third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg_test.cc \
third_party/boringssl/crypto/fipsmodule/sha/sha_test.cc \
third_party/boringssl/crypto/hkdf/hkdf_test.cc \
third_party/boringssl/crypto/hmac_extra/hmac_test.cc \
third_party/boringssl/crypto/hrss/hrss_test.cc \
third_party/boringssl/crypto/impl_dispatch_test.cc \
third_party/boringssl/crypto/lhash/lhash_test.cc \
third_party/boringssl/crypto/obj/obj_test.cc \
third_party/boringssl/crypto/pem/pem_test.cc \
third_party/boringssl/crypto/pkcs7/pkcs7_test.cc \
third_party/boringssl/crypto/pkcs8/pkcs12_test.cc \
third_party/boringssl/crypto/pkcs8/pkcs8_test.cc \
third_party/boringssl/crypto/poly1305/poly1305_test.cc \
third_party/boringssl/crypto/pool/pool_test.cc \
third_party/boringssl/crypto/rand_extra/rand_test.cc \
third_party/boringssl/crypto/refcount_test.cc \
third_party/boringssl/crypto/rsa_extra/rsa_test.cc \
third_party/boringssl/crypto/self_test.cc \
third_party/boringssl/crypto/siphash/siphash_test.cc \
third_party/boringssl/crypto/stack/stack_test.cc \
third_party/boringssl/crypto/test/abi_test.cc \
third_party/boringssl/crypto/test/file_test_gtest.cc \
third_party/boringssl/crypto/test/gtest_main.cc \
third_party/boringssl/crypto/thread_test.cc \
third_party/boringssl/crypto/x509/x509_test.cc \
third_party/boringssl/crypto/x509/x509_time_test.cc \
third_party/boringssl/crypto/x509v3/tab_test.cc \
third_party/boringssl/crypto/x509v3/v3name_test.cc \
@ -20289,6 +20315,8 @@ $(BORINGSSL_CRYPTO_TEST_OBJS): CXXFLAGS += -fno-exceptions
$(BORINGSSL_CRYPTO_TEST_OBJS): CFLAGS += -g
$(OBJDIR)/$(CONFIG)/src/boringssl/crypto_test_data.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/abi_self_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/asn1/asn1_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/base64/base64_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
@ -20311,6 +20339,8 @@ $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/compiler_test.o: $(LIBDIR)/$(C
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/constant_time_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/cpu-arm-linux_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/curve25519/ed25519_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/curve25519/spake25519_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
@ -20323,7 +20353,7 @@ $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/digest_extra/digest_test.o: $(
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/dsa/dsa_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/ecdh/ecdh_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/ecdh_extra/ecdh_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/err/err_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
@ -20345,18 +20375,28 @@ $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64_test.
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/md5/md5_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/modes/gcm_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/fipsmodule/sha/sha_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/hkdf/hkdf_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/hmac_extra/hmac_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/hrss/hrss_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/impl_dispatch_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/lhash/lhash_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/obj/obj_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/pem/pem_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/pkcs7/pkcs7_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/pkcs8/pkcs12_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
@ -20367,12 +20407,20 @@ $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/poly1305/poly1305_test.o: $(LI
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/pool/pool_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/rand_extra/rand_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/refcount_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/rsa_extra/rsa_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/self_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/siphash/siphash_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/stack/stack_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/abi_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/file_test_gtest.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/test/gtest_main.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
@ -20381,6 +20429,8 @@ $(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/thread_test.o: $(LIBDIR)/$(CON
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/x509/x509_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/x509/x509_time_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/x509v3/tab_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(OBJDIR)/$(CONFIG)/third_party/boringssl/crypto/x509v3/v3name_test.o: $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a

@ -100,10 +100,9 @@ def grpc_deps():
if "boringssl" not in native.existing_rules():
http_archive(
name = "boringssl",
# on the chromium-stable-with-bazel branch
# NOTE: This URL generates a tarball containing dynamic date
# information, so the sha256 is not consistent.
url = "https://boringssl.googlesource.com/boringssl/+archive/afc30d43eef92979b05776ec0963c9cede5fb80f.tar.gz",
url = "https://boringssl.googlesource.com/boringssl/+archive/83da28a68f32023fd3b95a8ae94991a07b1f6c62.tar.gz",
)
if "zlib" not in native.existing_rules():

@ -515,6 +515,7 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/bytestring/ber.c \
third_party/boringssl/crypto/bytestring/cbb.c \
third_party/boringssl/crypto/bytestring/cbs.c \
third_party/boringssl/crypto/bytestring/unicode.c \
third_party/boringssl/crypto/chacha/chacha.c \
third_party/boringssl/crypto/cipher_extra/cipher_extra.c \
third_party/boringssl/crypto/cipher_extra/derive_key.c \
@ -525,7 +526,6 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/cipher_extra/e_null.c \
third_party/boringssl/crypto/cipher_extra/e_rc2.c \
third_party/boringssl/crypto/cipher_extra/e_rc4.c \
third_party/boringssl/crypto/cipher_extra/e_ssl3.c \
third_party/boringssl/crypto/cipher_extra/e_tls.c \
third_party/boringssl/crypto/cipher_extra/tls_cbc.c \
third_party/boringssl/crypto/cmac/cmac.c \
@ -546,7 +546,8 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/dsa/dsa.c \
third_party/boringssl/crypto/dsa/dsa_asn1.c \
third_party/boringssl/crypto/ec_extra/ec_asn1.c \
third_party/boringssl/crypto/ecdh/ecdh.c \
third_party/boringssl/crypto/ec_extra/ec_derive.c \
third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c \
third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c \
third_party/boringssl/crypto/engine/engine.c \
third_party/boringssl/crypto/err/err.c \
@ -561,14 +562,18 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/evp/p_ed25519_asn1.c \
third_party/boringssl/crypto/evp/p_rsa.c \
third_party/boringssl/crypto/evp/p_rsa_asn1.c \
third_party/boringssl/crypto/evp/p_x25519.c \
third_party/boringssl/crypto/evp/p_x25519_asn1.c \
third_party/boringssl/crypto/evp/pbkdf.c \
third_party/boringssl/crypto/evp/print.c \
third_party/boringssl/crypto/evp/scrypt.c \
third_party/boringssl/crypto/evp/sign.c \
third_party/boringssl/crypto/ex_data.c \
third_party/boringssl/crypto/fipsmodule/bcm.c \
third_party/boringssl/crypto/fipsmodule/fips_shared_support.c \
third_party/boringssl/crypto/fipsmodule/is_fips.c \
third_party/boringssl/crypto/hkdf/hkdf.c \
third_party/boringssl/crypto/hrss/hrss.c \
third_party/boringssl/crypto/lhash/lhash.c \
third_party/boringssl/crypto/mem.c \
third_party/boringssl/crypto/obj/obj.c \
@ -599,6 +604,8 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/refcount_c11.c \
third_party/boringssl/crypto/refcount_lock.c \
third_party/boringssl/crypto/rsa_extra/rsa_asn1.c \
third_party/boringssl/crypto/rsa_extra/rsa_print.c \
third_party/boringssl/crypto/siphash/siphash.c \
third_party/boringssl/crypto/stack/stack.c \
third_party/boringssl/crypto/thread.c \
third_party/boringssl/crypto/thread_none.c \
@ -675,6 +682,7 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/x509v3/v3_int.c \
third_party/boringssl/crypto/x509v3/v3_lib.c \
third_party/boringssl/crypto/x509v3/v3_ncons.c \
third_party/boringssl/crypto/x509v3/v3_ocsp.c \
third_party/boringssl/crypto/x509v3/v3_pci.c \
third_party/boringssl/crypto/x509v3/v3_pcia.c \
third_party/boringssl/crypto/x509v3/v3_pcons.c \
@ -686,7 +694,6 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/crypto/x509v3/v3_sxnet.c \
third_party/boringssl/crypto/x509v3/v3_utl.c \
third_party/boringssl/ssl/bio_ssl.cc \
third_party/boringssl/ssl/custom_extensions.cc \
third_party/boringssl/ssl/d1_both.cc \
third_party/boringssl/ssl/d1_lib.cc \
third_party/boringssl/ssl/d1_pkt.cc \
@ -841,13 +848,14 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/digest_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/dsa)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ec_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ecdh)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ecdh_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ecdsa_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/engine)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/err)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/evp)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/fipsmodule)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/hkdf)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/hrss)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/lhash)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/obj)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/pem)
@ -858,6 +866,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rand_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rc4)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rsa_extra)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/siphash)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/stack)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509v3)

@ -485,6 +485,7 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\bytestring\\ber.c " +
"third_party\\boringssl\\crypto\\bytestring\\cbb.c " +
"third_party\\boringssl\\crypto\\bytestring\\cbs.c " +
"third_party\\boringssl\\crypto\\bytestring\\unicode.c " +
"third_party\\boringssl\\crypto\\chacha\\chacha.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\cipher_extra.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\derive_key.c " +
@ -495,7 +496,6 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\cipher_extra\\e_null.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\e_rc2.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\e_rc4.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\e_ssl3.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\e_tls.c " +
"third_party\\boringssl\\crypto\\cipher_extra\\tls_cbc.c " +
"third_party\\boringssl\\crypto\\cmac\\cmac.c " +
@ -516,7 +516,8 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\dsa\\dsa.c " +
"third_party\\boringssl\\crypto\\dsa\\dsa_asn1.c " +
"third_party\\boringssl\\crypto\\ec_extra\\ec_asn1.c " +
"third_party\\boringssl\\crypto\\ecdh\\ecdh.c " +
"third_party\\boringssl\\crypto\\ec_extra\\ec_derive.c " +
"third_party\\boringssl\\crypto\\ecdh_extra\\ecdh_extra.c " +
"third_party\\boringssl\\crypto\\ecdsa_extra\\ecdsa_asn1.c " +
"third_party\\boringssl\\crypto\\engine\\engine.c " +
"third_party\\boringssl\\crypto\\err\\err.c " +
@ -531,14 +532,18 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\evp\\p_ed25519_asn1.c " +
"third_party\\boringssl\\crypto\\evp\\p_rsa.c " +
"third_party\\boringssl\\crypto\\evp\\p_rsa_asn1.c " +
"third_party\\boringssl\\crypto\\evp\\p_x25519.c " +
"third_party\\boringssl\\crypto\\evp\\p_x25519_asn1.c " +
"third_party\\boringssl\\crypto\\evp\\pbkdf.c " +
"third_party\\boringssl\\crypto\\evp\\print.c " +
"third_party\\boringssl\\crypto\\evp\\scrypt.c " +
"third_party\\boringssl\\crypto\\evp\\sign.c " +
"third_party\\boringssl\\crypto\\ex_data.c " +
"third_party\\boringssl\\crypto\\fipsmodule\\bcm.c " +
"third_party\\boringssl\\crypto\\fipsmodule\\fips_shared_support.c " +
"third_party\\boringssl\\crypto\\fipsmodule\\is_fips.c " +
"third_party\\boringssl\\crypto\\hkdf\\hkdf.c " +
"third_party\\boringssl\\crypto\\hrss\\hrss.c " +
"third_party\\boringssl\\crypto\\lhash\\lhash.c " +
"third_party\\boringssl\\crypto\\mem.c " +
"third_party\\boringssl\\crypto\\obj\\obj.c " +
@ -569,6 +574,8 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\refcount_c11.c " +
"third_party\\boringssl\\crypto\\refcount_lock.c " +
"third_party\\boringssl\\crypto\\rsa_extra\\rsa_asn1.c " +
"third_party\\boringssl\\crypto\\rsa_extra\\rsa_print.c " +
"third_party\\boringssl\\crypto\\siphash\\siphash.c " +
"third_party\\boringssl\\crypto\\stack\\stack.c " +
"third_party\\boringssl\\crypto\\thread.c " +
"third_party\\boringssl\\crypto\\thread_none.c " +
@ -645,6 +652,7 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\x509v3\\v3_int.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_lib.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_ncons.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_ocsp.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_pci.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_pcia.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_pcons.c " +
@ -656,7 +664,6 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\crypto\\x509v3\\v3_sxnet.c " +
"third_party\\boringssl\\crypto\\x509v3\\v3_utl.c " +
"third_party\\boringssl\\ssl\\bio_ssl.cc " +
"third_party\\boringssl\\ssl\\custom_extensions.cc " +
"third_party\\boringssl\\ssl\\d1_both.cc " +
"third_party\\boringssl\\ssl\\d1_lib.cc " +
"third_party\\boringssl\\ssl\\d1_pkt.cc " +
@ -868,13 +875,14 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\digest_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\dsa");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\ec_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\ecdh");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\ecdh_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\ecdsa_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\engine");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\err");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\evp");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\fipsmodule");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\hkdf");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\hrss");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\lhash");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\obj");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\pem");
@ -885,6 +893,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\rand_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\rc4");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\rsa_extra");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\siphash");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\stack");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\x509");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto\\x509v3");

@ -900,9 +900,11 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/asn1/asn1_locl.h )
s.files += %w( third_party/boringssl/crypto/bio/internal.h )
s.files += %w( third_party/boringssl/crypto/bytestring/internal.h )
s.files += %w( third_party/boringssl/crypto/chacha/internal.h )
s.files += %w( third_party/boringssl/crypto/cipher_extra/internal.h )
s.files += %w( third_party/boringssl/crypto/conf/conf_def.h )
s.files += %w( third_party/boringssl/crypto/conf/internal.h )
s.files += %w( third_party/boringssl/crypto/cpu-arm-linux.h )
s.files += %w( third_party/boringssl/crypto/err/internal.h )
s.files += %w( third_party/boringssl/crypto/evp/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/aes/aes.c )
@ -916,8 +918,10 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/cmp.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/ctx.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/div.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/div_extra.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/gcd.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/generic.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bn/jacobi.c )
@ -945,21 +949,25 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/ec.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/ec_key.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/felem.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/oct.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/p224-64.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/scalar.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/simple.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/util.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ec/wnaf.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/hmac/hmac.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/md4/md4.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/md5/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/md5/md5.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/modes/cbc.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/modes/ccm.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/modes/cfb.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/modes/ctr.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/modes/gcm.c )
@ -976,12 +984,14 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/fipsmodule/rsa/rsa.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/self_check/self_check.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/sha/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/sha/sha1-altivec.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/sha/sha1.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/sha/sha256.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/sha/sha512.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/tls/internal.h )
s.files += %w( third_party/boringssl/crypto/fipsmodule/tls/kdf.c )
s.files += %w( third_party/boringssl/crypto/hrss/internal.h )
s.files += %w( third_party/boringssl/crypto/internal.h )
s.files += %w( third_party/boringssl/crypto/obj/obj_dat.h )
s.files += %w( third_party/boringssl/crypto/pkcs7/internal.h )
@ -992,6 +1002,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/x509/internal.h )
s.files += %w( third_party/boringssl/crypto/x509/vpm_int.h )
s.files += %w( third_party/boringssl/crypto/x509v3/ext_dat.h )
s.files += %w( third_party/boringssl/crypto/x509v3/internal.h )
s.files += %w( third_party/boringssl/crypto/x509v3/pcy_int.h )
s.files += %w( third_party/boringssl/include/openssl/aead.h )
s.files += %w( third_party/boringssl/include/openssl/aes.h )
@ -1020,6 +1031,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/include/openssl/digest.h )
s.files += %w( third_party/boringssl/include/openssl/dsa.h )
s.files += %w( third_party/boringssl/include/openssl/dtls1.h )
s.files += %w( third_party/boringssl/include/openssl/e_os2.h )
s.files += %w( third_party/boringssl/include/openssl/ec.h )
s.files += %w( third_party/boringssl/include/openssl/ec_key.h )
s.files += %w( third_party/boringssl/include/openssl/ecdh.h )
@ -1030,9 +1042,9 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/include/openssl/ex_data.h )
s.files += %w( third_party/boringssl/include/openssl/hkdf.h )
s.files += %w( third_party/boringssl/include/openssl/hmac.h )
s.files += %w( third_party/boringssl/include/openssl/hrss.h )
s.files += %w( third_party/boringssl/include/openssl/is_boringssl.h )
s.files += %w( third_party/boringssl/include/openssl/lhash.h )
s.files += %w( third_party/boringssl/include/openssl/lhash_macros.h )
s.files += %w( third_party/boringssl/include/openssl/md4.h )
s.files += %w( third_party/boringssl/include/openssl/md5.h )
s.files += %w( third_party/boringssl/include/openssl/mem.h )
@ -1055,6 +1067,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/include/openssl/rsa.h )
s.files += %w( third_party/boringssl/include/openssl/safestack.h )
s.files += %w( third_party/boringssl/include/openssl/sha.h )
s.files += %w( third_party/boringssl/include/openssl/siphash.h )
s.files += %w( third_party/boringssl/include/openssl/span.h )
s.files += %w( third_party/boringssl/include/openssl/srtp.h )
s.files += %w( third_party/boringssl/include/openssl/ssl.h )
@ -1067,9 +1080,13 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/include/openssl/x509_vfy.h )
s.files += %w( third_party/boringssl/include/openssl/x509v3.h )
s.files += %w( third_party/boringssl/ssl/internal.h )
s.files += %w( third_party/boringssl/third_party/fiat/curve25519_32.h )
s.files += %w( third_party/boringssl/third_party/fiat/curve25519_64.h )
s.files += %w( third_party/boringssl/third_party/fiat/curve25519_tables.h )
s.files += %w( third_party/boringssl/third_party/fiat/internal.h )
s.files += %w( third_party/boringssl/third_party/fiat/p256.c )
s.files += %w( third_party/boringssl/third_party/fiat/p256_32.h )
s.files += %w( third_party/boringssl/third_party/fiat/p256_64.h )
s.files += %w( src/boringssl/err_data.c )
s.files += %w( third_party/boringssl/crypto/asn1/a_bitstr.c )
s.files += %w( third_party/boringssl/crypto/asn1/a_bool.c )
@ -1119,6 +1136,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/bytestring/ber.c )
s.files += %w( third_party/boringssl/crypto/bytestring/cbb.c )
s.files += %w( third_party/boringssl/crypto/bytestring/cbs.c )
s.files += %w( third_party/boringssl/crypto/bytestring/unicode.c )
s.files += %w( third_party/boringssl/crypto/chacha/chacha.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/cipher_extra.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/derive_key.c )
@ -1129,7 +1147,6 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/cipher_extra/e_null.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/e_rc2.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/e_rc4.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/e_ssl3.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/e_tls.c )
s.files += %w( third_party/boringssl/crypto/cipher_extra/tls_cbc.c )
s.files += %w( third_party/boringssl/crypto/cmac/cmac.c )
@ -1150,7 +1167,8 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/dsa/dsa.c )
s.files += %w( third_party/boringssl/crypto/dsa/dsa_asn1.c )
s.files += %w( third_party/boringssl/crypto/ec_extra/ec_asn1.c )
s.files += %w( third_party/boringssl/crypto/ecdh/ecdh.c )
s.files += %w( third_party/boringssl/crypto/ec_extra/ec_derive.c )
s.files += %w( third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c )
s.files += %w( third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c )
s.files += %w( third_party/boringssl/crypto/engine/engine.c )
s.files += %w( third_party/boringssl/crypto/err/err.c )
@ -1165,14 +1183,18 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/evp/p_ed25519_asn1.c )
s.files += %w( third_party/boringssl/crypto/evp/p_rsa.c )
s.files += %w( third_party/boringssl/crypto/evp/p_rsa_asn1.c )
s.files += %w( third_party/boringssl/crypto/evp/p_x25519.c )
s.files += %w( third_party/boringssl/crypto/evp/p_x25519_asn1.c )
s.files += %w( third_party/boringssl/crypto/evp/pbkdf.c )
s.files += %w( third_party/boringssl/crypto/evp/print.c )
s.files += %w( third_party/boringssl/crypto/evp/scrypt.c )
s.files += %w( third_party/boringssl/crypto/evp/sign.c )
s.files += %w( third_party/boringssl/crypto/ex_data.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/bcm.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/fips_shared_support.c )
s.files += %w( third_party/boringssl/crypto/fipsmodule/is_fips.c )
s.files += %w( third_party/boringssl/crypto/hkdf/hkdf.c )
s.files += %w( third_party/boringssl/crypto/hrss/hrss.c )
s.files += %w( third_party/boringssl/crypto/lhash/lhash.c )
s.files += %w( third_party/boringssl/crypto/mem.c )
s.files += %w( third_party/boringssl/crypto/obj/obj.c )
@ -1203,6 +1225,8 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/refcount_c11.c )
s.files += %w( third_party/boringssl/crypto/refcount_lock.c )
s.files += %w( third_party/boringssl/crypto/rsa_extra/rsa_asn1.c )
s.files += %w( third_party/boringssl/crypto/rsa_extra/rsa_print.c )
s.files += %w( third_party/boringssl/crypto/siphash/siphash.c )
s.files += %w( third_party/boringssl/crypto/stack/stack.c )
s.files += %w( third_party/boringssl/crypto/thread.c )
s.files += %w( third_party/boringssl/crypto/thread_none.c )
@ -1279,6 +1303,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/x509v3/v3_int.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_lib.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_ncons.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_ocsp.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_pci.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_pcia.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_pcons.c )
@ -1290,7 +1315,6 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/crypto/x509v3/v3_sxnet.c )
s.files += %w( third_party/boringssl/crypto/x509v3/v3_utl.c )
s.files += %w( third_party/boringssl/ssl/bio_ssl.cc )
s.files += %w( third_party/boringssl/ssl/custom_extensions.cc )
s.files += %w( third_party/boringssl/ssl/d1_both.cc )
s.files += %w( third_party/boringssl/ssl/d1_lib.cc )
s.files += %w( third_party/boringssl/ssl/d1_pkt.cc )

@ -1987,6 +1987,7 @@
'third_party/boringssl/crypto/bytestring/ber.c',
'third_party/boringssl/crypto/bytestring/cbb.c',
'third_party/boringssl/crypto/bytestring/cbs.c',
'third_party/boringssl/crypto/bytestring/unicode.c',
'third_party/boringssl/crypto/chacha/chacha.c',
'third_party/boringssl/crypto/cipher_extra/cipher_extra.c',
'third_party/boringssl/crypto/cipher_extra/derive_key.c',
@ -1997,7 +1998,6 @@
'third_party/boringssl/crypto/cipher_extra/e_null.c',
'third_party/boringssl/crypto/cipher_extra/e_rc2.c',
'third_party/boringssl/crypto/cipher_extra/e_rc4.c',
'third_party/boringssl/crypto/cipher_extra/e_ssl3.c',
'third_party/boringssl/crypto/cipher_extra/e_tls.c',
'third_party/boringssl/crypto/cipher_extra/tls_cbc.c',
'third_party/boringssl/crypto/cmac/cmac.c',
@ -2018,7 +2018,8 @@
'third_party/boringssl/crypto/dsa/dsa.c',
'third_party/boringssl/crypto/dsa/dsa_asn1.c',
'third_party/boringssl/crypto/ec_extra/ec_asn1.c',
'third_party/boringssl/crypto/ecdh/ecdh.c',
'third_party/boringssl/crypto/ec_extra/ec_derive.c',
'third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c',
'third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c',
'third_party/boringssl/crypto/engine/engine.c',
'third_party/boringssl/crypto/err/err.c',
@ -2033,14 +2034,18 @@
'third_party/boringssl/crypto/evp/p_ed25519_asn1.c',
'third_party/boringssl/crypto/evp/p_rsa.c',
'third_party/boringssl/crypto/evp/p_rsa_asn1.c',
'third_party/boringssl/crypto/evp/p_x25519.c',
'third_party/boringssl/crypto/evp/p_x25519_asn1.c',
'third_party/boringssl/crypto/evp/pbkdf.c',
'third_party/boringssl/crypto/evp/print.c',
'third_party/boringssl/crypto/evp/scrypt.c',
'third_party/boringssl/crypto/evp/sign.c',
'third_party/boringssl/crypto/ex_data.c',
'third_party/boringssl/crypto/fipsmodule/bcm.c',
'third_party/boringssl/crypto/fipsmodule/fips_shared_support.c',
'third_party/boringssl/crypto/fipsmodule/is_fips.c',
'third_party/boringssl/crypto/hkdf/hkdf.c',
'third_party/boringssl/crypto/hrss/hrss.c',
'third_party/boringssl/crypto/lhash/lhash.c',
'third_party/boringssl/crypto/mem.c',
'third_party/boringssl/crypto/obj/obj.c',
@ -2071,6 +2076,8 @@
'third_party/boringssl/crypto/refcount_c11.c',
'third_party/boringssl/crypto/refcount_lock.c',
'third_party/boringssl/crypto/rsa_extra/rsa_asn1.c',
'third_party/boringssl/crypto/rsa_extra/rsa_print.c',
'third_party/boringssl/crypto/siphash/siphash.c',
'third_party/boringssl/crypto/stack/stack.c',
'third_party/boringssl/crypto/thread.c',
'third_party/boringssl/crypto/thread_none.c',
@ -2147,6 +2154,7 @@
'third_party/boringssl/crypto/x509v3/v3_int.c',
'third_party/boringssl/crypto/x509v3/v3_lib.c',
'third_party/boringssl/crypto/x509v3/v3_ncons.c',
'third_party/boringssl/crypto/x509v3/v3_ocsp.c',
'third_party/boringssl/crypto/x509v3/v3_pci.c',
'third_party/boringssl/crypto/x509v3/v3_pcia.c',
'third_party/boringssl/crypto/x509v3/v3_pcons.c',
@ -2158,7 +2166,6 @@
'third_party/boringssl/crypto/x509v3/v3_sxnet.c',
'third_party/boringssl/crypto/x509v3/v3_utl.c',
'third_party/boringssl/ssl/bio_ssl.cc',
'third_party/boringssl/ssl/custom_extensions.cc',
'third_party/boringssl/ssl/d1_both.cc',
'third_party/boringssl/ssl/d1_lib.cc',
'third_party/boringssl/ssl/d1_pkt.cc',
@ -2206,6 +2213,7 @@
'third_party/boringssl/crypto/test/file_test.cc',
'third_party/boringssl/crypto/test/malloc.cc',
'third_party/boringssl/crypto/test/test_util.cc',
'third_party/boringssl/crypto/test/wycheproof_util.cc',
],
},
{

@ -942,8 +942,8 @@ class CallOpSet : public CallOpSetInterface,
// A failure here indicates an API misuse; for example, doing a Write
// while another Write is already pending on the same RPC or invoking
// WritesDone multiple times
gpr_log(GPR_ERROR, "API misuse of type %s observed",
g_core_codegen_interface->grpc_call_error_to_string(err));
// gpr_log(GPR_ERROR, "API misuse of type %s observed",
// g_core_codegen_interface->grpc_call_error_to_string(err));
GPR_CODEGEN_ASSERT(false);
}
}

@ -316,6 +316,13 @@ class ClientContext {
void set_credentials(
const std::shared_ptr<grpc_impl::CallCredentials>& creds);
/// EXPERIMENTAL debugging API
///
/// Returns the credentials for the client call. This should be used only in
/// tests and for diagnostic purposes, and should not be used by application
/// logic.
std::shared_ptr<grpc_impl::CallCredentials> credentials() { return creds_; }
/// Return the compression algorithm the client call will request be used.
/// Note that the gRPC runtime may decide to ignore this request, for example,
/// due to resource constraints.

@ -905,9 +905,11 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/asn1/asn1_locl.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bio/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bytestring/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/chacha/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/conf/conf_def.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/conf/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cpu-arm-linux.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/err/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/aes/aes.c" role="src" />
@ -921,8 +923,10 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/cmp.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/ctx.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/div.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/div_extra.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/gcd.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/generic.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bn/jacobi.c" role="src" />
@ -950,21 +954,25 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/ec.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/ec_key.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/felem.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/oct.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/p224-64.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/scalar.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/simple.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/util.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ec/wnaf.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/hmac/hmac.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/md4/md4.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/md5/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/md5/md5.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/modes/cbc.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/modes/ccm.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/modes/cfb.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/modes/ctr.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/modes/gcm.c" role="src" />
@ -981,12 +989,14 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/rsa/rsa.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/self_check/self_check.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/sha/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/sha/sha1-altivec.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/sha/sha1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/sha/sha256.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/sha/sha512.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/tls/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/tls/kdf.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/hrss/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/obj/obj_dat.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/pkcs7/internal.h" role="src" />
@ -997,6 +1007,7 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509/vpm_int.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/ext_dat.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/pcy_int.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/aead.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/aes.h" role="src" />
@ -1025,6 +1036,7 @@
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/digest.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/dsa.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/dtls1.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/e_os2.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/ec.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/ec_key.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/ecdh.h" role="src" />
@ -1035,9 +1047,9 @@
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/ex_data.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/hkdf.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/hmac.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/hrss.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/is_boringssl.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/lhash.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/lhash_macros.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/md4.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/md5.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/mem.h" role="src" />
@ -1060,6 +1072,7 @@
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/rsa.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/safestack.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/sha.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/siphash.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/span.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/srtp.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/ssl.h" role="src" />
@ -1072,9 +1085,13 @@
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/x509_vfy.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/include/openssl/x509v3.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/curve25519_32.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/curve25519_64.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/curve25519_tables.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/internal.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/p256.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/p256_32.h" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/p256_64.h" role="src" />
<file baseinstalldir="/" name="src/boringssl/err_data.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/asn1/a_bitstr.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/asn1/a_bool.c" role="src" />
@ -1124,6 +1141,7 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/bytestring/ber.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bytestring/cbb.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bytestring/cbs.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/bytestring/unicode.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/chacha/chacha.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/cipher_extra.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/derive_key.c" role="src" />
@ -1134,7 +1152,6 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/e_null.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/e_rc2.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/e_rc4.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/e_ssl3.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/e_tls.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cipher_extra/tls_cbc.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/cmac/cmac.c" role="src" />
@ -1155,7 +1172,8 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/dsa/dsa.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/dsa/dsa_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ec_extra/ec_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ecdh/ecdh.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ec_extra/ec_derive.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/engine/engine.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/err/err.c" role="src" />
@ -1170,14 +1188,18 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/p_ed25519_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/p_rsa.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/p_rsa_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/p_x25519.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/p_x25519_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/pbkdf.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/print.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/scrypt.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/evp/sign.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/ex_data.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/bcm.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/fips_shared_support.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/fipsmodule/is_fips.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/hkdf/hkdf.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/hrss/hrss.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/lhash/lhash.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/mem.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/obj/obj.c" role="src" />
@ -1208,6 +1230,8 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/refcount_c11.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/refcount_lock.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/rsa_extra/rsa_asn1.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/rsa_extra/rsa_print.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/siphash/siphash.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/stack/stack.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/thread.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/thread_none.c" role="src" />
@ -1284,6 +1308,7 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_int.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_lib.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_ncons.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_ocsp.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_pci.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_pcia.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_pcons.c" role="src" />
@ -1295,7 +1320,6 @@
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_sxnet.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/crypto/x509v3/v3_utl.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/bio_ssl.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/custom_extensions.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/d1_both.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/d1_lib.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/d1_pkt.cc" role="src" />

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -282,7 +282,7 @@ class ChannelData {
//
// Fields used in the control plane. Guarded by combiner.
//
grpc_combiner* combiner_;
Combiner* combiner_;
grpc_pollset_set* interested_parties_;
RefCountedPtr<SubchannelPoolInterface> subchannel_pool_;
OrphanablePtr<ResolvingLoadBalancingPolicy> resolving_lb_policy_;
@ -1044,10 +1044,10 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
: parent_(std::move(parent)),
state_(new_state),
connected_subchannel_(std::move(connected_subchannel)) {
GRPC_CLOSURE_INIT(
&closure_, ApplyUpdateInControlPlaneCombiner, this,
grpc_combiner_scheduler(parent_->parent_->chand_->combiner_));
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
parent_->parent_->chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&closure_, ApplyUpdateInControlPlaneCombiner,
this, nullptr),
GRPC_ERROR_NONE);
}
private:
@ -1140,9 +1140,8 @@ ChannelData::ExternalConnectivityWatcher::ExternalConnectivityWatcher(
grpc_polling_entity_add_to_pollset_set(&pollent_,
chand_->interested_parties_);
GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ExternalConnectivityWatcher");
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&add_closure_, AddWatcherLocked, this,
grpc_combiner_scheduler(chand_->combiner_)),
chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&add_closure_, AddWatcherLocked, this, nullptr),
GRPC_ERROR_NONE);
}
@ -1169,9 +1168,8 @@ void ChannelData::ExternalConnectivityWatcher::Notify(
// Not needed in state SHUTDOWN, because the tracker will
// automatically remove all watchers in that case.
if (state != GRPC_CHANNEL_SHUTDOWN) {
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this,
grpc_combiner_scheduler(chand_->combiner_)),
chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this, nullptr),
GRPC_ERROR_NONE);
}
}
@ -1184,9 +1182,8 @@ void ChannelData::ExternalConnectivityWatcher::Cancel() {
}
GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_CANCELLED);
// Hop back into the combiner to clean up.
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this,
grpc_combiner_scheduler(chand_->combiner_)),
chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this, nullptr),
GRPC_ERROR_NONE);
}
@ -1223,9 +1220,11 @@ class ChannelData::ConnectivityWatcherAdder {
initial_state_(initial_state),
watcher_(std::move(watcher)) {
GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ConnectivityWatcherAdder");
GRPC_CLOSURE_INIT(&closure_, &ConnectivityWatcherAdder::AddWatcherLocked,
this, grpc_combiner_scheduler(chand_->combiner_));
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&closure_,
&ConnectivityWatcherAdder::AddWatcherLocked, this,
nullptr),
GRPC_ERROR_NONE);
}
private:
@ -1255,10 +1254,11 @@ class ChannelData::ConnectivityWatcherRemover {
AsyncConnectivityStateWatcherInterface* watcher)
: chand_(chand), watcher_(watcher) {
GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ConnectivityWatcherRemover");
GRPC_CLOSURE_INIT(&closure_,
&ConnectivityWatcherRemover::RemoveWatcherLocked, this,
grpc_combiner_scheduler(chand_->combiner_));
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&closure_,
&ConnectivityWatcherRemover::RemoveWatcherLocked,
this, nullptr),
GRPC_ERROR_NONE);
}
private:
@ -1883,10 +1883,9 @@ void ChannelData::StartTransportOp(grpc_channel_element* elem,
// Pop into control plane combiner for remaining ops.
op->handler_private.extra_arg = elem;
GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "start_transport_op");
GRPC_CLOSURE_SCHED(
chand->combiner_->Run(
GRPC_CLOSURE_INIT(&op->handler_private.closure,
ChannelData::StartTransportOpLocked, op,
grpc_combiner_scheduler(chand->combiner_)),
ChannelData::StartTransportOpLocked, op, nullptr),
GRPC_ERROR_NONE);
}
@ -1953,9 +1952,8 @@ grpc_connectivity_state ChannelData::CheckConnectivityState(
grpc_connectivity_state out = state_tracker_.state();
if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
GRPC_CHANNEL_STACK_REF(owning_stack_, "TryToConnect");
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(TryToConnectLocked, this,
grpc_combiner_scheduler(combiner_)),
GRPC_ERROR_NONE);
combiner_->Run(GRPC_CLOSURE_CREATE(TryToConnectLocked, this, nullptr),
GRPC_ERROR_NONE);
}
return out;
}

@ -105,9 +105,8 @@ LoadBalancingPolicy::PickResult LoadBalancingPolicy::QueuePicker::Pick(
if (!exit_idle_called_) {
exit_idle_called_ = true;
parent_->Ref().release(); // ref held by closure.
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(&CallExitIdle, parent_.get(),
grpc_combiner_scheduler(parent_->combiner())),
parent_->combiner()->Run(
GRPC_CLOSURE_CREATE(&CallExitIdle, parent_.get(), nullptr),
GRPC_ERROR_NONE);
}
PickResult result;

@ -313,7 +313,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
// TODO(roth): Once we have a C++-like interface for combiners, this
// API should change to take a smart pointer that does pass ownership
// of a reference.
grpc_combiner* combiner = nullptr;
Combiner* combiner = nullptr;
/// Channel control helper.
/// Note: LB policies MUST NOT call any method on the helper from
/// their constructor.
@ -383,7 +383,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
};
protected:
grpc_combiner* combiner() const { return combiner_; }
Combiner* combiner() const { return combiner_; }
// Note: LB policies MUST NOT call any method on the helper from their
// constructor.
@ -396,7 +396,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
private:
/// Combiner under which LB policy actions take place.
grpc_combiner* combiner_;
Combiner* combiner_;
/// Owned pointer to interested parties in load balancing decisions.
grpc_pollset_set* interested_parties_;
/// Channel control helper.

@ -174,6 +174,12 @@ class GrpcLb : public LoadBalancingPolicy {
static bool LoadReportCountersAreZero(grpc_grpclb_request* request);
static void MaybeSendClientLoadReport(void* arg, grpc_error* error);
static void ClientLoadReportDone(void* arg, grpc_error* error);
static void OnInitialRequestSent(void* arg, grpc_error* error);
static void OnBalancerMessageReceived(void* arg, grpc_error* error);
static void OnBalancerStatusReceived(void* arg, grpc_error* error);
static void MaybeSendClientLoadReportLocked(void* arg, grpc_error* error);
static void ClientLoadReportDoneLocked(void* arg, grpc_error* error);
static void OnInitialRequestSentLocked(void* arg, grpc_error* error);
@ -312,17 +318,21 @@ class GrpcLb : public LoadBalancingPolicy {
// Helper functions used in UpdateLocked().
void ProcessAddressesAndChannelArgsLocked(const ServerAddressList& addresses,
const grpc_channel_args& args);
static void OnBalancerChannelConnectivityChanged(void* arg,
grpc_error* error);
static void OnBalancerChannelConnectivityChangedLocked(void* arg,
grpc_error* error);
void CancelBalancerChannelConnectivityWatchLocked();
// Methods for dealing with fallback state.
void MaybeEnterFallbackModeAfterStartup();
static void OnFallbackTimer(void* arg, grpc_error* error);
static void OnFallbackTimerLocked(void* arg, grpc_error* error);
// Methods for dealing with the balancer call.
void StartBalancerCallLocked();
void StartBalancerCallRetryTimerLocked();
static void OnBalancerCallRetryTimer(void* arg, grpc_error* error);
static void OnBalancerCallRetryTimerLocked(void* arg, grpc_error* error);
// Methods for dealing with the child policy.
@ -783,14 +793,6 @@ GrpcLb::BalancerCallState::BalancerCallState(
// Init other data associated with the LB call.
grpc_metadata_array_init(&lb_initial_metadata_recv_);
grpc_metadata_array_init(&lb_trailing_metadata_recv_);
GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSentLocked,
this, grpc_combiner_scheduler(grpclb_policy()->combiner()));
GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_,
OnBalancerMessageReceivedLocked, this,
grpc_combiner_scheduler(grpclb_policy()->combiner()));
GRPC_CLOSURE_INIT(&lb_on_balancer_status_received_,
OnBalancerStatusReceivedLocked, this,
grpc_combiner_scheduler(grpclb_policy()->combiner()));
}
GrpcLb::BalancerCallState::~BalancerCallState() {
@ -848,6 +850,8 @@ void GrpcLb::BalancerCallState::StartQuery() {
// with the callback.
auto self = Ref(DEBUG_LOCATION, "on_initial_request_sent");
self.release();
GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSent, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(
lb_call_, ops, (size_t)(op - ops), &lb_on_initial_request_sent_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -870,6 +874,8 @@ void GrpcLb::BalancerCallState::StartQuery() {
// with the callback.
self = Ref(DEBUG_LOCATION, "on_message_received");
self.release();
GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_,
OnBalancerMessageReceived, this, grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(
lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_message_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -886,6 +892,8 @@ void GrpcLb::BalancerCallState::StartQuery() {
// This callback signals the end of the LB call, so it relies on the initial
// ref instead of a new ref. When it's invoked, it's the initial ref that is
// unreffed.
GRPC_CLOSURE_INIT(&lb_on_balancer_status_received_, OnBalancerStatusReceived,
this, grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(
lb_call_, ops, (size_t)(op - ops), &lb_on_balancer_status_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -894,14 +902,22 @@ void GrpcLb::BalancerCallState::StartQuery() {
void GrpcLb::BalancerCallState::ScheduleNextClientLoadReportLocked() {
const grpc_millis next_client_load_report_time =
ExecCtx::Get()->Now() + client_stats_report_interval_;
GRPC_CLOSURE_INIT(&client_load_report_closure_,
MaybeSendClientLoadReportLocked, this,
grpc_combiner_scheduler(grpclb_policy()->combiner()));
GRPC_CLOSURE_INIT(&client_load_report_closure_, MaybeSendClientLoadReport,
this, grpc_schedule_on_exec_ctx);
grpc_timer_init(&client_load_report_timer_, next_client_load_report_time,
&client_load_report_closure_);
client_load_report_timer_callback_pending_ = true;
}
void GrpcLb::BalancerCallState::MaybeSendClientLoadReport(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
lb_calld->grpclb_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&lb_calld->client_load_report_closure_,
MaybeSendClientLoadReportLocked, lb_calld, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked(
void* arg, grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
@ -966,8 +982,8 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
memset(&op, 0, sizeof(op));
op.op = GRPC_OP_SEND_MESSAGE;
op.data.send_message.send_message = send_message_payload_;
GRPC_CLOSURE_INIT(&client_load_report_closure_, ClientLoadReportDoneLocked,
this, grpc_combiner_scheduler(grpclb_policy()->combiner()));
GRPC_CLOSURE_INIT(&client_load_report_closure_, ClientLoadReportDone, this,
grpc_schedule_on_exec_ctx);
grpc_call_error call_error = grpc_call_start_batch_and_execute(
lb_call_, &op, 1, &client_load_report_closure_);
if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
@ -978,6 +994,15 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
}
}
void GrpcLb::BalancerCallState::ClientLoadReportDone(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
lb_calld->grpclb_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&lb_calld->client_load_report_closure_,
ClientLoadReportDoneLocked, lb_calld, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::BalancerCallState::ClientLoadReportDoneLocked(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
@ -991,6 +1016,15 @@ void GrpcLb::BalancerCallState::ClientLoadReportDoneLocked(void* arg,
lb_calld->ScheduleNextClientLoadReportLocked();
}
void GrpcLb::BalancerCallState::OnInitialRequestSent(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
lb_calld->grpclb_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&lb_calld->lb_on_initial_request_sent_,
OnInitialRequestSentLocked, lb_calld, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::BalancerCallState::OnInitialRequestSentLocked(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
@ -1006,6 +1040,15 @@ void GrpcLb::BalancerCallState::OnInitialRequestSentLocked(void* arg,
lb_calld->Unref(DEBUG_LOCATION, "on_initial_request_sent");
}
void GrpcLb::BalancerCallState::OnBalancerMessageReceived(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
lb_calld->grpclb_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&lb_calld->lb_on_balancer_message_received_,
OnBalancerMessageReceivedLocked, lb_calld, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
void* arg, grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
@ -1141,6 +1184,9 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
op.flags = 0;
op.reserved = nullptr;
// Reuse the "OnBalancerMessageReceivedLocked" ref taken in StartQuery().
GRPC_CLOSURE_INIT(&lb_calld->lb_on_balancer_message_received_,
GrpcLb::BalancerCallState::OnBalancerMessageReceived,
lb_calld, grpc_schedule_on_exec_ctx);
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
lb_calld->lb_call_, &op, 1,
&lb_calld->lb_on_balancer_message_received_);
@ -1150,6 +1196,15 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
}
}
void GrpcLb::BalancerCallState::OnBalancerStatusReceived(void* arg,
grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
lb_calld->grpclb_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&lb_calld->lb_on_balancer_status_received_,
OnBalancerStatusReceivedLocked, lb_calld, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::BalancerCallState::OnBalancerStatusReceivedLocked(
void* arg, grpc_error* error) {
BalancerCallState* lb_calld = static_cast<BalancerCallState*>(arg);
@ -1312,12 +1367,6 @@ GrpcLb::GrpcLb(Args args)
.set_jitter(GRPC_GRPCLB_RECONNECT_JITTER)
.set_max_backoff(GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS *
1000)) {
// Initialization.
GRPC_CLOSURE_INIT(&lb_on_fallback_, &GrpcLb::OnFallbackTimerLocked, this,
grpc_combiner_scheduler(combiner()));
GRPC_CLOSURE_INIT(&lb_channel_on_connectivity_changed_,
&GrpcLb::OnBalancerChannelConnectivityChangedLocked, this,
grpc_combiner_scheduler(args.combiner));
// Record server name.
const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI);
const char* server_uri = grpc_channel_arg_get_string(arg);
@ -1410,6 +1459,8 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
// Start timer.
grpc_millis deadline = ExecCtx::Get()->Now() + fallback_at_startup_timeout_;
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Ref for callback
GRPC_CLOSURE_INIT(&lb_on_fallback_, &GrpcLb::OnFallbackTimer, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
// Start watching the channel's connectivity state. If the channel
// goes into state TRANSIENT_FAILURE before the timer fires, we go into
@ -1419,6 +1470,9 @@ void GrpcLb::UpdateLocked(UpdateArgs args) {
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
// Ref held by callback.
Ref(DEBUG_LOCATION, "watch_lb_channel_connectivity").release();
GRPC_CLOSURE_INIT(&lb_channel_on_connectivity_changed_,
&GrpcLb::OnBalancerChannelConnectivityChanged, this,
grpc_schedule_on_exec_ctx);
grpc_client_channel_watch_connectivity_state(
client_channel_elem,
grpc_polling_entity_create_from_pollset_set(interested_parties()),
@ -1482,6 +1536,16 @@ void GrpcLb::ProcessAddressesAndChannelArgsLocked(
response_generator_->SetResponse(std::move(result));
}
void GrpcLb::OnBalancerChannelConnectivityChanged(void* arg,
grpc_error* error) {
GrpcLb* self = static_cast<GrpcLb*>(arg);
self->combiner()->Run(
GRPC_CLOSURE_INIT(&self->lb_channel_on_connectivity_changed_,
&GrpcLb::OnBalancerChannelConnectivityChangedLocked,
self, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::OnBalancerChannelConnectivityChangedLocked(void* arg,
grpc_error* error) {
GrpcLb* self = static_cast<GrpcLb*>(arg);
@ -1492,6 +1556,9 @@ void GrpcLb::OnBalancerChannelConnectivityChangedLocked(void* arg,
grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(self->lb_channel_));
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
GRPC_CLOSURE_INIT(&self->lb_channel_on_connectivity_changed_,
&GrpcLb::OnBalancerChannelConnectivityChanged, self,
grpc_schedule_on_exec_ctx);
grpc_client_channel_watch_connectivity_state(
client_channel_elem,
grpc_polling_entity_create_from_pollset_set(
@ -1561,12 +1628,21 @@ void GrpcLb::StartBalancerCallRetryTimerLocked() {
// with the callback.
auto self = Ref(DEBUG_LOCATION, "on_balancer_call_retry_timer");
self.release();
GRPC_CLOSURE_INIT(&lb_on_call_retry_, &GrpcLb::OnBalancerCallRetryTimerLocked,
this, grpc_combiner_scheduler(combiner()));
GRPC_CLOSURE_INIT(&lb_on_call_retry_, &GrpcLb::OnBalancerCallRetryTimer, this,
grpc_schedule_on_exec_ctx);
retry_timer_callback_pending_ = true;
grpc_timer_init(&lb_call_retry_timer_, next_try, &lb_on_call_retry_);
}
void GrpcLb::OnBalancerCallRetryTimer(void* arg, grpc_error* error) {
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
grpclb_policy->combiner()->Run(
GRPC_CLOSURE_INIT(&grpclb_policy->lb_on_call_retry_,
&GrpcLb::OnBalancerCallRetryTimerLocked, grpclb_policy,
nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::OnBalancerCallRetryTimerLocked(void* arg, grpc_error* error) {
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
grpclb_policy->retry_timer_callback_pending_ = false;
@ -1603,6 +1679,14 @@ void GrpcLb::MaybeEnterFallbackModeAfterStartup() {
}
}
void GrpcLb::OnFallbackTimer(void* arg, grpc_error* error) {
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
grpclb_policy->combiner()->Run(
GRPC_CLOSURE_INIT(&grpclb_policy->lb_on_fallback_,
&GrpcLb::OnFallbackTimerLocked, grpclb_policy, nullptr),
GRPC_ERROR_REF(error));
}
void GrpcLb::OnFallbackTimerLocked(void* arg, grpc_error* error) {
GrpcLb* grpclb_policy = static_cast<GrpcLb*>(arg);
// If we receive a serverlist after the timer fires but before this callback

@ -77,9 +77,14 @@ constexpr char kXds[] = "xds_experimental";
class ParsedXdsConfig : public LoadBalancingPolicy::Config {
public:
ParsedXdsConfig(RefCountedPtr<LoadBalancingPolicy::Config> child_policy,
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy)
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy,
UniquePtr<char> eds_service_name,
UniquePtr<char> lrs_load_reporting_server_name)
: child_policy_(std::move(child_policy)),
fallback_policy_(std::move(fallback_policy)) {}
fallback_policy_(std::move(fallback_policy)),
eds_service_name_(std::move(eds_service_name)),
lrs_load_reporting_server_name_(
std::move(lrs_load_reporting_server_name)) {}
const char* name() const override { return kXds; }
@ -91,9 +96,17 @@ class ParsedXdsConfig : public LoadBalancingPolicy::Config {
return fallback_policy_;
}
const char* eds_service_name() const { return eds_service_name_.get(); };
const char* lrs_load_reporting_server_name() const {
return lrs_load_reporting_server_name_.get();
};
private:
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_;
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_;
UniquePtr<char> eds_service_name_;
UniquePtr<char> lrs_load_reporting_server_name_;
};
class XdsLb : public LoadBalancingPolicy {
@ -111,16 +124,17 @@ class XdsLb : public LoadBalancingPolicy {
// We need this wrapper for the following reasons:
// 1. To process per-locality load reporting.
// 2. Since pickers are UniquePtrs we use this RefCounted wrapper to control
// references to it by the xds picker and the locality.
class PickerWrapper : public RefCounted<PickerWrapper> {
// references to it by the xds picker and the locality.
class EndpointPickerWrapper : public RefCounted<EndpointPickerWrapper> {
public:
PickerWrapper(UniquePtr<SubchannelPicker> picker,
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats)
EndpointPickerWrapper(
UniquePtr<SubchannelPicker> picker,
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats)
: picker_(std::move(picker)),
locality_stats_(std::move(locality_stats)) {
locality_stats_->RefByPicker();
}
~PickerWrapper() { locality_stats_->UnrefByPicker(); }
~EndpointPickerWrapper() { locality_stats_->UnrefByPicker(); }
PickResult Pick(PickArgs args);
@ -131,15 +145,16 @@ class XdsLb : public LoadBalancingPolicy {
// The picker will use a stateless weighting algorithm to pick the locality to
// use for each request.
class Picker : public SubchannelPicker {
class LocalityPicker : public SubchannelPicker {
public:
// Maintains a weighted list of pickers from each locality that is in ready
// state. The first element in the pair represents the end of a range
// proportional to the locality's weight. The start of the range is the
// previous value in the vector and is 0 for the first element.
using PickerList =
InlinedVector<std::pair<uint32_t, RefCountedPtr<PickerWrapper>>, 1>;
Picker(RefCountedPtr<XdsLb> xds_policy, PickerList pickers)
InlinedVector<std::pair<uint32_t, RefCountedPtr<EndpointPickerWrapper>>,
1>;
LocalityPicker(RefCountedPtr<XdsLb> xds_policy, PickerList pickers)
: xds_policy_(std::move(xds_policy)),
pickers_(std::move(pickers)),
drop_config_(xds_policy_->drop_config_) {}
@ -204,7 +219,7 @@ class XdsLb : public LoadBalancingPolicy {
return connectivity_state_;
}
uint32_t weight() const { return weight_; }
RefCountedPtr<PickerWrapper> picker_wrapper() const {
RefCountedPtr<EndpointPickerWrapper> picker_wrapper() const {
return picker_wrapper_;
}
@ -245,6 +260,7 @@ class XdsLb : public LoadBalancingPolicy {
grpc_channel_args* CreateChildPolicyArgsLocked(
const grpc_channel_args* args);
static void OnDelayedRemovalTimer(void* arg, grpc_error* error);
static void OnDelayedRemovalTimerLocked(void* arg, grpc_error* error);
XdsLb* xds_policy() const { return locality_map_->xds_policy(); }
@ -255,7 +271,7 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<XdsLocalityName> name_;
OrphanablePtr<LoadBalancingPolicy> child_policy_;
OrphanablePtr<LoadBalancingPolicy> pending_child_policy_;
RefCountedPtr<PickerWrapper> picker_wrapper_;
RefCountedPtr<EndpointPickerWrapper> picker_wrapper_;
grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;
uint32_t weight_;
@ -294,6 +310,8 @@ class XdsLb : public LoadBalancingPolicy {
private:
void OnLocalityStateUpdateLocked();
void UpdateConnectivityStateLocked();
static void OnDelayedRemovalTimer(void* arg, grpc_error* error);
static void OnFailoverTimer(void* arg, grpc_error* error);
static void OnDelayedRemovalTimerLocked(void* arg, grpc_error* error);
static void OnFailoverTimerLocked(void* arg, grpc_error* error);
@ -367,22 +385,31 @@ class XdsLb : public LoadBalancingPolicy {
// Methods for dealing with fallback state.
void MaybeCancelFallbackAtStartupChecks();
static void OnFallbackTimer(void* arg, grpc_error* error);
static void OnFallbackTimerLocked(void* arg, grpc_error* error);
void UpdateFallbackPolicyLocked();
OrphanablePtr<LoadBalancingPolicy> CreateFallbackPolicyLocked(
const char* name, const grpc_channel_args* args);
void MaybeExitFallbackMode();
const char* eds_service_name() const {
if (config_ != nullptr && config_->eds_service_name() != nullptr) {
return config_->eds_service_name();
}
return server_name_.get();
}
XdsClient* xds_client() const {
return xds_client_from_channel_ != nullptr ? xds_client_from_channel_.get()
: xds_client_.get();
}
// Name of the backend server to connect to.
const char* server_name_ = nullptr;
// Server name from target URI.
UniquePtr<char> server_name_;
// Current channel args from the resolver.
// Current channel args and config from the resolver.
const grpc_channel_args* args_ = nullptr;
RefCountedPtr<ParsedXdsConfig> config_;
// Internal state.
bool shutting_down_ = false;
@ -414,14 +441,10 @@ class XdsLb : public LoadBalancingPolicy {
grpc_timer lb_fallback_timer_;
grpc_closure lb_on_fallback_;
// The policy to use for the fallback backends.
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_config_;
// Non-null iff we are in fallback mode.
OrphanablePtr<LoadBalancingPolicy> fallback_policy_;
OrphanablePtr<LoadBalancingPolicy> pending_fallback_policy_;
// The policy to use for the backends.
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_config_;
const grpc_millis locality_retention_interval_ms_;
const grpc_millis locality_map_failover_timeout_ms_;
// A list of locality maps indexed by priority.
@ -437,10 +460,10 @@ class XdsLb : public LoadBalancingPolicy {
};
//
// XdsLb::PickerWrapper::Pick
// XdsLb::EndpointPickerWrapper
//
LoadBalancingPolicy::PickResult XdsLb::PickerWrapper::Pick(
LoadBalancingPolicy::PickResult XdsLb::EndpointPickerWrapper::Pick(
LoadBalancingPolicy::PickArgs args) {
// Forward the pick to the picker returned from the child policy.
PickResult result = picker_->Pick(args);
@ -466,10 +489,10 @@ LoadBalancingPolicy::PickResult XdsLb::PickerWrapper::Pick(
}
//
// XdsLb::Picker
// XdsLb::LocalityPicker
//
XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) {
XdsLb::PickResult XdsLb::LocalityPicker::Pick(PickArgs args) {
// Handle drop.
const UniquePtr<char>* drop_category;
if (drop_config_->ShouldDrop(&drop_category)) {
@ -485,8 +508,8 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) {
return PickFromLocality(key, args);
}
XdsLb::PickResult XdsLb::Picker::PickFromLocality(const uint32_t key,
PickArgs args) {
XdsLb::PickResult XdsLb::LocalityPicker::PickFromLocality(const uint32_t key,
PickArgs args) {
size_t mid = 0;
size_t start_index = 0;
size_t end_index = pickers_.size() - 1;
@ -682,11 +705,11 @@ XdsLb::XdsLb(Args args)
GPR_ASSERT(server_uri != nullptr);
grpc_uri* uri = grpc_uri_parse(server_uri, true);
GPR_ASSERT(uri->path[0] != '\0');
server_name_ = gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
server_name_.reset(
gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path));
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) {
gpr_log(GPR_INFO,
"[xdslb %p] Will use '%s' as the server name for LB request.", this,
server_name_);
gpr_log(GPR_INFO, "[xdslb %p] server name from channel: %s", this,
server_name_.get());
}
grpc_uri_destroy(uri);
}
@ -695,7 +718,6 @@ XdsLb::~XdsLb() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) {
gpr_log(GPR_INFO, "[xdslb %p] destroying xds LB policy", this);
}
gpr_free((void*)server_name_);
grpc_channel_args_destroy(args_);
}
@ -718,9 +740,13 @@ void XdsLb::ShutdownLocked() {
pending_fallback_policy_.reset();
// Cancel the endpoint watch here instead of in our dtor, because the
// watcher holds a ref to us.
xds_client()->CancelEndpointDataWatch(StringView(server_name_),
xds_client()->CancelEndpointDataWatch(StringView(eds_service_name()),
endpoint_watcher_);
xds_client()->RemoveClientStats(StringView(server_name_), &client_stats_);
if (config_->lrs_load_reporting_server_name() != nullptr) {
xds_client()->RemoveClientStats(
StringView(config_->lrs_load_reporting_server_name()),
StringView(eds_service_name()), &client_stats_);
}
xds_client_from_channel_.reset();
xds_client_.reset();
}
@ -749,9 +775,9 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
}
const bool is_initial_update = args_ == nullptr;
// Update config.
auto* xds_config = static_cast<const ParsedXdsConfig*>(args.config.get());
child_policy_config_ = xds_config->child_policy();
fallback_policy_config_ = xds_config->fallback_policy();
const char* old_eds_service_name = eds_service_name();
auto old_config = std::move(config_);
config_ = std::move(args.config);
// Update fallback address list.
fallback_backend_addresses_ = std::move(args.addresses);
// Update args.
@ -768,7 +794,7 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
if (xds_client_from_channel_ == nullptr) {
grpc_error* error = GRPC_ERROR_NONE;
xds_client_ = MakeOrphanable<XdsClient>(
combiner(), interested_parties(), StringView(server_name_),
combiner(), interested_parties(), StringView(eds_service_name()),
nullptr /* service config watcher */, *args_, &error);
// TODO(roth): If we decide that we care about fallback mode, add
// proper error handling here.
@ -778,19 +804,50 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
xds_client_.get());
}
}
auto watcher = MakeUnique<EndpointWatcher>(Ref());
endpoint_watcher_ = watcher.get();
xds_client()->WatchEndpointData(StringView(server_name_),
std::move(watcher));
xds_client()->AddClientStats(StringView(server_name_), &client_stats_);
// Start fallback-at-startup checks.
grpc_millis deadline = ExecCtx::Get()->Now() + lb_fallback_timeout_ms_;
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Held by closure
GRPC_CLOSURE_INIT(&lb_on_fallback_, &XdsLb::OnFallbackTimerLocked, this,
grpc_combiner_scheduler(combiner()));
GRPC_CLOSURE_INIT(&lb_on_fallback_, &XdsLb::OnFallbackTimer, this,
grpc_schedule_on_exec_ctx);
fallback_at_startup_checks_pending_ = true;
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
}
// Update endpoint watcher if needed.
if (is_initial_update ||
strcmp(old_eds_service_name, eds_service_name()) != 0) {
if (!is_initial_update) {
xds_client()->CancelEndpointDataWatch(StringView(old_eds_service_name),
endpoint_watcher_);
}
auto watcher = MakeUnique<EndpointWatcher>(Ref());
endpoint_watcher_ = watcher.get();
xds_client()->WatchEndpointData(StringView(eds_service_name()),
std::move(watcher));
}
// Update load reporting if needed.
// TODO(roth): Ideally, we should not collect any stats if load reporting
// is disabled, which would require changing this code to recreate
// all of the pickers whenever load reporting is enabled or disabled
// here.
if (is_initial_update ||
(config_->lrs_load_reporting_server_name() == nullptr) !=
(old_config->lrs_load_reporting_server_name() == nullptr) ||
(config_->lrs_load_reporting_server_name() != nullptr &&
old_config->lrs_load_reporting_server_name() != nullptr &&
strcmp(config_->lrs_load_reporting_server_name(),
old_config->lrs_load_reporting_server_name()) != 0)) {
if (old_config != nullptr &&
old_config->lrs_load_reporting_server_name() != nullptr) {
xds_client()->RemoveClientStats(
StringView(old_config->lrs_load_reporting_server_name()),
StringView(old_eds_service_name), &client_stats_);
}
if (config_->lrs_load_reporting_server_name() != nullptr) {
xds_client()->AddClientStats(
StringView(config_->lrs_load_reporting_server_name()),
StringView(eds_service_name()), &client_stats_);
}
}
}
//
@ -806,6 +863,14 @@ void XdsLb::MaybeCancelFallbackAtStartupChecks() {
fallback_at_startup_checks_pending_ = false;
}
void XdsLb::OnFallbackTimer(void* arg, grpc_error* error) {
XdsLb* xdslb_policy = static_cast<XdsLb*>(arg);
xdslb_policy->combiner()->Run(
GRPC_CLOSURE_INIT(&xdslb_policy->lb_on_fallback_,
&XdsLb::OnFallbackTimerLocked, xdslb_policy, nullptr),
GRPC_ERROR_REF(error));
}
void XdsLb::OnFallbackTimerLocked(void* arg, grpc_error* error) {
XdsLb* xdslb_policy = static_cast<XdsLb*>(arg);
// If some fallback-at-startup check is done after the timer fires but before
@ -827,9 +892,7 @@ void XdsLb::UpdateFallbackPolicyLocked() {
// Construct update args.
UpdateArgs update_args;
update_args.addresses = fallback_backend_addresses_;
update_args.config = fallback_policy_config_ == nullptr
? nullptr
: fallback_policy_config_->Ref();
update_args.config = config_->fallback_policy();
update_args.args = grpc_channel_args_copy(args_);
// If the child policy name changes, we need to create a new child
// policy. When this happens, we leave child_policy_ as-is and store
@ -880,9 +943,9 @@ void XdsLb::UpdateFallbackPolicyLocked() {
// that was there before, which will be immediately shut down)
// and will later be swapped into child_policy_ by the helper
// when the new child transitions into state READY.
const char* fallback_policy_name = fallback_policy_config_ == nullptr
const char* fallback_policy_name = update_args.config == nullptr
? "round_robin"
: fallback_policy_config_->name();
: update_args.config->name();
const bool create_policy =
// case 1
fallback_policy_ == nullptr ||
@ -1088,10 +1151,9 @@ XdsLb::PriorityList::LocalityMap::LocalityMap(RefCountedPtr<XdsLb> xds_policy,
gpr_log(GPR_INFO, "[xdslb %p] Creating priority %" PRIu32,
xds_policy_.get(), priority_);
}
GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimerLocked,
this, grpc_combiner_scheduler(xds_policy_->combiner()));
GRPC_CLOSURE_INIT(&on_failover_timer_, OnFailoverTimerLocked, this,
grpc_combiner_scheduler(xds_policy_->combiner()));
GRPC_CLOSURE_INIT(&on_failover_timer_, OnFailoverTimer, this,
grpc_schedule_on_exec_ctx);
// Start the failover timer.
Ref(DEBUG_LOCATION, "LocalityMap+OnFailoverTimerLocked").release();
grpc_timer_init(
@ -1164,7 +1226,7 @@ void XdsLb::PriorityList::LocalityMap::UpdateXdsPickerLocked() {
// that are ready. Each locality is represented by a portion of the range
// proportional to its weight, such that the total range is the sum of the
// weights of all localities.
Picker::PickerList picker_list;
LocalityPicker::PickerList picker_list;
uint32_t end = 0;
for (const auto& p : localities_) {
const auto& locality_name = p.first;
@ -1176,9 +1238,9 @@ void XdsLb::PriorityList::LocalityMap::UpdateXdsPickerLocked() {
picker_list.push_back(std::make_pair(end, locality->picker_wrapper()));
}
xds_policy()->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY,
MakeUnique<Picker>(xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+Picker"),
std::move(picker_list)));
GRPC_CHANNEL_READY, MakeUnique<LocalityPicker>(
xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+Picker"),
std::move(picker_list)));
}
OrphanablePtr<XdsLb::PriorityList::LocalityMap::Locality>
@ -1207,6 +1269,8 @@ void XdsLb::PriorityList::LocalityMap::DeactivateLocked() {
xds_policy(), priority_,
xds_policy()->locality_retention_interval_ms_);
}
GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimer, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(
&delayed_removal_timer_,
ExecCtx::Get()->Now() + xds_policy()->locality_retention_interval_ms_,
@ -1335,6 +1399,15 @@ void XdsLb::PriorityList::LocalityMap::UpdateConnectivityStateLocked() {
}
}
void XdsLb::PriorityList::LocalityMap::OnDelayedRemovalTimer(
void* arg, grpc_error* error) {
LocalityMap* self = static_cast<LocalityMap*>(arg);
self->xds_policy_->combiner()->Run(
GRPC_CLOSURE_INIT(&self->on_delayed_removal_timer_,
OnDelayedRemovalTimerLocked, self, nullptr),
GRPC_ERROR_REF(error));
}
void XdsLb::PriorityList::LocalityMap::OnDelayedRemovalTimerLocked(
void* arg, grpc_error* error) {
LocalityMap* self = static_cast<LocalityMap*>(arg);
@ -1344,13 +1417,13 @@ void XdsLb::PriorityList::LocalityMap::OnDelayedRemovalTimerLocked(
const bool keep = self->priority_list_update().Contains(self->priority_) &&
self->priority_ <= priority_list->current_priority();
if (!keep) {
// This check is to make sure we always delete the locality maps from the
// lowest priority even if the closures of the back-to-back timers are not
// run in FIFO order.
// This check is to make sure we always delete the locality maps from
// the lowest priority even if the closures of the back-to-back timers
// are not run in FIFO order.
// TODO(juanlishen): Eliminate unnecessary maintenance overhead for some
// deactivated locality maps when out-of-order closures are run.
// TODO(juanlishen): Check the timer implementation to see if this defense
// is necessary.
// TODO(juanlishen): Check the timer implementation to see if this
// defense is necessary.
if (self->priority_ == priority_list->LowestPriority()) {
priority_list->priorities_.pop_back();
} else {
@ -1365,6 +1438,15 @@ void XdsLb::PriorityList::LocalityMap::OnDelayedRemovalTimerLocked(
self->Unref(DEBUG_LOCATION, "LocalityMap+timer");
}
void XdsLb::PriorityList::LocalityMap::OnFailoverTimer(void* arg,
grpc_error* error) {
LocalityMap* self = static_cast<LocalityMap*>(arg);
self->xds_policy_->combiner()->Run(
GRPC_CLOSURE_INIT(&self->on_failover_timer_, OnFailoverTimerLocked, self,
nullptr),
GRPC_ERROR_REF(error));
}
void XdsLb::PriorityList::LocalityMap::OnFailoverTimerLocked(
void* arg, grpc_error* error) {
LocalityMap* self = static_cast<LocalityMap*>(arg);
@ -1387,8 +1469,6 @@ XdsLb::PriorityList::LocalityMap::Locality::Locality(
gpr_log(GPR_INFO, "[xdslb %p] created Locality %p for %s", xds_policy(),
this, name_->AsHumanReadableString());
}
GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimerLocked,
this, grpc_combiner_scheduler(xds_policy()->combiner()));
}
XdsLb::PriorityList::LocalityMap::Locality::~Locality() {
@ -1443,8 +1523,8 @@ XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked(
lb_policy.get());
}
// Add the xDS's interested_parties pollset_set to that of the newly created
// child policy. This will make the child policy progress upon activity on xDS
// LB, which in turn is tied to the application's call.
// child policy. This will make the child policy progress upon activity on
// xDS LB, which in turn is tied to the application's call.
grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(),
xds_policy()->interested_parties());
return lb_policy;
@ -1461,9 +1541,7 @@ void XdsLb::PriorityList::LocalityMap::Locality::UpdateLocked(
// Construct update args.
UpdateArgs update_args;
update_args.addresses = std::move(serverlist);
update_args.config = xds_policy()->child_policy_config_ == nullptr
? nullptr
: xds_policy()->child_policy_config_->Ref();
update_args.config = xds_policy()->config_->child_policy();
update_args.args = CreateChildPolicyArgsLocked(xds_policy()->args_);
// If the child policy name changes, we need to create a new child
// policy. When this happens, we leave child_policy_ as-is and store
@ -1516,10 +1594,9 @@ void XdsLb::PriorityList::LocalityMap::Locality::UpdateLocked(
// when the new child transitions into state READY.
// TODO(juanlishen): If the child policy is not configured via service config,
// use whatever algorithm is specified by the balancer.
const char* child_policy_name =
xds_policy()->child_policy_config_ == nullptr
? "round_robin"
: xds_policy()->child_policy_config_->name();
const char* child_policy_name = update_args.config == nullptr
? "round_robin"
: update_args.config->name();
const bool create_policy =
// case 1
child_policy_ == nullptr ||
@ -1608,6 +1685,8 @@ void XdsLb::PriorityList::LocalityMap::Locality::DeactivateLocked() {
weight_ = 0;
// Start a timer to delete the locality.
Ref(DEBUG_LOCATION, "Locality+timer").release();
GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimer, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(
&delayed_removal_timer_,
ExecCtx::Get()->Now() + xds_policy()->locality_retention_interval_ms_,
@ -1615,6 +1694,15 @@ void XdsLb::PriorityList::LocalityMap::Locality::DeactivateLocked() {
delayed_removal_timer_callback_pending_ = true;
}
void XdsLb::PriorityList::LocalityMap::Locality::OnDelayedRemovalTimer(
void* arg, grpc_error* error) {
Locality* self = static_cast<Locality*>(arg);
self->xds_policy()->combiner()->Run(
GRPC_CLOSURE_INIT(&self->on_delayed_removal_timer_,
OnDelayedRemovalTimerLocked, self, nullptr),
GRPC_ERROR_REF(error));
}
void XdsLb::PriorityList::LocalityMap::Locality::OnDelayedRemovalTimerLocked(
void* arg, grpc_error* error) {
Locality* self = static_cast<Locality*>(arg);
@ -1675,7 +1763,11 @@ void XdsLb::PriorityList::LocalityMap::Locality::Helper::UpdateState(
return;
}
// Cache the picker and its state in the locality.
locality_->picker_wrapper_ = MakeRefCounted<PickerWrapper>(
// TODO(roth): If load reporting is not configured, we should ideally
// pass a null LocalityStats ref to the EndpointPickerWrapper and have it
// not collect any stats, since they're not going to be used. This would
// require recreating all of the pickers whenever we get a config update.
locality_->picker_wrapper_ = MakeRefCounted<EndpointPickerWrapper>(
std::move(picker),
locality_->xds_policy()->client_stats_.FindLocalityStats(
locality_->name_));
@ -1722,6 +1814,8 @@ class XdsFactory : public LoadBalancingPolicyFactory {
InlinedVector<grpc_error*, 3> error_list;
RefCountedPtr<LoadBalancingPolicy::Config> child_policy;
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy;
const char* eds_service_name = nullptr;
const char* lrs_load_reporting_server_name = nullptr;
for (const grpc_json* field = json->child; field != nullptr;
field = field->next) {
if (field->key == nullptr) continue;
@ -1749,11 +1843,35 @@ class XdsFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE);
error_list.push_back(parse_error);
}
} else if (strcmp(field->key, "edsServiceName") == 0) {
if (eds_service_name != nullptr) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:edsServiceName error:Duplicate entry"));
}
if (field->type != GRPC_JSON_STRING) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:edsServiceName error:type should be string"));
continue;
}
eds_service_name = field->value;
} else if (strcmp(field->key, "lrsLoadReportingServerName") == 0) {
if (lrs_load_reporting_server_name != nullptr) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:lrsLoadReportingServerName error:Duplicate entry"));
}
if (field->type != GRPC_JSON_STRING) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:lrsLoadReportingServerName error:type should be string"));
continue;
}
lrs_load_reporting_server_name = field->value;
}
}
if (error_list.empty()) {
return RefCountedPtr<LoadBalancingPolicy::Config>(New<ParsedXdsConfig>(
std::move(child_policy), std::move(fallback_policy)));
return MakeRefCounted<ParsedXdsConfig>(
std::move(child_policy), std::move(fallback_policy),
UniquePtr<char>(gpr_strdup(eds_service_name)),
UniquePtr<char>(gpr_strdup(lrs_load_reporting_server_name)));
} else {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Xds Parser", &error_list);
return nullptr;

@ -30,8 +30,7 @@ namespace grpc_core {
// Resolver
//
Resolver::Resolver(grpc_combiner* combiner,
UniquePtr<ResultHandler> result_handler)
Resolver::Resolver(Combiner* combiner, UniquePtr<ResultHandler> result_handler)
: InternallyRefCounted(&grpc_trace_resolver_refcount),
result_handler_(std::move(result_handler)),
combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {}

@ -126,19 +126,19 @@ class Resolver : public InternallyRefCounted<Resolver> {
// TODO(roth): Once we have a C++-like interface for combiners, this
// API should change to take a RefCountedPtr<>, so that we always take
// ownership of a new ref.
explicit Resolver(grpc_combiner* combiner,
explicit Resolver(Combiner* combiner,
UniquePtr<ResultHandler> result_handler);
/// Shuts down the resolver.
virtual void ShutdownLocked() = 0;
grpc_combiner* combiner() const { return combiner_; }
Combiner* combiner() const { return combiner_; }
ResultHandler* result_handler() const { return result_handler_.get(); }
private:
UniquePtr<ResultHandler> result_handler_;
grpc_combiner* combiner_;
Combiner* combiner_;
};
} // namespace grpc_core

@ -76,6 +76,8 @@ class AresDnsResolver : public Resolver {
void MaybeStartResolvingLocked();
void StartResolvingLocked();
static void OnNextResolution(void* arg, grpc_error* error);
static void OnResolved(void* arg, grpc_error* error);
static void OnNextResolutionLocked(void* arg, grpc_error* error);
static void OnResolvedLocked(void* arg, grpc_error* error);
@ -152,10 +154,7 @@ AresDnsResolver::AresDnsResolver(ResolverArgs args)
if (args.pollset_set != nullptr) {
grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set);
}
GRPC_CLOSURE_INIT(&on_next_resolution_, OnNextResolutionLocked, this,
grpc_combiner_scheduler(combiner()));
GRPC_CLOSURE_INIT(&on_resolved_, OnResolvedLocked, this,
grpc_combiner_scheduler(combiner()));
const grpc_arg* query_timeout_ms_arg =
grpc_channel_args_find(channel_args_, GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS);
query_timeout_ms_ = grpc_channel_arg_get_integer(
@ -200,6 +199,13 @@ void AresDnsResolver::ShutdownLocked() {
}
}
void AresDnsResolver::OnNextResolution(void* arg, grpc_error* error) {
AresDnsResolver* r = static_cast<AresDnsResolver*>(arg);
r->combiner()->Run(GRPC_CLOSURE_INIT(&r->on_next_resolution_,
OnNextResolutionLocked, r, nullptr),
GRPC_ERROR_REF(error));
}
void AresDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) {
AresDnsResolver* r = static_cast<AresDnsResolver*>(arg);
GRPC_CARES_TRACE_LOG(
@ -317,6 +323,13 @@ char* ChooseServiceConfig(char* service_config_choice_json,
return service_config;
}
void AresDnsResolver::OnResolved(void* arg, grpc_error* error) {
AresDnsResolver* r = static_cast<AresDnsResolver*>(arg);
r->combiner()->Run(
GRPC_CLOSURE_INIT(&r->on_resolved_, OnResolvedLocked, r, nullptr),
GRPC_ERROR_REF(error));
}
void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
AresDnsResolver* r = static_cast<AresDnsResolver*>(arg);
GPR_ASSERT(r->resolving_);
@ -373,6 +386,8 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
} else {
GRPC_CARES_TRACE_LOG("resolver:%p retrying immediately", r);
}
GRPC_CLOSURE_INIT(&r->on_next_resolution_, OnNextResolution, r,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&r->next_resolution_timer_, next_try,
&r->on_next_resolution_);
}
@ -400,6 +415,8 @@ void AresDnsResolver::MaybeStartResolvingLocked() {
// new closure API is done, find a way to track this ref with the timer
// callback as part of the type system.
Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release();
GRPC_CLOSURE_INIT(&on_next_resolution_, OnNextResolution, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&next_resolution_timer_,
ExecCtx::Get()->Now() + ms_until_next_resolution,
&on_next_resolution_);
@ -417,6 +434,7 @@ void AresDnsResolver::StartResolvingLocked() {
GPR_ASSERT(!resolving_);
resolving_ = true;
service_config_json_ = nullptr;
GRPC_CLOSURE_INIT(&on_resolved_, OnResolved, this, grpc_schedule_on_exec_ctx);
pending_request_ = grpc_dns_lookup_ares_locked(
dns_server_, name_to_resolve_, kDefaultPort, interested_parties_,
&on_resolved_, &addresses_, enable_srv_queries_ /* check_grpclb */,

@ -67,7 +67,7 @@ struct grpc_ares_ev_driver {
gpr_refcount refs;
/** combiner to synchronize c-ares and I/O callbacks on */
grpc_combiner* combiner;
grpc_core::Combiner* combiner;
/** a list of grpc_fd that this event driver is currently using. */
fd_node* fds;
/** is this event driver currently working? */
@ -132,8 +132,10 @@ static void fd_node_shutdown_locked(fd_node* fdn, const char* reason) {
}
}
static void on_timeout(void* arg, grpc_error* error);
static void on_timeout_locked(void* arg, grpc_error* error);
static void on_ares_backup_poll_alarm(void* arg, grpc_error* error);
static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error);
static void noop_inject_channel_config(ares_channel channel) {}
@ -144,7 +146,7 @@ void (*grpc_ares_test_only_inject_config)(ares_channel channel) =
grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
grpc_pollset_set* pollset_set,
int query_timeout_ms,
grpc_combiner* combiner,
grpc_core::Combiner* combiner,
grpc_ares_request* request) {
*ev_driver = grpc_core::New<grpc_ares_ev_driver>();
ares_options opts;
@ -173,11 +175,6 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
grpc_core::NewGrpcPolledFdFactory((*ev_driver)->combiner);
(*ev_driver)
->polled_fd_factory->ConfigureAresChannelLocked((*ev_driver)->channel);
GRPC_CLOSURE_INIT(&(*ev_driver)->on_timeout_locked, on_timeout_locked,
*ev_driver, grpc_combiner_scheduler(combiner));
GRPC_CLOSURE_INIT(&(*ev_driver)->on_ares_backup_poll_alarm_locked,
on_ares_backup_poll_alarm_locked, *ev_driver,
grpc_combiner_scheduler(combiner));
(*ev_driver)->query_timeout_ms = query_timeout_ms;
return GRPC_ERROR_NONE;
}
@ -235,6 +232,13 @@ static grpc_millis calculate_next_ares_backup_poll_alarm_ms(
grpc_core::ExecCtx::Get()->Now();
}
static void on_timeout(void* arg, grpc_error* error) {
grpc_ares_ev_driver* driver = static_cast<grpc_ares_ev_driver*>(arg);
driver->combiner->Run(GRPC_CLOSURE_INIT(&driver->on_timeout_locked,
on_timeout_locked, driver, nullptr),
GRPC_ERROR_REF(error));
}
static void on_timeout_locked(void* arg, grpc_error* error) {
grpc_ares_ev_driver* driver = static_cast<grpc_ares_ev_driver*>(arg);
GRPC_CARES_TRACE_LOG(
@ -247,6 +251,14 @@ static void on_timeout_locked(void* arg, grpc_error* error) {
grpc_ares_ev_driver_unref(driver);
}
static void on_ares_backup_poll_alarm(void* arg, grpc_error* error) {
grpc_ares_ev_driver* driver = static_cast<grpc_ares_ev_driver*>(arg);
driver->combiner->Run(
GRPC_CLOSURE_INIT(&driver->on_ares_backup_poll_alarm_locked,
on_ares_backup_poll_alarm_locked, driver, nullptr),
GRPC_ERROR_REF(error));
}
/* In case of non-responsive DNS servers, dropped packets, etc., c-ares has
* intelligent timeout and retry logic, which we can take advantage of by
* polling ares_process_fd on time intervals. Overall, the c-ares library is
@ -279,6 +291,9 @@ static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error) {
grpc_millis next_ares_backup_poll_alarm =
calculate_next_ares_backup_poll_alarm_ms(driver);
grpc_ares_ev_driver_ref(driver);
GRPC_CLOSURE_INIT(&driver->on_ares_backup_poll_alarm_locked,
on_ares_backup_poll_alarm, driver,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&driver->ares_backup_poll_alarm,
next_ares_backup_poll_alarm,
&driver->on_ares_backup_poll_alarm_locked);
@ -313,6 +328,13 @@ static void on_readable_locked(void* arg, grpc_error* error) {
grpc_ares_ev_driver_unref(ev_driver);
}
static void on_readable(void* arg, grpc_error* error) {
fd_node* fdn = static_cast<fd_node*>(arg);
fdn->ev_driver->combiner->Run(
GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable_locked, fdn, nullptr),
GRPC_ERROR_REF(error));
}
static void on_writable_locked(void* arg, grpc_error* error) {
fd_node* fdn = static_cast<fd_node*>(arg);
GPR_ASSERT(fdn->writable_registered);
@ -336,6 +358,13 @@ static void on_writable_locked(void* arg, grpc_error* error) {
grpc_ares_ev_driver_unref(ev_driver);
}
static void on_writable(void* arg, grpc_error* error) {
fd_node* fdn = static_cast<fd_node*>(arg);
fdn->ev_driver->combiner->Run(
GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_locked, fdn, nullptr),
GRPC_ERROR_REF(error));
}
ares_channel* grpc_ares_ev_driver_get_channel_locked(
grpc_ares_ev_driver* ev_driver) {
return &ev_driver->channel;
@ -365,10 +394,6 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
fdn->readable_registered = false;
fdn->writable_registered = false;
fdn->already_shutdown = false;
GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable_locked, fdn,
grpc_combiner_scheduler(ev_driver->combiner));
GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_locked, fdn,
grpc_combiner_scheduler(ev_driver->combiner));
}
fdn->next = new_list;
new_list = fdn;
@ -380,6 +405,8 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
GRPC_CARES_TRACE_LOG("request:%p notify read on: %s",
ev_driver->request,
fdn->grpc_polled_fd->GetName());
GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable, fdn,
grpc_schedule_on_exec_ctx);
fdn->grpc_polled_fd->RegisterForOnReadableLocked(&fdn->read_closure);
fdn->readable_registered = true;
}
@ -391,6 +418,8 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
ev_driver->request,
fdn->grpc_polled_fd->GetName());
grpc_ares_ev_driver_ref(ev_driver);
GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable, fdn,
grpc_schedule_on_exec_ctx);
fdn->grpc_polled_fd->RegisterForOnWriteableLocked(
&fdn->write_closure);
fdn->writable_registered = true;
@ -435,12 +464,17 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) {
"%" PRId64 " ms",
ev_driver->request, ev_driver, timeout);
grpc_ares_ev_driver_ref(ev_driver);
GRPC_CLOSURE_INIT(&ev_driver->on_timeout_locked, on_timeout, ev_driver,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&ev_driver->query_timeout, timeout,
&ev_driver->on_timeout_locked);
// Initialize the backup poll alarm
grpc_millis next_ares_backup_poll_alarm =
calculate_next_ares_backup_poll_alarm_ms(ev_driver);
grpc_ares_ev_driver_ref(ev_driver);
GRPC_CLOSURE_INIT(&ev_driver->on_ares_backup_poll_alarm_locked,
on_ares_backup_poll_alarm, ev_driver,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&ev_driver->ares_backup_poll_alarm,
next_ares_backup_poll_alarm,
&ev_driver->on_ares_backup_poll_alarm_locked);

@ -43,7 +43,7 @@ ares_channel* grpc_ares_ev_driver_get_channel_locked(
grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
grpc_pollset_set* pollset_set,
int query_timeout_ms,
grpc_combiner* combiner,
grpc_core::Combiner* combiner,
grpc_ares_request* request);
/* Called back when all DNS lookups have completed. */
@ -90,12 +90,12 @@ class GrpcPolledFdFactory {
/* Creates a new wrapped fd for the current platform */
virtual GrpcPolledFd* NewGrpcPolledFdLocked(
ares_socket_t as, grpc_pollset_set* driver_pollset_set,
grpc_combiner* combiner) = 0;
Combiner* combiner) = 0;
/* Optionally configures the ares channel after creation */
virtual void ConfigureAresChannelLocked(ares_channel channel) = 0;
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner);
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner);
} // namespace grpc_core

@ -41,7 +41,7 @@ void ares_uv_poll_close_cb(uv_handle_t* handle) { Delete(handle); }
class GrpcPolledFdLibuv : public GrpcPolledFd {
public:
GrpcPolledFdLibuv(ares_socket_t as, grpc_combiner* combiner)
GrpcPolledFdLibuv(ares_socket_t as, Combiner* combiner)
: as_(as), combiner_(combiner) {
gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, (intptr_t)as);
handle_ = New<uv_poll_t>();
@ -107,7 +107,7 @@ class GrpcPolledFdLibuv : public GrpcPolledFd {
grpc_closure* read_closure_ = nullptr;
grpc_closure* write_closure_ = nullptr;
int poll_events_ = 0;
grpc_combiner* combiner_;
Combiner* combiner_;
};
struct AresUvPollCbArg {
@ -153,9 +153,8 @@ void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) {
GrpcPolledFdLibuv* polled_fd =
reinterpret_cast<GrpcPolledFdLibuv*>(handle->data);
AresUvPollCbArg* arg = New<AresUvPollCbArg>(handle, status, events);
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg,
grpc_combiner_scheduler(polled_fd->combiner_)),
polled_fd->combiner_->Run(
GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, nullptr),
GRPC_ERROR_NONE);
}
@ -163,14 +162,14 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory {
public:
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set,
grpc_combiner* combiner) override {
Combiner* combiner) override {
return New<GrpcPolledFdLibuv>(as, combiner);
}
void ConfigureAresChannelLocked(ares_channel channel) override {}
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner) {
return MakeUnique<GrpcPolledFdFactoryLibuv>();
}

@ -90,14 +90,14 @@ class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory {
public:
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set,
grpc_combiner* combiner) override {
Combiner* combiner) override {
return New<GrpcPolledFdPosix>(as, driver_pollset_set);
}
void ConfigureAresChannelLocked(ares_channel channel) override {}
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner) {
return MakeUnique<GrpcPolledFdFactoryPosix>();
}

@ -97,8 +97,8 @@ class GrpcPolledFdWindows {
WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY,
};
GrpcPolledFdWindows(ares_socket_t as, grpc_combiner* combiner,
int address_family, int socket_type)
GrpcPolledFdWindows(ares_socket_t as, Combiner* combiner, int address_family,
int socket_type)
: read_buf_(grpc_empty_slice()),
write_buf_(grpc_empty_slice()),
tcp_write_state_(WRITE_IDLE),
@ -108,22 +108,13 @@ class GrpcPolledFdWindows {
gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, as);
winsocket_ = grpc_winsocket_create(as, name_);
combiner_ = GRPC_COMBINER_REF(combiner, name_);
GRPC_CLOSURE_INIT(&outer_read_closure_,
&GrpcPolledFdWindows::OnIocpReadable, this,
grpc_combiner_scheduler(combiner_));
GRPC_CLOSURE_INIT(&outer_write_closure_,
&GrpcPolledFdWindows::OnIocpWriteable, this,
grpc_combiner_scheduler(combiner_));
GRPC_CLOSURE_INIT(&on_tcp_connect_locked_,
&GrpcPolledFdWindows::OnTcpConnectLocked, this,
grpc_combiner_scheduler(combiner_));
GRPC_CLOSURE_INIT(&continue_register_for_on_readable_locked_,
&GrpcPolledFdWindows::ContinueRegisterForOnReadableLocked,
this, grpc_combiner_scheduler(combiner_));
this, nullptr);
GRPC_CLOSURE_INIT(
&continue_register_for_on_writeable_locked_,
&GrpcPolledFdWindows::ContinueRegisterForOnWriteableLocked, this,
grpc_combiner_scheduler(combiner_));
nullptr);
}
~GrpcPolledFdWindows() {
@ -154,8 +145,8 @@ class GrpcPolledFdWindows {
GPR_ASSERT(!read_buf_has_data_);
read_buf_ = GRPC_SLICE_MALLOC(4192);
if (connect_done_) {
GRPC_CLOSURE_SCHED(&continue_register_for_on_readable_locked_,
GRPC_ERROR_NONE);
combiner_->Run(&continue_register_for_on_readable_locked_,
GRPC_ERROR_NONE);
} else {
GPR_ASSERT(pending_continue_register_for_on_readable_locked_ == nullptr);
pending_continue_register_for_on_readable_locked_ =
@ -203,7 +194,10 @@ class GrpcPolledFdWindows {
return;
}
}
grpc_socket_notify_on_read(winsocket_, &outer_read_closure_);
grpc_socket_notify_on_read(
winsocket_, GRPC_CLOSURE_INIT(&outer_read_closure_,
&GrpcPolledFdWindows::OnIocpReadable,
this, grpc_schedule_on_exec_ctx));
}
void RegisterForOnWriteableLocked(grpc_closure* write_closure) {
@ -219,8 +213,8 @@ class GrpcPolledFdWindows {
GPR_ASSERT(write_closure_ == nullptr);
write_closure_ = write_closure;
if (connect_done_) {
GRPC_CLOSURE_SCHED(&continue_register_for_on_writeable_locked_,
GRPC_ERROR_NONE);
combiner_->Run(&continue_register_for_on_writeable_locked_,
GRPC_ERROR_NONE);
} else {
GPR_ASSERT(pending_continue_register_for_on_writeable_locked_ == nullptr);
pending_continue_register_for_on_writeable_locked_ =
@ -262,7 +256,11 @@ class GrpcPolledFdWindows {
ScheduleAndNullWriteClosure(
GRPC_WSA_ERROR(wsa_error_code, "WSASend (overlapped)"));
} else {
grpc_socket_notify_on_write(winsocket_, &outer_write_closure_);
grpc_socket_notify_on_write(
winsocket_,
GRPC_CLOSURE_INIT(&outer_write_closure_,
&GrpcPolledFdWindows::OnIocpWriteable, this,
grpc_schedule_on_exec_ctx));
}
break;
case WRITE_PENDING:
@ -439,6 +437,16 @@ class GrpcPolledFdWindows {
abort();
}
static void OnTcpConnect(void* arg, grpc_error* error) {
GrpcPolledFdWindows* grpc_polled_fd =
static_cast<GrpcPolledFdWindows*>(arg);
grpc_polled_fd->combiner_->Run(
GRPC_CLOSURE_INIT(&grpc_polled_fd->on_tcp_connect_locked_,
&GrpcPolledFdWindows::OnTcpConnectLocked,
grpc_polled_fd, nullptr),
GRPC_ERROR_REF(error));
}
static void OnTcpConnectLocked(void* arg, grpc_error* error) {
GrpcPolledFdWindows* grpc_polled_fd =
static_cast<GrpcPolledFdWindows*>(arg);
@ -479,12 +487,12 @@ class GrpcPolledFdWindows {
wsa_connect_error_ = WSA_OPERATION_ABORTED;
}
if (pending_continue_register_for_on_readable_locked_ != nullptr) {
GRPC_CLOSURE_SCHED(pending_continue_register_for_on_readable_locked_,
GRPC_ERROR_NONE);
combiner_->Run(pending_continue_register_for_on_readable_locked_,
GRPC_ERROR_NONE);
}
if (pending_continue_register_for_on_writeable_locked_ != nullptr) {
GRPC_CLOSURE_SCHED(pending_continue_register_for_on_writeable_locked_,
GRPC_ERROR_NONE);
combiner_->Run(pending_continue_register_for_on_writeable_locked_,
GRPC_ERROR_NONE);
}
}
@ -585,11 +593,23 @@ class GrpcPolledFdWindows {
return -1;
}
}
GRPC_CLOSURE_INIT(&on_tcp_connect_locked_,
&GrpcPolledFdWindows::OnTcpConnect, this,
grpc_schedule_on_exec_ctx);
grpc_socket_notify_on_write(winsocket_, &on_tcp_connect_locked_);
return out;
}
static void OnIocpReadable(void* arg, grpc_error* error) {
GrpcPolledFdWindows* polled_fd = static_cast<GrpcPolledFdWindows*>(arg);
polled_fd->combiner_->Run(
GRPC_CLOSURE_INIT(&polled_fd->outer_read_closure_,
&GrpcPolledFdWindows::OnIocpReadableLocked, polled_fd,
nullptr),
GRPC_ERROR_REF(error));
}
static void OnIocpReadableLocked(void* arg, grpc_error* error) {
GrpcPolledFdWindows* polled_fd = static_cast<GrpcPolledFdWindows*>(arg);
polled_fd->OnIocpReadableInner(error);
}
@ -633,6 +653,15 @@ class GrpcPolledFdWindows {
}
static void OnIocpWriteable(void* arg, grpc_error* error) {
GrpcPolledFdWindows* polled_fd = static_cast<GrpcPolledFdWindows*>(arg);
polled_fd->combiner_->Run(
GRPC_CLOSURE_INIT(&polled_fd->outer_write_closure_,
&GrpcPolledFdWindows::OnIocpWriteableLocked,
polled_fd, nullptr),
GRPC_ERROR_REF(error));
}
static void OnIocpWriteableLocked(void* arg, grpc_error* error) {
GrpcPolledFdWindows* polled_fd = static_cast<GrpcPolledFdWindows*>(arg);
polled_fd->OnIocpWriteableInner(error);
}
@ -669,7 +698,7 @@ class GrpcPolledFdWindows {
bool gotten_into_driver_list() const { return gotten_into_driver_list_; }
void set_gotten_into_driver_list() { gotten_into_driver_list_ = true; }
grpc_combiner* combiner_;
Combiner* combiner_;
char recv_from_source_addr_[200];
ares_socklen_t recv_from_source_addr_len_;
grpc_slice read_buf_;
@ -713,7 +742,7 @@ struct SockToPolledFdEntry {
* with a GrpcPolledFdWindows factory and event driver */
class SockToPolledFdMap {
public:
SockToPolledFdMap(grpc_combiner* combiner) {
SockToPolledFdMap(Combiner* combiner) {
combiner_ = GRPC_COMBINER_REF(combiner, "sock to polled fd map");
}
@ -832,7 +861,7 @@ class SockToPolledFdMap {
private:
SockToPolledFdEntry* head_ = nullptr;
grpc_combiner* combiner_;
Combiner* combiner_;
};
const struct ares_socket_functions custom_ares_sock_funcs = {
@ -881,12 +910,12 @@ class GrpcPolledFdWindowsWrapper : public GrpcPolledFd {
class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
public:
GrpcPolledFdFactoryWindows(grpc_combiner* combiner)
GrpcPolledFdFactoryWindows(Combiner* combiner)
: sock_to_polled_fd_map_(combiner) {}
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set,
grpc_combiner* combiner) override {
Combiner* combiner) override {
GrpcPolledFdWindows* polled_fd = sock_to_polled_fd_map_.LookupPolledFd(as);
// Set a flag so that the virtual socket "close" method knows it
// doesn't need to call ShutdownLocked, since now the driver will.
@ -903,7 +932,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
SockToPolledFdMap sock_to_polled_fd_map_;
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner) {
return MakeUnique<GrpcPolledFdFactoryWindows>(combiner);
}

@ -350,7 +350,7 @@ done:
void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked(
grpc_ares_request* r, const char* dns_server, const char* name,
const char* default_port, grpc_pollset_set* interested_parties,
bool check_grpclb, int query_timeout_ms, grpc_combiner* combiner) {
bool check_grpclb, int query_timeout_ms, grpc_core::Combiner* combiner) {
grpc_error* error = GRPC_ERROR_NONE;
grpc_ares_hostbyname_request* hr = nullptr;
ares_channel* channel = nullptr;
@ -590,7 +590,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) {
grpc_core::Combiner* combiner) {
grpc_ares_request* r =
static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request)));
r->ev_driver = nullptr;
@ -633,7 +633,7 @@ grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {
GPR_ASSERT(r != nullptr);
@ -674,7 +674,7 @@ void grpc_ares_cleanup(void) {}
typedef struct grpc_resolve_address_ares_request {
/* combiner that queries and related callbacks run under */
grpc_combiner* combiner;
grpc_core::Combiner* combiner;
/** the pointer to receive the resolved addresses */
grpc_resolved_addresses** addrs_out;
/** currently resolving addresses */
@ -719,10 +719,20 @@ static void on_dns_lookup_done_locked(void* arg, grpc_error* error) {
grpc_core::Delete(r);
}
static void on_dns_lookup_done(void* arg, grpc_error* error) {
grpc_resolve_address_ares_request* r =
static_cast<grpc_resolve_address_ares_request*>(arg);
r->combiner->Run(GRPC_CLOSURE_INIT(&r->on_dns_lookup_done_locked,
on_dns_lookup_done_locked, r, nullptr),
GRPC_ERROR_REF(error));
}
static void grpc_resolve_address_invoke_dns_lookup_ares_locked(
void* arg, grpc_error* unused_error) {
grpc_resolve_address_ares_request* r =
static_cast<grpc_resolve_address_ares_request*>(arg);
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done_locked, on_dns_lookup_done, r,
grpc_schedule_on_exec_ctx);
r->ares_request = grpc_dns_lookup_ares_locked(
nullptr /* dns_server */, r->name, r->default_port, r->interested_parties,
&r->on_dns_lookup_done_locked, &r->addresses, false /* check_grpclb */,
@ -740,14 +750,12 @@ static void grpc_resolve_address_ares_impl(const char* name,
r->combiner = grpc_combiner_create();
r->addrs_out = addrs;
r->on_resolve_address_done = on_done;
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done_locked, on_dns_lookup_done_locked, r,
grpc_combiner_scheduler(r->combiner));
r->name = name;
r->default_port = default_port;
r->interested_parties = interested_parties;
GRPC_CLOSURE_SCHED(
r->combiner->Run(
GRPC_CLOSURE_CREATE(grpc_resolve_address_invoke_dns_lookup_ares_locked, r,
grpc_combiner_scheduler(r->combiner)),
nullptr),
GRPC_ERROR_NONE);
}

@ -65,7 +65,7 @@ extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner);
grpc_core::Combiner* combiner);
/* Cancel the pending grpc_ares_request \a request */
extern void (*grpc_cancel_ares_request_locked)(grpc_ares_request* request);

@ -31,7 +31,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) {
grpc_core::Combiner* combiner) {
return NULL;
}
@ -40,7 +40,7 @@ grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {}

@ -66,7 +66,9 @@ class NativeDnsResolver : public Resolver {
void MaybeStartResolvingLocked();
void StartResolvingLocked();
static void OnNextResolution(void* arg, grpc_error* error);
static void OnNextResolutionLocked(void* arg, grpc_error* error);
static void OnResolved(void* arg, grpc_error* error);
static void OnResolvedLocked(void* arg, grpc_error* error);
/// name to resolve
@ -115,11 +117,6 @@ NativeDnsResolver::NativeDnsResolver(ResolverArgs args)
if (args.pollset_set != nullptr) {
grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set);
}
GRPC_CLOSURE_INIT(&on_next_resolution_,
NativeDnsResolver::OnNextResolutionLocked, this,
grpc_combiner_scheduler(args.combiner));
GRPC_CLOSURE_INIT(&on_resolved_, NativeDnsResolver::OnResolvedLocked, this,
grpc_combiner_scheduler(args.combiner));
}
NativeDnsResolver::~NativeDnsResolver() {
@ -150,6 +147,14 @@ void NativeDnsResolver::ShutdownLocked() {
}
}
void NativeDnsResolver::OnNextResolution(void* arg, grpc_error* error) {
NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
r->combiner()->Run(
GRPC_CLOSURE_INIT(&r->on_next_resolution_,
NativeDnsResolver::OnNextResolutionLocked, r, nullptr),
GRPC_ERROR_REF(error));
}
void NativeDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) {
NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
r->have_next_resolution_timer_ = false;
@ -159,6 +164,14 @@ void NativeDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) {
r->Unref(DEBUG_LOCATION, "retry-timer");
}
void NativeDnsResolver::OnResolved(void* arg, grpc_error* error) {
NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
r->combiner()->Run(
GRPC_CLOSURE_INIT(&r->on_resolved_, NativeDnsResolver::OnResolvedLocked,
r, nullptr),
GRPC_ERROR_REF(error));
}
void NativeDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
GPR_ASSERT(r->resolving_);
@ -202,6 +215,9 @@ void NativeDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
} else {
gpr_log(GPR_DEBUG, "retrying immediately");
}
GRPC_CLOSURE_INIT(&r->on_next_resolution_,
NativeDnsResolver::OnNextResolution, r,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&r->next_resolution_timer_, next_try,
&r->on_next_resolution_);
}
@ -229,6 +245,9 @@ void NativeDnsResolver::MaybeStartResolvingLocked() {
// new closure API is done, find a way to track this ref with the timer
// callback as part of the type system.
Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release();
GRPC_CLOSURE_INIT(&on_next_resolution_,
NativeDnsResolver::OnNextResolution, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&next_resolution_timer_,
ExecCtx::Get()->Now() + ms_until_next_resolution,
&on_next_resolution_);
@ -247,6 +266,8 @@ void NativeDnsResolver::StartResolvingLocked() {
GPR_ASSERT(!resolving_);
resolving_ = true;
addresses_ = nullptr;
GRPC_CLOSURE_INIT(&on_resolved_, NativeDnsResolver::OnResolved, this,
grpc_schedule_on_exec_ctx);
grpc_resolve_address(name_to_resolve_, kDefaultPort, interested_parties_,
&on_resolved_, &addresses_);
last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now();

@ -98,8 +98,6 @@ FakeResolver::FakeResolver(ResolverArgs args)
: Resolver(args.combiner, std::move(args.result_handler)),
response_generator_(
FakeResolverResponseGenerator::GetFromArgs(args.args)) {
GRPC_CLOSURE_INIT(&reresolution_closure_, ReturnReresolutionResult, this,
grpc_combiner_scheduler(combiner()));
// Channels sharing the same subchannels may have different resolver response
// generators. If we don't remove this arg, subchannel pool will create new
// subchannels for the same address instead of reusing existing ones because
@ -129,7 +127,9 @@ void FakeResolver::RequestReresolutionLocked() {
if (!reresolution_closure_pending_) {
reresolution_closure_pending_ = true;
Ref().release(); // ref held by closure
GRPC_CLOSURE_SCHED(&reresolution_closure_, GRPC_ERROR_NONE);
GRPC_CLOSURE_INIT(&reresolution_closure_, ReturnReresolutionResult, this,
nullptr);
combiner()->Run(&reresolution_closure_, GRPC_ERROR_NONE);
}
}
}
@ -208,10 +208,9 @@ void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) {
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
closure_arg->resolver = std::move(resolver);
closure_arg->result = std::move(result);
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(
&closure_arg->set_response_closure, SetResponseLocked, closure_arg,
grpc_combiner_scheduler(closure_arg->resolver->combiner())),
closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetResponseLocked,
closure_arg, nullptr),
GRPC_ERROR_NONE);
}
@ -238,11 +237,9 @@ void FakeResolverResponseGenerator::SetReresolutionResponse(
closure_arg->resolver = std::move(resolver);
closure_arg->result = std::move(result);
closure_arg->has_result = true;
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(
&closure_arg->set_response_closure, SetReresolutionResponseLocked,
closure_arg,
grpc_combiner_scheduler(closure_arg->resolver->combiner())),
closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
SetReresolutionResponseLocked, closure_arg, nullptr),
GRPC_ERROR_NONE);
}
@ -255,11 +252,9 @@ void FakeResolverResponseGenerator::UnsetReresolutionResponse() {
}
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
closure_arg->resolver = std::move(resolver);
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(
&closure_arg->set_response_closure, SetReresolutionResponseLocked,
closure_arg,
grpc_combiner_scheduler(closure_arg->resolver->combiner())),
closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
SetReresolutionResponseLocked, closure_arg, nullptr),
GRPC_ERROR_NONE);
}
@ -283,10 +278,9 @@ void FakeResolverResponseGenerator::SetFailure() {
}
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
closure_arg->resolver = std::move(resolver);
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(
&closure_arg->set_response_closure, SetFailureLocked, closure_arg,
grpc_combiner_scheduler(closure_arg->resolver->combiner())),
closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked,
closure_arg, nullptr),
GRPC_ERROR_NONE);
}
@ -300,10 +294,9 @@ void FakeResolverResponseGenerator::SetFailureOnReresolution() {
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
closure_arg->resolver = std::move(resolver);
closure_arg->immediate = false;
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(
&closure_arg->set_response_closure, SetFailureLocked, closure_arg,
grpc_combiner_scheduler(closure_arg->resolver->combiner())),
closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked,
closure_arg, nullptr),
GRPC_ERROR_NONE);
}
@ -316,10 +309,9 @@ void FakeResolverResponseGenerator::SetFakeResolver(
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
closure_arg->resolver = resolver_->Ref();
closure_arg->result = std::move(result_);
GRPC_CLOSURE_SCHED(
resolver_->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetResponseLocked,
closure_arg,
grpc_combiner_scheduler(resolver_->combiner())),
closure_arg, nullptr),
GRPC_ERROR_NONE);
has_result_ = false;
}

@ -39,7 +39,7 @@ struct ResolverArgs {
/// Used to drive I/O in the name resolution process.
grpc_pollset_set* pollset_set = nullptr;
/// The combiner under which all resolver calls will be run.
grpc_combiner* combiner = nullptr;
Combiner* combiner = nullptr;
/// The result handler to be used by the resolver.
UniquePtr<Resolver::ResultHandler> result_handler;
};

@ -145,7 +145,7 @@ bool ResolverRegistry::IsValidTarget(const char* target) {
OrphanablePtr<Resolver> ResolverRegistry::CreateResolver(
const char* target, const grpc_channel_args* args,
grpc_pollset_set* pollset_set, grpc_combiner* combiner,
grpc_pollset_set* pollset_set, Combiner* combiner,
UniquePtr<Resolver::ResultHandler> result_handler) {
GPR_ASSERT(g_state != nullptr);
grpc_uri* uri = nullptr;

@ -68,7 +68,7 @@ class ResolverRegistry {
/// \a result_handler is used to return results from the resolver.
static OrphanablePtr<Resolver> CreateResolver(
const char* target, const grpc_channel_args* args,
grpc_pollset_set* pollset_set, grpc_combiner* combiner,
grpc_pollset_set* pollset_set, Combiner* combiner,
UniquePtr<Resolver::ResultHandler> result_handler);
/// Returns the default authority to pass from a client for \a target.

@ -30,6 +30,7 @@
#include "envoy/api/v2/core/address.upb.h"
#include "envoy/api/v2/core/base.upb.h"
#include "envoy/api/v2/core/health_check.upb.h"
#include "envoy/api/v2/discovery.upb.h"
#include "envoy/api/v2/eds.upb.h"
#include "envoy/api/v2/endpoint/endpoint.upb.h"
@ -91,7 +92,7 @@ bool XdsDropConfig::ShouldDrop(const UniquePtr<char>** category_name) const {
for (size_t i = 0; i < drop_category_list_.size(); ++i) {
const auto& drop_category = drop_category_list_[i];
// Generate a random number in [0, 1000000).
const int random = rand() % 1000000;
const uint32_t random = static_cast<uint32_t>(rand()) % 1000000;
if (random < drop_category.parts_per_million) {
*category_name = &drop_category.name;
return true;
@ -223,6 +224,13 @@ namespace {
grpc_error* ServerAddressParseAndAppend(
const envoy_api_v2_endpoint_LbEndpoint* lb_endpoint,
ServerAddressList* list) {
// If health_status is not HEALTHY or UNKNOWN, skip this endpoint.
const int32_t health_status =
envoy_api_v2_endpoint_LbEndpoint_health_status(lb_endpoint);
if (health_status != envoy_api_v2_core_UNKNOWN &&
health_status != envoy_api_v2_core_HEALTHY) {
return GRPC_ERROR_NONE;
}
// Find the ip:port.
const envoy_api_v2_endpoint_Endpoint* endpoint =
envoy_api_v2_endpoint_LbEndpoint_endpoint(lb_endpoint);

@ -92,6 +92,7 @@ class XdsClient::ChannelState::RetryableCall
private:
void StartNewCallLocked();
void StartRetryTimerLocked();
static void OnRetryTimer(void* arg, grpc_error* error);
static void OnRetryTimerLocked(void* arg, grpc_error* error);
// The wrapped xds call that talks to the xds server. It's instantiated
@ -125,6 +126,8 @@ class XdsClient::ChannelState::AdsCallState
bool seen_response() const { return seen_response_; }
private:
static void OnResponseReceived(void* arg, grpc_error* error);
static void OnStatusReceived(void* arg, grpc_error* error);
static void OnResponseReceivedLocked(void* arg, grpc_error* error);
static void OnStatusReceivedLocked(void* arg, grpc_error* error);
@ -177,10 +180,6 @@ class XdsClient::ChannelState::LrsCallState
public:
Reporter(RefCountedPtr<LrsCallState> parent, grpc_millis report_interval)
: parent_(std::move(parent)), report_interval_(report_interval) {
GRPC_CLOSURE_INIT(&on_next_report_timer_, OnNextReportTimerLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
GRPC_CLOSURE_INIT(&on_report_done_, OnReportDoneLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
ScheduleNextReportLocked();
}
@ -188,8 +187,10 @@ class XdsClient::ChannelState::LrsCallState
private:
void ScheduleNextReportLocked();
static void OnNextReportTimer(void* arg, grpc_error* error);
static void OnNextReportTimerLocked(void* arg, grpc_error* error);
void SendReportLocked();
static void OnReportDone(void* arg, grpc_error* error);
static void OnReportDoneLocked(void* arg, grpc_error* error);
bool IsCurrentReporterOnCall() const {
@ -209,6 +210,9 @@ class XdsClient::ChannelState::LrsCallState
grpc_closure on_report_done_;
};
static void OnInitialRequestSent(void* arg, grpc_error* error);
static void OnResponseReceived(void* arg, grpc_error* error);
static void OnStatusReceived(void* arg, grpc_error* error);
static void OnInitialRequestSentLocked(void* arg, grpc_error* error);
static void OnResponseReceivedLocked(void* arg, grpc_error* error);
static void OnStatusReceivedLocked(void* arg, grpc_error* error);
@ -253,8 +257,7 @@ class XdsClient::ChannelState::StateWatcher
: public AsyncConnectivityStateWatcherInterface {
public:
explicit StateWatcher(RefCountedPtr<ChannelState> parent)
: AsyncConnectivityStateWatcherInterface(
grpc_combiner_scheduler(parent->xds_client()->combiner_)),
: AsyncConnectivityStateWatcherInterface(parent->xds_client()->combiner_),
parent_(std::move(parent)) {}
private:
@ -421,8 +424,6 @@ XdsClient::ChannelState::RetryableCall<T>::RetryableCall(
.set_multiplier(GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER)
.set_jitter(GRPC_XDS_RECONNECT_JITTER)
.set_max_backoff(GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) {
GRPC_CLOSURE_INIT(&on_retry_timer_, OnRetryTimerLocked, this,
grpc_combiner_scheduler(chand_->xds_client()->combiner_));
StartNewCallLocked();
}
@ -476,10 +477,22 @@ void XdsClient::ChannelState::RetryableCall<T>::StartRetryTimerLocked() {
chand()->xds_client(), chand(), timeout);
}
this->Ref(DEBUG_LOCATION, "RetryableCall+retry_timer_start").release();
GRPC_CLOSURE_INIT(&on_retry_timer_, OnRetryTimer, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&retry_timer_, next_attempt_time, &on_retry_timer_);
retry_timer_callback_pending_ = true;
}
template <typename T>
void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimer(
void* arg, grpc_error* error) {
RetryableCall* calld = static_cast<RetryableCall*>(arg);
calld->chand_->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&calld->on_retry_timer_, OnRetryTimerLocked, calld,
nullptr),
GRPC_ERROR_REF(error));
}
template <typename T>
void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
void* arg, grpc_error* error) {
@ -528,10 +541,6 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
// Init other data associated with the call.
grpc_metadata_array_init(&initial_metadata_recv_);
grpc_metadata_array_init(&trailing_metadata_recv_);
GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceivedLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceivedLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
// Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO,
@ -575,6 +584,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
op->reserved = nullptr;
op++;
Ref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked").release();
GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
&on_response_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -590,6 +601,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
// This callback signals the end of the call, so it relies on the initial
// ref instead of a new ref. When it's invoked, it's the initial ref that is
// unreffed.
GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
&on_status_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -616,6 +629,15 @@ void XdsClient::ChannelState::AdsCallState::Orphan() {
// corresponding unref happens in on_status_received_ instead of here.
}
void XdsClient::ChannelState::AdsCallState::OnResponseReceived(
void* arg, grpc_error* error) {
AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
ads_calld->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&ads_calld->on_response_received_,
OnResponseReceivedLocked, ads_calld, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked(
void* arg, grpc_error* error) {
AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
@ -714,8 +736,11 @@ void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked(
}
}
// Start load reporting if needed.
LrsCallState* lrs_calld = ads_calld->chand()->lrs_calld_->calld();
if (lrs_calld != nullptr) lrs_calld->MaybeStartReportingLocked();
auto& lrs_call = ads_calld->chand()->lrs_calld_;
if (lrs_call != nullptr) {
LrsCallState* lrs_calld = lrs_call->calld();
if (lrs_calld != nullptr) lrs_calld->MaybeStartReportingLocked();
}
// Ignore identical update.
const EdsUpdate& prev_update = xds_client->cluster_state_.eds_update;
const bool priority_list_changed =
@ -754,11 +779,22 @@ void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked(
op.reserved = nullptr;
GPR_ASSERT(ads_calld->call_ != nullptr);
// Reuse the "ADS+OnResponseReceivedLocked" ref taken in ctor.
GRPC_CLOSURE_INIT(&ads_calld->on_response_received_, OnResponseReceived,
ads_calld, grpc_schedule_on_exec_ctx);
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
ads_calld->call_, &op, 1, &ads_calld->on_response_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
void XdsClient::ChannelState::AdsCallState::OnStatusReceived(
void* arg, grpc_error* error) {
AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
ads_calld->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&ads_calld->on_status_received_, OnStatusReceivedLocked,
ads_calld, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked(
void* arg, grpc_error* error) {
AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
@ -804,11 +840,22 @@ void XdsClient::ChannelState::LrsCallState::Reporter::Orphan() {
void XdsClient::ChannelState::LrsCallState::Reporter::
ScheduleNextReportLocked() {
const grpc_millis next_report_time = ExecCtx::Get()->Now() + report_interval_;
GRPC_CLOSURE_INIT(&on_next_report_timer_, OnNextReportTimer, this,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&next_report_timer_, next_report_time,
&on_next_report_timer_);
next_report_timer_callback_pending_ = true;
}
void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimer(
void* arg, grpc_error* error) {
Reporter* self = static_cast<Reporter*>(arg);
self->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&self->on_next_report_timer_, OnNextReportTimerLocked,
self, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
void* arg, grpc_error* error) {
Reporter* self = static_cast<Reporter*>(arg);
@ -848,6 +895,8 @@ void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
memset(&op, 0, sizeof(op));
op.op = GRPC_OP_SEND_MESSAGE;
op.data.send_message.send_message = parent_->send_message_payload_;
GRPC_CLOSURE_INIT(&on_report_done_, OnReportDone, this,
grpc_schedule_on_exec_ctx);
grpc_call_error call_error = grpc_call_start_batch_and_execute(
parent_->call_, &op, 1, &on_report_done_);
if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
@ -858,6 +907,15 @@ void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
}
}
void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDone(
void* arg, grpc_error* error) {
Reporter* self = static_cast<Reporter*>(arg);
self->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&self->on_report_done_, OnReportDoneLocked, self,
nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
void* arg, grpc_error* error) {
Reporter* self = static_cast<Reporter*>(arg);
@ -905,12 +963,6 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
// Init other data associated with the LRS call.
grpc_metadata_array_init(&initial_metadata_recv_);
grpc_metadata_array_init(&trailing_metadata_recv_);
GRPC_CLOSURE_INIT(&on_initial_request_sent_, OnInitialRequestSentLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceivedLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceivedLocked, this,
grpc_combiner_scheduler(xds_client()->combiner_));
// Start the call.
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO,
@ -937,6 +989,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
op->reserved = nullptr;
op++;
Ref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked").release();
GRPC_CLOSURE_INIT(&on_initial_request_sent_, OnInitialRequestSent, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
&on_initial_request_sent_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -955,6 +1009,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
op->reserved = nullptr;
op++;
Ref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked").release();
GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
&on_response_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -970,6 +1026,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
// This callback signals the end of the call, so it relies on the initial
// ref instead of a new ref. When it's invoked, it's the initial ref that is
// unreffed.
GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
grpc_schedule_on_exec_ctx);
call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
&on_status_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@ -1018,6 +1076,15 @@ void XdsClient::ChannelState::LrsCallState::MaybeStartReportingLocked() {
Ref(DEBUG_LOCATION, "LRS+load_report+start"), load_reporting_interval_);
}
void XdsClient::ChannelState::LrsCallState::OnInitialRequestSent(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
lrs_calld->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&lrs_calld->on_initial_request_sent_,
OnInitialRequestSentLocked, lrs_calld, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
@ -1028,6 +1095,15 @@ void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked(
lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked");
}
void XdsClient::ChannelState::LrsCallState::OnResponseReceived(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
lrs_calld->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&lrs_calld->on_response_received_,
OnResponseReceivedLocked, lrs_calld, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
@ -1111,11 +1187,22 @@ void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked(
op.reserved = nullptr;
GPR_ASSERT(lrs_calld->call_ != nullptr);
// Reuse the "OnResponseReceivedLocked" ref taken in ctor.
GRPC_CLOSURE_INIT(&lrs_calld->on_response_received_, OnResponseReceived,
lrs_calld, grpc_schedule_on_exec_ctx);
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
lrs_calld->call_, &op, 1, &lrs_calld->on_response_received_);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
void XdsClient::ChannelState::LrsCallState::OnStatusReceived(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
lrs_calld->xds_client()->combiner_->Run(
GRPC_CLOSURE_INIT(&lrs_calld->on_status_received_, OnStatusReceivedLocked,
lrs_calld, nullptr),
GRPC_ERROR_REF(error));
}
void XdsClient::ChannelState::LrsCallState::OnStatusReceivedLocked(
void* arg, grpc_error* error) {
LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
@ -1162,8 +1249,7 @@ UniquePtr<char> GenerateBuildVersionString() {
} // namespace
XdsClient::XdsClient(grpc_combiner* combiner,
grpc_pollset_set* interested_parties,
XdsClient::XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
StringView server_name,
UniquePtr<ServiceConfigWatcherInterface> watcher,
const grpc_channel_args& channel_args, grpc_error** error)
@ -1190,8 +1276,8 @@ XdsClient::XdsClient(grpc_combiner* combiner,
// TODO(juanlishen): Start LDS call and do not return service config
// until we get the first LDS response.
GRPC_CLOSURE_INIT(&service_config_notify_, NotifyOnServiceConfig,
Ref().release(), grpc_combiner_scheduler(combiner_));
GRPC_CLOSURE_SCHED(&service_config_notify_, GRPC_ERROR_NONE);
Ref().release(), nullptr);
combiner_->Run(&service_config_notify_, GRPC_ERROR_NONE);
}
}
@ -1236,14 +1322,18 @@ void XdsClient::CancelEndpointDataWatch(StringView cluster,
}
}
void XdsClient::AddClientStats(StringView cluster,
void XdsClient::AddClientStats(StringView lrs_server, StringView cluster,
XdsClientStats* client_stats) {
// TODO(roth): When we add support for direct federation, use the
// server name specified in lrs_server.
cluster_state_.client_stats.insert(client_stats);
chand_->MaybeStartLrsCall();
}
void XdsClient::RemoveClientStats(StringView cluster,
void XdsClient::RemoveClientStats(StringView lrs_server, StringView cluster,
XdsClientStats* client_stats) {
// TODO(roth): When we add support for direct federation, use the
// server name specified in lrs_server.
// TODO(roth): In principle, we should try to send a final load report
// containing whatever final stats have been accumulated since the
// last load report.
@ -1282,7 +1372,9 @@ void XdsClient::NotifyOnServiceConfig(void* arg, grpc_error* error) {
static const char* json =
"{\n"
" \"loadBalancingConfig\":[\n"
" { \"xds_experimental\":{} }\n"
" { \"xds_experimental\":{\n"
" \"lrsLoadReportingServerName\": \"\"\n"
" } }\n"
" ]\n"
"}";
RefCountedPtr<ServiceConfig> service_config =

@ -71,7 +71,7 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
// If *error is not GRPC_ERROR_NONE after construction, then there was
// an error initializing the client.
XdsClient(grpc_combiner* combiner, grpc_pollset_set* interested_parties,
XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
StringView server_name,
UniquePtr<ServiceConfigWatcherInterface> watcher,
const grpc_channel_args& channel_args, grpc_error** error);
@ -100,8 +100,10 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
EndpointWatcherInterface* watcher);
// Adds and removes client stats for cluster.
void AddClientStats(StringView cluster, XdsClientStats* client_stats);
void RemoveClientStats(StringView cluster, XdsClientStats* client_stats);
void AddClientStats(StringView lrs_server, StringView cluster,
XdsClientStats* client_stats);
void RemoveClientStats(StringView lrs_server, StringView cluster,
XdsClientStats* client_stats);
// Resets connection backoff state.
void ResetBackoff();
@ -194,7 +196,7 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
UniquePtr<char> build_version_;
grpc_combiner* combiner_;
Combiner* combiner_;
grpc_pollset_set* interested_parties_;
UniquePtr<XdsBootstrap> bootstrap_;
@ -208,8 +210,9 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
// The channel for communicating with the xds server.
OrphanablePtr<ChannelState> chand_;
// TODO(roth): When we need support for multiple clusters, replace
// cluster_state_ with a map keyed by cluster name.
// TODO(juanlishen): As part of adding CDS support, replace
// cluster_state_ with a map keyed by cluster name, so that we can
// support multiple clusters for both CDS and EDS.
ClusterState cluster_state_;
// Map<StringView /*cluster*/, ClusterState, StringLess> clusters_;

@ -104,11 +104,14 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false,
/* forward declarations of various callbacks that we'll build closures around */
static void write_action_begin_locked(void* t, grpc_error* error);
static void write_action(void* t, grpc_error* error);
static void write_action_end(void* t, grpc_error* error);
static void write_action_end_locked(void* t, grpc_error* error);
static void read_action(void* t, grpc_error* error);
static void read_action_locked(void* t, grpc_error* error);
static void continue_read_action_locked(grpc_chttp2_transport* t);
static void complete_fetch(void* gs, grpc_error* error);
static void complete_fetch_locked(void* gs, grpc_error* error);
/** Set a transport level setting, and push it to our peer */
static void queue_setting_update(grpc_chttp2_transport* t,
@ -124,6 +127,8 @@ static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
const char* reason);
static void benign_reclaimer(void* t, grpc_error* error);
static void destructive_reclaimer(void* t, grpc_error* error);
static void benign_reclaimer_locked(void* t, grpc_error* error);
static void destructive_reclaimer_locked(void* t, grpc_error* error);
@ -134,8 +139,11 @@ static void close_transport_locked(grpc_chttp2_transport* t, grpc_error* error);
static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error);
static void schedule_bdp_ping_locked(grpc_chttp2_transport* t);
static void start_bdp_ping(void* tp, grpc_error* error);
static void finish_bdp_ping(void* tp, grpc_error* error);
static void start_bdp_ping_locked(void* tp, grpc_error* error);
static void finish_bdp_ping_locked(void* tp, grpc_error* error);
static void next_bdp_ping_timer_expired(void* tp, grpc_error* error);
static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error);
static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error);
@ -145,9 +153,13 @@ static void send_ping_locked(grpc_chttp2_transport* t,
static void retry_initiate_ping_locked(void* tp, grpc_error* error);
/** keepalive-relevant functions */
static void init_keepalive_ping(void* arg, grpc_error* error);
static void init_keepalive_ping_locked(void* arg, grpc_error* error);
static void start_keepalive_ping(void* arg, grpc_error* error);
static void finish_keepalive_ping(void* arg, grpc_error* error);
static void start_keepalive_ping_locked(void* arg, grpc_error* error);
static void finish_keepalive_ping_locked(void* arg, grpc_error* error);
static void keepalive_watchdog_fired(void* arg, grpc_error* error);
static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error);
static void reset_byte_stream(void* arg, grpc_error* error);
@ -377,36 +389,6 @@ static bool read_channel_args(grpc_chttp2_transport* t,
return enable_bdp;
}
static void init_transport_closures(grpc_chttp2_transport* t) {
GRPC_CLOSURE_INIT(&t->read_action_locked, read_action_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->benign_reclaimer_locked, benign_reclaimer_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->destructive_reclaimer_locked,
destructive_reclaimer_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->retry_initiate_ping_locked, retry_initiate_ping_locked,
t, grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->start_bdp_ping_locked, start_bdp_ping_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked,
next_bdp_ping_timer_expired_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping_locked,
t, grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping_locked, t,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&t->keepalive_watchdog_fired_locked,
keepalive_watchdog_fired_locked, t,
grpc_combiner_scheduler(t->combiner));
}
static void init_transport_keepalive_settings(grpc_chttp2_transport* t) {
if (t->is_client) {
t->keepalive_time = g_default_client_keepalive_time_ms == INT_MAX
@ -442,6 +424,8 @@ static void init_keepalive_pings_if_enabled(grpc_chttp2_transport* t) {
if (t->keepalive_time != GRPC_MILLIS_INF_FUTURE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping, t,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->keepalive_ping_timer,
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
@ -494,8 +478,6 @@ grpc_chttp2_transport::grpc_chttp2_transport(
grpc_chttp2_hpack_parser_init(&hpack_parser);
grpc_chttp2_goaway_parser_init(&goaway_parser);
init_transport_closures(this);
/* configure http2 the way we like it */
if (is_client) {
queue_setting_update(this, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
@ -556,9 +538,8 @@ static void destroy_transport_locked(void* tp, grpc_error* error) {
static void destroy_transport(grpc_transport* gt) {
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
t->combiner->Run(GRPC_CLOSURE_CREATE(destroy_transport_locked, t, nullptr),
GRPC_ERROR_NONE);
}
static void close_transport_locked(grpc_chttp2_transport* t,
@ -669,11 +650,7 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t,
grpc_slice_buffer_init(&frame_storage);
grpc_slice_buffer_init(&unprocessed_incoming_frames_buffer);
grpc_slice_buffer_init(&flow_controlled_buffer);
GRPC_CLOSURE_INIT(&complete_fetch_locked, ::complete_fetch_locked, this,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&reset_byte_stream, ::reset_byte_stream, this,
grpc_combiner_scheduler(t->combiner));
GRPC_CLOSURE_INIT(&reset_byte_stream, ::reset_byte_stream, this, nullptr);
}
grpc_chttp2_stream::~grpc_chttp2_stream() {
@ -766,9 +743,8 @@ static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
}
s->destroy_stream_arg = then_schedule_closure;
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
grpc_combiner_scheduler(t->combiner)),
t->combiner->Run(
GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s, nullptr),
GRPC_ERROR_NONE);
}
@ -929,10 +905,9 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
* Also, 'write_action_begin_locked' only gathers the bytes into outbuf.
* It does not call the endpoint to write the bytes. That is done by the
* 'write_action' (which is scheduled by 'write_action_begin_locked') */
GRPC_CLOSURE_SCHED(
t->combiner->FinallyRun(
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
write_action_begin_locked, t, nullptr),
GRPC_ERROR_NONE);
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING:
@ -1006,11 +981,18 @@ static void write_action(void* gt, grpc_error* error) {
t->cl = nullptr;
grpc_endpoint_write(
t->ep, &t->outbuf,
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end_locked, t,
grpc_combiner_scheduler(t->combiner)),
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end, t,
grpc_schedule_on_exec_ctx),
cl);
}
static void write_action_end(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->write_action_end_locked,
write_action_end_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
/* Callback from the grpc_endpoint after bytes have been written by calling
* sendmsg */
static void write_action_end_locked(void* tp, grpc_error* error) {
@ -1051,10 +1033,9 @@ static void write_action_end_locked(void* tp, grpc_error* error) {
if (!closed) {
GRPC_CLOSURE_LIST_SCHED(&t->run_after_write);
}
GRPC_CLOSURE_RUN(
t->combiner->FinallyRun(
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
write_action_begin_locked, t, nullptr),
GRPC_ERROR_NONE);
break;
}
@ -1305,8 +1286,10 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
}
s->fetching_send_message.reset();
return; /* early out */
} else if (s->fetching_send_message->Next(UINT32_MAX,
&s->complete_fetch_locked)) {
} else if (s->fetching_send_message->Next(
UINT32_MAX, GRPC_CLOSURE_INIT(&s->complete_fetch_locked,
::complete_fetch, s,
grpc_schedule_on_exec_ctx))) {
grpc_error* error = s->fetching_send_message->Pull(&s->fetching_slice);
if (error != GRPC_ERROR_NONE) {
s->fetching_send_message.reset();
@ -1318,6 +1301,13 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
}
}
static void complete_fetch(void* gs, grpc_error* error) {
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(gs);
s->t->combiner->Run(GRPC_CLOSURE_INIT(&s->complete_fetch_locked,
::complete_fetch_locked, s, nullptr),
GRPC_ERROR_REF(error));
}
static void complete_fetch_locked(void* gs, grpc_error* error) {
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(gs);
grpc_chttp2_transport* t = s->t;
@ -1668,10 +1658,9 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
GRPC_CHTTP2_STREAM_REF(s, "perform_stream_op");
op->handler_private.extra_arg = gs;
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&op->handler_private.closure, perform_stream_op_locked,
op, grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
t->combiner->Run(GRPC_CLOSURE_INIT(&op->handler_private.closure,
perform_stream_op_locked, op, nullptr),
GRPC_ERROR_NONE);
}
static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error) {
@ -1707,24 +1696,45 @@ static void send_ping_locked(grpc_chttp2_transport* t,
*/
static void send_keepalive_ping_locked(grpc_chttp2_transport* t) {
if (t->closed_with_error != GRPC_ERROR_NONE) {
GRPC_CLOSURE_RUN(&t->start_keepalive_ping_locked,
GRPC_ERROR_REF(t->closed_with_error));
GRPC_CLOSURE_RUN(&t->finish_keepalive_ping_locked,
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(t->closed_with_error));
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(t->closed_with_error));
return;
}
grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) {
/* There is a ping in flight. Add yourself to the inflight closure list. */
GRPC_CLOSURE_RUN(&t->start_keepalive_ping_locked, GRPC_ERROR_NONE);
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT],
&t->finish_keepalive_ping_locked, GRPC_ERROR_NONE);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(t->closed_with_error));
grpc_closure_list_append(
&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT],
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping, t, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
return;
}
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE],
&t->start_keepalive_ping_locked, GRPC_ERROR_NONE);
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
&t->finish_keepalive_ping_locked, GRPC_ERROR_NONE);
grpc_closure_list_append(
&pq->lists[GRPC_CHTTP2_PCL_INITIATE],
GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, start_keepalive_ping,
t, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
grpc_closure_list_append(
&pq->lists[GRPC_CHTTP2_PCL_NEXT],
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, finish_keepalive_ping,
t, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->retry_initiate_ping_locked,
retry_initiate_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void retry_initiate_ping_locked(void* tp, grpc_error* error) {
@ -1835,10 +1845,9 @@ static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
}
op->handler_private.extra_arg = gt;
GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op");
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&op->handler_private.closure,
perform_transport_op_locked, op,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
t->combiner->Run(GRPC_CLOSURE_INIT(&op->handler_private.closure,
perform_transport_op_locked, op, nullptr),
GRPC_ERROR_NONE);
}
/*******************************************************************************
@ -2479,6 +2488,13 @@ static grpc_error* try_http_parsing(grpc_chttp2_transport* t) {
return error;
}
static void read_action(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->read_action_locked, read_action_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void read_action_locked(void* tp, grpc_error* error) {
GPR_TIMER_SCOPE("reading_action_locked", 0);
@ -2576,6 +2592,8 @@ static void read_action_locked(void* tp, grpc_error* error) {
static void continue_read_action_locked(grpc_chttp2_transport* t) {
const bool urgent = t->goaway_error != GRPC_ERROR_NONE;
GRPC_CLOSURE_INIT(&t->read_action_locked, read_action, t,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent);
grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t, nullptr);
}
@ -2584,7 +2602,19 @@ static void continue_read_action_locked(grpc_chttp2_transport* t) {
// that kicks off finishes, it's unreffed
static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
t->flow_control->bdp_estimator()->SchedulePing();
send_ping_locked(t, &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
send_ping_locked(
t,
GRPC_CLOSURE_INIT(&t->start_bdp_ping_locked, start_bdp_ping, t,
grpc_schedule_on_exec_ctx),
GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping, t,
grpc_schedule_on_exec_ctx));
}
static void start_bdp_ping(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_bdp_ping_locked,
start_bdp_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void start_bdp_ping_locked(void* tp, grpc_error* error) {
@ -2601,6 +2631,14 @@ static void start_bdp_ping_locked(void* tp, grpc_error* error) {
grpc_timer_cancel(&t->keepalive_ping_timer);
}
t->flow_control->bdp_estimator()->StartPing();
t->bdp_ping_started = true;
}
static void finish_bdp_ping(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked,
finish_bdp_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
@ -2613,15 +2651,34 @@ static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return;
}
if (!t->bdp_ping_started) {
/* start_bdp_ping_locked has not been run yet. Schedule
* finish_bdp_ping_locked to be run later. */
t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked,
finish_bdp_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
return;
}
t->bdp_ping_started = false;
grpc_millis next_ping = t->flow_control->bdp_estimator()->CompletePing();
grpc_chttp2_act_on_flowctl_action(t->flow_control->PeriodicUpdate(), t,
nullptr);
GPR_ASSERT(!t->have_next_bdp_ping_timer);
t->have_next_bdp_ping_timer = true;
GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked,
next_bdp_ping_timer_expired, t, grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->next_bdp_ping_timer, next_ping,
&t->next_bdp_ping_timer_expired_locked);
}
static void next_bdp_ping_timer_expired(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked,
next_bdp_ping_timer_expired_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
GPR_ASSERT(t->have_next_bdp_ping_timer);
@ -2700,6 +2757,13 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
}
}
static void init_keepalive_ping(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked,
init_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
@ -2715,6 +2779,8 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
} else {
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping, t,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->keepalive_ping_timer,
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
@ -2722,6 +2788,8 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
} else if (error == GRPC_ERROR_CANCELLED) {
/* The keepalive ping timer may be cancelled by bdp */
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping, t,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->keepalive_ping_timer,
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
@ -2729,6 +2797,13 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping");
}
static void start_keepalive_ping(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (error != GRPC_ERROR_NONE) {
@ -2741,9 +2816,19 @@ static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
gpr_log(GPR_INFO, "%s: Start keepalive ping", t->peer_string);
}
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
GRPC_CLOSURE_INIT(&t->keepalive_watchdog_fired_locked,
keepalive_watchdog_fired, t, grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->keepalive_watchdog_timer,
grpc_core::ExecCtx::Get()->Now() + t->keepalive_timeout,
&t->keepalive_watchdog_fired_locked);
t->keepalive_ping_started = true;
}
static void finish_keepalive_ping(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
@ -2753,9 +2838,21 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "%s: Finish keepalive ping", t->peer_string);
}
if (!t->keepalive_ping_started) {
/* start_keepalive_ping_locked has not run yet. Reschedule
* finish_keepalive_ping_locked for it to be run later. */
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
return;
}
t->keepalive_ping_started = false;
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
grpc_timer_cancel(&t->keepalive_watchdog_timer);
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping, t,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->keepalive_ping_timer,
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
@ -2764,6 +2861,14 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive ping end");
}
static void keepalive_watchdog_fired(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->keepalive_watchdog_fired_locked,
keepalive_watchdog_fired_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
@ -2864,10 +2969,9 @@ void Chttp2IncomingByteStream::OrphanLocked(void* arg,
void Chttp2IncomingByteStream::Orphan() {
GPR_TIMER_SCOPE("incoming_byte_stream_destroy", 0);
GRPC_CLOSURE_SCHED(
transport_->combiner->Run(
GRPC_CLOSURE_INIT(&destroy_action_,
&Chttp2IncomingByteStream::OrphanLocked, this,
grpc_combiner_scheduler(transport_->combiner)),
&Chttp2IncomingByteStream::OrphanLocked, this, nullptr),
GRPC_ERROR_NONE);
}
@ -2924,10 +3028,9 @@ bool Chttp2IncomingByteStream::Next(size_t max_size_hint,
Ref();
next_action_.max_size_hint = max_size_hint;
next_action_.on_complete = on_complete;
GRPC_CLOSURE_SCHED(
transport_->combiner->Run(
GRPC_CLOSURE_INIT(&next_action_.closure,
&Chttp2IncomingByteStream::NextLocked, this,
grpc_combiner_scheduler(transport_->combiner)),
&Chttp2IncomingByteStream::NextLocked, this, nullptr),
GRPC_ERROR_NONE);
return false;
}
@ -2980,7 +3083,8 @@ grpc_error* Chttp2IncomingByteStream::Pull(grpc_slice* slice) {
}
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error));
stream_->t->combiner->Run(&stream_->reset_byte_stream,
GRPC_ERROR_REF(error));
return error;
}
return GRPC_ERROR_NONE;
@ -3000,7 +3104,8 @@ grpc_error* Chttp2IncomingByteStream::Push(const grpc_slice& slice,
if (remaining_bytes_ < GRPC_SLICE_LENGTH(slice)) {
grpc_error* error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream");
GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error));
transport_->combiner->Run(&stream_->reset_byte_stream,
GRPC_ERROR_REF(error));
grpc_slice_unref_internal(slice);
return error;
} else {
@ -3020,7 +3125,8 @@ grpc_error* Chttp2IncomingByteStream::Finished(grpc_error* error,
}
}
if (error != GRPC_ERROR_NONE && reset_on_error) {
GRPC_CLOSURE_SCHED(&stream_->reset_byte_stream, GRPC_ERROR_REF(error));
transport_->combiner->Run(&stream_->reset_byte_stream,
GRPC_ERROR_REF(error));
}
Unref();
return error;
@ -3040,6 +3146,8 @@ static void post_benign_reclaimer(grpc_chttp2_transport* t) {
if (!t->benign_reclaimer_registered) {
t->benign_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer");
GRPC_CLOSURE_INIT(&t->benign_reclaimer_locked, benign_reclaimer, t,
grpc_schedule_on_exec_ctx);
grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
false, &t->benign_reclaimer_locked);
}
@ -3049,11 +3157,20 @@ static void post_destructive_reclaimer(grpc_chttp2_transport* t) {
if (!t->destructive_reclaimer_registered) {
t->destructive_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer");
GRPC_CLOSURE_INIT(&t->destructive_reclaimer_locked, destructive_reclaimer,
t, grpc_schedule_on_exec_ctx);
grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
true, &t->destructive_reclaimer_locked);
}
}
static void benign_reclaimer(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->benign_reclaimer_locked,
benign_reclaimer_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void benign_reclaimer_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (error == GRPC_ERROR_NONE &&
@ -3083,6 +3200,13 @@ static void benign_reclaimer_locked(void* arg, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "benign_reclaimer");
}
static void destructive_reclaimer(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
t->combiner->Run(GRPC_CLOSURE_INIT(&t->destructive_reclaimer_locked,
destructive_reclaimer_locked, t, nullptr),
GRPC_ERROR_REF(error));
}
static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
@ -3209,5 +3333,7 @@ void grpc_chttp2_transport_start_reading(
gpr_free(read_buffer);
}
t->notify_on_receive_settings = notify_on_receive_settings;
GRPC_CLOSURE_SCHED(&t->read_action_locked, GRPC_ERROR_NONE);
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->read_action_locked, read_action_locked, t, nullptr),
GRPC_ERROR_NONE);
}

@ -1741,9 +1741,8 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
however -- it might be that we receive a RST_STREAM following this
and can avoid the extra write */
GRPC_CHTTP2_STREAM_REF(s, "final_rst");
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(force_client_rst_stream, s,
grpc_combiner_finally_scheduler(t->combiner)),
t->combiner->FinallyRun(
GRPC_CLOSURE_CREATE(force_client_rst_stream, s, nullptr),
GRPC_ERROR_NONE);
}
grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);

@ -300,7 +300,7 @@ struct grpc_chttp2_transport {
grpc_resource_user* resource_user;
grpc_combiner* combiner;
grpc_core::Combiner* combiner;
grpc_closure* notify_on_receive_settings = nullptr;
@ -459,6 +459,8 @@ struct grpc_chttp2_transport {
/* next bdp ping timer */
bool have_next_bdp_ping_timer = false;
/** If start_bdp_ping_locked has been called */
bool bdp_ping_started = false;
grpc_timer next_bdp_ping_timer;
/* keep-alive ping support */
@ -480,6 +482,8 @@ struct grpc_chttp2_transport {
grpc_millis keepalive_timeout;
/** if keepalive pings are allowed when there's no outstanding streams */
bool keepalive_permit_without_calls = false;
/** If start_keepalive_ping_locked has been called */
bool keepalive_ping_started = false;
/** keep-alive state machine state */
grpc_chttp2_keepalive_state keepalive_state;
grpc_core::ContextList* cl = nullptr;
@ -862,4 +866,6 @@ void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client);
void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error* error);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */

@ -96,6 +96,9 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
if (!t->ping_state.is_delayed_ping_timer_set) {
t->ping_state.is_delayed_ping_timer_set = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "retry_initiate_ping_locked");
GRPC_CLOSURE_INIT(&t->retry_initiate_ping_locked,
grpc_chttp2_retry_initiate_ping, t,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&t->ping_state.delayed_ping_timer, next_allowed_ping,
&t->retry_initiate_ping_locked);
}

@ -45,42 +45,16 @@ grpc_core::DebugOnlyTraceFlag grpc_combiner_trace(false, "combiner");
#define STATE_UNORPHANED 1
#define STATE_ELEM_COUNT_LOW_BIT 2
struct grpc_combiner {
grpc_combiner* next_combiner_on_this_exec_ctx = nullptr;
grpc_closure_scheduler scheduler;
grpc_closure_scheduler finally_scheduler;
grpc_core::MultiProducerSingleConsumerQueue queue;
// either:
// a pointer to the initiating exec ctx if that is the only exec_ctx that has
// ever queued to this combiner, or NULL. If this is non-null, it's not
// dereferencable (since the initiating exec_ctx may have gone out of scope)
gpr_atm initiating_exec_ctx_or_null;
// state is:
// lower bit - zero if orphaned (STATE_UNORPHANED)
// other bits - number of items queued on the lock (STATE_ELEM_COUNT_LOW_BIT)
gpr_atm state;
bool time_to_execute_final_list = false;
grpc_closure_list final_list;
grpc_closure offload;
gpr_refcount refs;
};
static void combiner_run(grpc_closure* closure, grpc_error* error);
static void combiner_exec(grpc_closure* closure, grpc_error* error);
static void combiner_finally_exec(grpc_closure* closure, grpc_error* error);
static const grpc_closure_scheduler_vtable scheduler = {
combiner_run, combiner_exec, "combiner:immediately"};
static const grpc_closure_scheduler_vtable finally_scheduler = {
combiner_finally_exec, combiner_finally_exec, "combiner:finally"};
static void combiner_exec(grpc_core::Combiner* lock, grpc_closure* closure,
grpc_error* error);
static void combiner_finally_exec(grpc_core::Combiner* lock,
grpc_closure* closure, grpc_error* error);
static void offload(void* arg, grpc_error* error);
grpc_combiner* grpc_combiner_create(void) {
grpc_combiner* lock = grpc_core::New<grpc_combiner>();
grpc_core::Combiner* grpc_combiner_create(void) {
grpc_core::Combiner* lock = grpc_core::New<grpc_core::Combiner>();
gpr_ref_init(&lock->refs, 1);
lock->scheduler.vtable = &scheduler;
lock->finally_scheduler.vtable = &finally_scheduler;
gpr_atm_no_barrier_store(&lock->state, STATE_UNORPHANED);
grpc_closure_list_init(&lock->final_list);
GRPC_CLOSURE_INIT(
@ -90,13 +64,13 @@ grpc_combiner* grpc_combiner_create(void) {
return lock;
}
static void really_destroy(grpc_combiner* lock) {
static void really_destroy(grpc_core::Combiner* lock) {
GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p really_destroy", lock));
GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0);
grpc_core::Delete(lock);
}
static void start_destroy(grpc_combiner* lock) {
static void start_destroy(grpc_core::Combiner* lock) {
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED);
GRPC_COMBINER_TRACE(gpr_log(
GPR_INFO, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state));
@ -117,20 +91,21 @@ static void start_destroy(grpc_combiner* lock) {
#define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif
void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
void grpc_combiner_unref(grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM("UNREF", -1);
if (gpr_unref(&lock->refs)) {
start_destroy(lock);
}
}
grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
grpc_core::Combiner* grpc_combiner_ref(
grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM(" REF", 1);
gpr_ref(&lock->refs);
return lock;
}
static void push_last_on_exec_ctx(grpc_combiner* lock) {
static void push_last_on_exec_ctx(grpc_core::Combiner* lock) {
lock->next_combiner_on_this_exec_ctx = nullptr;
if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
grpc_core::ExecCtx::Get()->combiner_data()->active_combiner =
@ -143,7 +118,7 @@ static void push_last_on_exec_ctx(grpc_combiner* lock) {
}
}
static void push_first_on_exec_ctx(grpc_combiner* lock) {
static void push_first_on_exec_ctx(grpc_core::Combiner* lock) {
lock->next_combiner_on_this_exec_ctx =
grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
grpc_core::ExecCtx::Get()->combiner_data()->active_combiner = lock;
@ -152,14 +127,10 @@ static void push_first_on_exec_ctx(grpc_combiner* lock) {
}
}
#define COMBINER_FROM_CLOSURE_SCHEDULER(closure, scheduler_name) \
((grpc_combiner*)(((char*)((closure)->scheduler)) - \
offsetof(grpc_combiner, scheduler_name)))
static void combiner_exec(grpc_closure* cl, grpc_error* error) {
static void combiner_exec(grpc_core::Combiner* lock, grpc_closure* cl,
grpc_error* error) {
GPR_TIMER_SCOPE("combiner.execute", 0);
GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS();
grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(cl, scheduler);
gpr_atm last = gpr_atm_full_fetch_add(&lock->state, STATE_ELEM_COUNT_LOW_BIT);
GRPC_COMBINER_TRACE(gpr_log(GPR_INFO,
"C:%p grpc_combiner_execute c=%p last=%" PRIdPTR,
@ -198,11 +169,11 @@ static void move_next() {
}
static void offload(void* arg, grpc_error* error) {
grpc_combiner* lock = static_cast<grpc_combiner*>(arg);
grpc_core::Combiner* lock = static_cast<grpc_core::Combiner*>(arg);
push_last_on_exec_ctx(lock);
}
static void queue_offload(grpc_combiner* lock) {
static void queue_offload(grpc_core::Combiner* lock) {
GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED();
move_next();
GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p queue_offload", lock));
@ -211,7 +182,7 @@ static void queue_offload(grpc_combiner* lock) {
bool grpc_combiner_continue_exec_ctx() {
GPR_TIMER_SCOPE("combiner.continue_exec_ctx", 0);
grpc_combiner* lock =
grpc_core::Combiner* lock =
grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
if (lock == nullptr) {
return false;
@ -329,19 +300,20 @@ bool grpc_combiner_continue_exec_ctx() {
static void enqueue_finally(void* closure, grpc_error* error);
static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
static void combiner_finally_exec(grpc_core::Combiner* lock,
grpc_closure* closure, grpc_error* error) {
GPR_ASSERT(lock != nullptr);
GPR_TIMER_SCOPE("combiner.execute_finally", 0);
GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS();
grpc_combiner* lock =
COMBINER_FROM_CLOSURE_SCHEDULER(closure, finally_scheduler);
GRPC_COMBINER_TRACE(gpr_log(
GPR_INFO, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock, closure,
grpc_core::ExecCtx::Get()->combiner_data()->active_combiner));
if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner != lock) {
GPR_TIMER_MARK("slowpath", 0);
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(enqueue_finally, closure,
grpc_combiner_scheduler(lock)),
error);
// Reusing scheduler to store the combiner so that it can be accessed in
// enqueue_finally
closure->scheduler = reinterpret_cast<grpc_closure_scheduler*>(lock);
lock->Run(GRPC_CLOSURE_CREATE(enqueue_finally, closure, nullptr), error);
return;
}
@ -351,32 +323,24 @@ static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
grpc_closure_list_append(&lock->final_list, closure, error);
}
static void combiner_run(grpc_closure* closure, grpc_error* error) {
grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(closure, scheduler);
#ifndef NDEBUG
closure->scheduled = false;
GRPC_COMBINER_TRACE(gpr_log(
GPR_DEBUG,
"Combiner:%p grpc_combiner_run closure:%p created [%s:%d] run [%s:%d]",
lock, closure, closure->file_created, closure->line_created,
closure->file_initiated, closure->line_initiated));
#endif
GPR_ASSERT(grpc_core::ExecCtx::Get()->combiner_data()->active_combiner ==
lock);
closure->cb(closure->cb_arg, error);
GRPC_ERROR_UNREF(error);
}
static void enqueue_finally(void* closure, grpc_error* error) {
combiner_finally_exec(static_cast<grpc_closure*>(closure),
GRPC_ERROR_REF(error));
grpc_closure* cl = static_cast<grpc_closure*>(closure);
combiner_finally_exec(reinterpret_cast<grpc_core::Combiner*>(cl->scheduler),
cl, GRPC_ERROR_REF(error));
}
grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* combiner) {
return &combiner->scheduler;
namespace grpc_core {
void Combiner::Run(grpc_closure* closure, grpc_error* error) {
GPR_ASSERT(closure->scheduler == nullptr ||
closure->scheduler ==
reinterpret_cast<grpc_closure_scheduler*>(this));
combiner_exec(this, closure, error);
}
grpc_closure_scheduler* grpc_combiner_finally_scheduler(
grpc_combiner* combiner) {
return &combiner->finally_scheduler;
void Combiner::FinallyRun(grpc_closure* closure, grpc_error* error) {
GPR_ASSERT(closure->scheduler == nullptr ||
closure->scheduler ==
reinterpret_cast<grpc_closure_scheduler*>(this));
combiner_finally_exec(this, closure, error);
}
} // namespace grpc_core

@ -27,6 +27,34 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/exec_ctx.h"
namespace grpc_core {
// TODO(yashkt) : Remove this class and replace it with a class that does not
// use ExecCtx
class Combiner {
public:
void Run(grpc_closure* closure, grpc_error* error);
// TODO(yashkt) : Remove this method
void FinallyRun(grpc_closure* closure, grpc_error* error);
Combiner* next_combiner_on_this_exec_ctx = nullptr;
grpc_closure_scheduler scheduler;
grpc_closure_scheduler finally_scheduler;
MultiProducerSingleConsumerQueue queue;
// either:
// a pointer to the initiating exec ctx if that is the only exec_ctx that has
// ever queued to this combiner, or NULL. If this is non-null, it's not
// dereferencable (since the initiating exec_ctx may have gone out of scope)
gpr_atm initiating_exec_ctx_or_null;
// state is:
// lower bit - zero if orphaned (STATE_UNORPHANED)
// other bits - number of items queued on the lock (STATE_ELEM_COUNT_LOW_BIT)
gpr_atm state;
bool time_to_execute_final_list = false;
grpc_closure_list final_list;
grpc_closure offload;
gpr_refcount refs;
};
} // namespace grpc_core
// Provides serialized access to some resource.
// Each action queued on a combiner is executed serially in a borrowed thread.
// The actual thread executing actions may change over time (but there will only
@ -34,7 +62,7 @@
// Initialize the lock, with an optional workqueue to shift load to when
// necessary
grpc_combiner* grpc_combiner_create(void);
grpc_core::Combiner* grpc_combiner_create(void);
#ifndef NDEBUG
#define GRPC_COMBINER_DEBUG_ARGS \
@ -51,12 +79,9 @@ grpc_combiner* grpc_combiner_create(void);
// Ref/unref the lock, for when we're sharing the lock ownership
// Prefer to use the macros above
grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
// Fetch a scheduler to schedule closures against
grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* lock);
// Scheduler to execute \a action within the lock just prior to unlocking.
grpc_closure_scheduler* grpc_combiner_finally_scheduler(grpc_combiner* lock);
grpc_core::Combiner* grpc_combiner_ref(
grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS);
void grpc_combiner_unref(grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS);
bool grpc_combiner_continue_exec_ctx();

@ -63,6 +63,7 @@ grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles);
grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles);
namespace grpc_core {
class Combiner;
/** Execution context.
* A bag of data that collects information along a callstack.
* It is created on the stack at core entry points (public API or iomgr), and
@ -136,9 +137,9 @@ class ExecCtx {
struct CombinerData {
/* currently active combiner: updated only via combiner.c */
grpc_combiner* active_combiner;
Combiner* active_combiner;
/* last active combiner in the active combiner list */
grpc_combiner* last_combiner;
Combiner* last_combiner;
};
/** Only to be used by grpc-combiner code */

@ -132,7 +132,7 @@ struct grpc_resource_quota {
/* Master combiner lock: all activity on a quota executes under this combiner
* (so no mutex is needed for this data structure) */
grpc_combiner* combiner;
grpc_core::Combiner* combiner;
/* Size of the resource quota */
int64_t size;
/* Amount of free memory in the resource quota */
@ -293,7 +293,8 @@ static void rq_step_sched(grpc_resource_quota* resource_quota) {
if (resource_quota->step_scheduled) return;
resource_quota->step_scheduled = true;
grpc_resource_quota_ref_internal(resource_quota);
GRPC_CLOSURE_SCHED(&resource_quota->rq_step_closure, GRPC_ERROR_NONE);
resource_quota->combiner->FinallyRun(&resource_quota->rq_step_closure,
GRPC_ERROR_NONE);
}
/* update the atomically available resource estimate - use no barriers since
@ -655,10 +656,9 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) {
(intptr_t)resource_quota);
}
GRPC_CLOSURE_INIT(&resource_quota->rq_step_closure, rq_step, resource_quota,
grpc_combiner_finally_scheduler(resource_quota->combiner));
nullptr);
GRPC_CLOSURE_INIT(&resource_quota->rq_reclamation_done_closure,
rq_reclamation_done, resource_quota,
grpc_combiner_scheduler(resource_quota->combiner));
rq_reclamation_done, resource_quota, nullptr);
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
resource_quota->roots[i] = nullptr;
}
@ -774,19 +774,15 @@ grpc_resource_user* grpc_resource_user_create(
resource_user->resource_quota =
grpc_resource_quota_ref_internal(resource_quota);
GRPC_CLOSURE_INIT(&resource_user->allocate_closure, &ru_allocate,
resource_user,
grpc_combiner_scheduler(resource_quota->combiner));
resource_user, nullptr);
GRPC_CLOSURE_INIT(&resource_user->add_to_free_pool_closure,
&ru_add_to_free_pool, resource_user,
grpc_combiner_scheduler(resource_quota->combiner));
&ru_add_to_free_pool, resource_user, nullptr);
GRPC_CLOSURE_INIT(&resource_user->post_reclaimer_closure[0],
&ru_post_benign_reclaimer, resource_user,
grpc_combiner_scheduler(resource_quota->combiner));
&ru_post_benign_reclaimer, resource_user, nullptr);
GRPC_CLOSURE_INIT(&resource_user->post_reclaimer_closure[1],
&ru_post_destructive_reclaimer, resource_user,
grpc_combiner_scheduler(resource_quota->combiner));
&ru_post_destructive_reclaimer, resource_user, nullptr);
GRPC_CLOSURE_INIT(&resource_user->destroy_closure, &ru_destroy, resource_user,
grpc_combiner_scheduler(resource_quota->combiner));
nullptr);
gpr_mu_init(&resource_user->mu);
gpr_atm_rel_store(&resource_user->refs, 1);
gpr_atm_rel_store(&resource_user->shutdown, 0);
@ -827,7 +823,8 @@ static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount) {
gpr_atm old = gpr_atm_full_fetch_add(&resource_user->refs, -amount);
GPR_ASSERT(old >= amount);
if (old == amount) {
GRPC_CLOSURE_SCHED(&resource_user->destroy_closure, GRPC_ERROR_NONE);
resource_user->resource_quota->combiner->Run(
&resource_user->destroy_closure, GRPC_ERROR_NONE);
}
}
@ -841,10 +838,8 @@ void grpc_resource_user_unref(grpc_resource_user* resource_user) {
void grpc_resource_user_shutdown(grpc_resource_user* resource_user) {
if (gpr_atm_full_fetch_add(&resource_user->shutdown, 1) == 0) {
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(
ru_shutdown, resource_user,
grpc_combiner_scheduler(resource_user->resource_quota->combiner)),
resource_user->resource_quota->combiner->Run(
GRPC_CLOSURE_CREATE(ru_shutdown, resource_user, nullptr),
GRPC_ERROR_NONE);
}
}
@ -902,7 +897,8 @@ static bool resource_user_alloc_locked(grpc_resource_user* resource_user,
}
if (!resource_user->allocating) {
resource_user->allocating = true;
GRPC_CLOSURE_SCHED(&resource_user->allocate_closure, GRPC_ERROR_NONE);
resource_user->resource_quota->combiner->Run(
&resource_user->allocate_closure, GRPC_ERROR_NONE);
}
return false;
}
@ -957,8 +953,8 @@ void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
if (is_bigger_than_zero && was_zero_or_negative &&
!resource_user->added_to_free_pool) {
resource_user->added_to_free_pool = true;
GRPC_CLOSURE_SCHED(&resource_user->add_to_free_pool_closure,
GRPC_ERROR_NONE);
resource_quota->combiner->Run(&resource_user->add_to_free_pool_closure,
GRPC_ERROR_NONE);
}
gpr_mu_unlock(&resource_user->mu);
ru_unref_by(resource_user, static_cast<gpr_atm>(size));
@ -969,8 +965,8 @@ void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
grpc_closure* closure) {
GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr);
resource_user->new_reclaimers[destructive] = closure;
GRPC_CLOSURE_SCHED(&resource_user->post_reclaimer_closure[destructive],
GRPC_ERROR_NONE);
resource_user->resource_quota->combiner->Run(
&resource_user->post_reclaimer_closure[destructive], GRPC_ERROR_NONE);
}
void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
@ -978,7 +974,7 @@ void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
gpr_log(GPR_INFO, "RQ %s %s: reclamation complete",
resource_user->resource_quota->name, resource_user->name);
}
GRPC_CLOSURE_SCHED(
resource_user->resource_quota->combiner->Run(
&resource_user->resource_quota->rq_reclamation_done_closure,
GRPC_ERROR_NONE);
}

@ -1043,7 +1043,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
gpr_log(GPR_INFO, "write: %s", str);
}
// No need to take a ref on error since tcp_flush provides a ref.
GRPC_CLOSURE_SCHED(cb, error);
GRPC_CLOSURE_RUN(cb, error);
TCP_UNREF(tcp, "write");
}
}

@ -26,6 +26,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/exec_ctx.h"
namespace grpc_core {
@ -57,10 +58,17 @@ const char* ConnectivityStateName(grpc_connectivity_state state) {
class AsyncConnectivityStateWatcherInterface::Notifier {
public:
Notifier(RefCountedPtr<AsyncConnectivityStateWatcherInterface> watcher,
grpc_connectivity_state state, grpc_closure_scheduler* scheduler)
grpc_connectivity_state state, Combiner* combiner)
: watcher_(std::move(watcher)), state_(state) {
GRPC_CLOSURE_INIT(&closure_, SendNotification, this, scheduler);
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
if (combiner != nullptr) {
combiner->Run(
GRPC_CLOSURE_INIT(&closure_, SendNotification, this, nullptr),
GRPC_ERROR_NONE);
} else {
GRPC_CLOSURE_INIT(&closure_, SendNotification, this,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
}
}
private:
@ -81,7 +89,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
void AsyncConnectivityStateWatcherInterface::Notify(
grpc_connectivity_state state) {
New<Notifier>(Ref(), state, scheduler_); // Deletes itself when done.
New<Notifier>(Ref(), state, combiner_); // Deletes itself when done.
}
//

@ -68,15 +68,16 @@ class AsyncConnectivityStateWatcherInterface
protected:
class Notifier;
explicit AsyncConnectivityStateWatcherInterface(
grpc_closure_scheduler* scheduler = grpc_schedule_on_exec_ctx)
: scheduler_(scheduler) {}
// If \a combiner is nullptr, then the notification will be scheduled on the
// ExecCtx.
explicit AsyncConnectivityStateWatcherInterface(Combiner* combiner = nullptr)
: combiner_(combiner) {}
// Invoked asynchronously when Notify() is called.
virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) = 0;
private:
grpc_closure_scheduler* scheduler_;
Combiner* combiner_;
};
// Tracks connectivity state. Maintains a list of watchers that are

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -21,92 +21,8 @@ import grpc
from grpc._cython import cygrpc
from grpc._cython.cygrpc import init_grpc_aio
class Channel(six.with_metaclass(abc.ABCMeta)):
"""Asynchronous Channel implementation."""
@abc.abstractmethod
def unary_unary(self,
method,
request_serializer=None,
response_deserializer=None):
"""Creates a UnaryUnaryMultiCallable for a unary-unary method.
Args:
method: The name of the RPC method.
request_serializer: Optional behaviour for serializing the request
message. Request goes unserialized in case None is passed.
response_deserializer: Optional behaviour for deserializing the
response message. Response goes undeserialized in case None
is passed.
Returns:
A UnaryUnaryMultiCallable value for the named unary-unary method.
"""
raise NotImplementedError()
@abc.abstractmethod
async def close(self):
"""Closes this Channel and releases all resources held by it.
Closing the Channel will proactively terminate all RPCs active with the
Channel and it is not valid to invoke new RPCs with the Channel.
This method is idempotent.
"""
raise NotImplementedError()
@abc.abstractmethod
async def __aenter__(self):
"""Starts an asynchronous context manager.
Returns:
Channel the channel that was instantiated.
"""
raise NotImplementedError()
@abc.abstractmethod
async def __aexit__(self, exc_type, exc_val, exc_tb):
"""Finishes the asynchronous context manager by closing gracefully the channel."""
raise NotImplementedError()
class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC from client-side in an asynchronous way."""
@abc.abstractmethod
async def __call__(self,
request,
*,
timeout=None,
metadata=None,
credentials=None,
wait_for_ready=None,
compression=None):
"""Asynchronously invokes the underlying RPC.
Args:
request: The request value for the RPC.
timeout: An optional duration of time in seconds to allow
for the RPC.
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC. Only valid for
secure Channel.
wait_for_ready: This is an EXPERIMENTAL argument. An optional
flag to enable wait for ready mechanism
compression: An element of grpc.compression, e.g.
grpc.compression.Gzip. This is an EXPERIMENTAL option.
Returns:
The response value for the RPC.
Raises:
RpcError: Indicating that the RPC terminated with non-OK status. The
raised RpcError will also be a Call for the RPC affording the RPC's
metadata, status code, and details.
"""
raise NotImplementedError()
from ._channel import Channel
from ._channel import UnaryUnaryMultiCallable
def insecure_channel(target, options=None, compression=None):
@ -147,3 +63,13 @@ class AioRpcError:
cls._class_built.__doc__ = cls.__doc__
return cls._class_built(*args, **kwargs)
################################### __all__ #################################
__all__ = (
'init_grpc_aio',
'Channel',
'UnaryUnaryMultiCallable',
'insecure_channel',
'AioRpcError',
)

@ -17,13 +17,13 @@ from typing import Callable, Optional
from grpc import _common
from grpc._cython import cygrpc
from grpc.experimental import aio
SerializingFunction = Callable[[str], bytes]
DeserializingFunction = Callable[[bytes], str]
class UnaryUnaryMultiCallable(aio.UnaryUnaryMultiCallable):
class UnaryUnaryMultiCallable:
"""Afford invoking a unary-unary RPC from client-side in an asynchronous way."""
def __init__(self, channel: cygrpc.AioChannel, method: bytes,
request_serializer: SerializingFunction,
@ -47,6 +47,29 @@ class UnaryUnaryMultiCallable(aio.UnaryUnaryMultiCallable):
credentials=None,
wait_for_ready=None,
compression=None):
"""Asynchronously invokes the underlying RPC.
Args:
request: The request value for the RPC.
timeout: An optional duration of time in seconds to allow
for the RPC.
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC. Only valid for
secure Channel.
wait_for_ready: This is an EXPERIMENTAL argument. An optional
flag to enable wait for ready mechanism
compression: An element of grpc.compression, e.g.
grpc.compression.Gzip. This is an EXPERIMENTAL option.
Returns:
The response value for the RPC.
Raises:
RpcError: Indicating that the RPC terminated with non-OK status. The
raised RpcError will also be a Call for the RPC affording the RPC's
metadata, status code, and details.
"""
if metadata:
raise NotImplementedError("TODO: metadata not implemented yet")
@ -69,8 +92,11 @@ class UnaryUnaryMultiCallable(aio.UnaryUnaryMultiCallable):
return _common.deserialize(response, self._response_deserializer)
class Channel(aio.Channel):
"""A cygrpc.AioChannel-backed implementation of grpc.experimental.aio.Channel."""
class Channel:
"""Asynchronous Channel implementation.
A cygrpc.AioChannel-backed implementation.
"""
def __init__(self, target, options, credentials, compression):
"""Constructor.
@ -98,7 +124,19 @@ class Channel(aio.Channel):
method,
request_serializer=None,
response_deserializer=None):
"""Creates a UnaryUnaryMultiCallable for a unary-unary method.
Args:
method: The name of the RPC method.
request_serializer: Optional behaviour for serializing the request
message. Request goes unserialized in case None is passed.
response_deserializer: Optional behaviour for deserializing the
response message. Response goes undeserialized in case None
is passed.
Returns:
A UnaryUnaryMultiCallable value for the named unary-unary method.
"""
return UnaryUnaryMultiCallable(self._channel, _common.encode(method),
request_serializer,
response_deserializer)
@ -108,10 +146,23 @@ class Channel(aio.Channel):
self._channel.close()
async def __aenter__(self):
"""Starts an asynchronous context manager.
Returns:
Channel the channel that was instantiated.
"""
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
"""Finishes the asynchronous context manager by closing gracefully the channel."""
await self._close()
async def close(self):
"""Closes this Channel and releases all resources held by it.
Closing the Channel will proactively terminate all RPCs active with the
Channel and it is not valid to invoke new RPCs with the Channel.
This method is idempotent.
"""
await self._close()

@ -484,6 +484,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/bytestring/ber.c',
'third_party/boringssl/crypto/bytestring/cbb.c',
'third_party/boringssl/crypto/bytestring/cbs.c',
'third_party/boringssl/crypto/bytestring/unicode.c',
'third_party/boringssl/crypto/chacha/chacha.c',
'third_party/boringssl/crypto/cipher_extra/cipher_extra.c',
'third_party/boringssl/crypto/cipher_extra/derive_key.c',
@ -494,7 +495,6 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/cipher_extra/e_null.c',
'third_party/boringssl/crypto/cipher_extra/e_rc2.c',
'third_party/boringssl/crypto/cipher_extra/e_rc4.c',
'third_party/boringssl/crypto/cipher_extra/e_ssl3.c',
'third_party/boringssl/crypto/cipher_extra/e_tls.c',
'third_party/boringssl/crypto/cipher_extra/tls_cbc.c',
'third_party/boringssl/crypto/cmac/cmac.c',
@ -515,7 +515,8 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/dsa/dsa.c',
'third_party/boringssl/crypto/dsa/dsa_asn1.c',
'third_party/boringssl/crypto/ec_extra/ec_asn1.c',
'third_party/boringssl/crypto/ecdh/ecdh.c',
'third_party/boringssl/crypto/ec_extra/ec_derive.c',
'third_party/boringssl/crypto/ecdh_extra/ecdh_extra.c',
'third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c',
'third_party/boringssl/crypto/engine/engine.c',
'third_party/boringssl/crypto/err/err.c',
@ -530,14 +531,18 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/evp/p_ed25519_asn1.c',
'third_party/boringssl/crypto/evp/p_rsa.c',
'third_party/boringssl/crypto/evp/p_rsa_asn1.c',
'third_party/boringssl/crypto/evp/p_x25519.c',
'third_party/boringssl/crypto/evp/p_x25519_asn1.c',
'third_party/boringssl/crypto/evp/pbkdf.c',
'third_party/boringssl/crypto/evp/print.c',
'third_party/boringssl/crypto/evp/scrypt.c',
'third_party/boringssl/crypto/evp/sign.c',
'third_party/boringssl/crypto/ex_data.c',
'third_party/boringssl/crypto/fipsmodule/bcm.c',
'third_party/boringssl/crypto/fipsmodule/fips_shared_support.c',
'third_party/boringssl/crypto/fipsmodule/is_fips.c',
'third_party/boringssl/crypto/hkdf/hkdf.c',
'third_party/boringssl/crypto/hrss/hrss.c',
'third_party/boringssl/crypto/lhash/lhash.c',
'third_party/boringssl/crypto/mem.c',
'third_party/boringssl/crypto/obj/obj.c',
@ -568,6 +573,8 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/refcount_c11.c',
'third_party/boringssl/crypto/refcount_lock.c',
'third_party/boringssl/crypto/rsa_extra/rsa_asn1.c',
'third_party/boringssl/crypto/rsa_extra/rsa_print.c',
'third_party/boringssl/crypto/siphash/siphash.c',
'third_party/boringssl/crypto/stack/stack.c',
'third_party/boringssl/crypto/thread.c',
'third_party/boringssl/crypto/thread_none.c',
@ -644,6 +651,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/x509v3/v3_int.c',
'third_party/boringssl/crypto/x509v3/v3_lib.c',
'third_party/boringssl/crypto/x509v3/v3_ncons.c',
'third_party/boringssl/crypto/x509v3/v3_ocsp.c',
'third_party/boringssl/crypto/x509v3/v3_pci.c',
'third_party/boringssl/crypto/x509v3/v3_pcia.c',
'third_party/boringssl/crypto/x509v3/v3_pcons.c',
@ -655,7 +663,6 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/x509v3/v3_sxnet.c',
'third_party/boringssl/crypto/x509v3/v3_utl.c',
'third_party/boringssl/ssl/bio_ssl.cc',
'third_party/boringssl/ssl/custom_extensions.cc',
'third_party/boringssl/ssl/d1_both.cc',
'third_party/boringssl/ssl/d1_lib.cc',
'third_party/boringssl/ssl/d1_pkt.cc',

File diff suppressed because it is too large Load Diff

@ -33,7 +33,7 @@
static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_combiner* g_combiner;
static grpc_core::Combiner* g_combiner;
static void my_resolve_address(const char* addr, const char* /*default_port*/,
grpc_pollset_set* /*interested_parties*/,
@ -65,7 +65,7 @@ static grpc_ares_request* my_dns_lookup_ares_locked(
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool /*check_grpclb*/, char** /*service_config_json*/,
int /*query_timeout_ms*/, grpc_combiner* /*combiner*/) {
int /*query_timeout_ms*/, grpc_core::Combiner* /*combiner*/) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", addr));
grpc_error* error = GRPC_ERROR_NONE;

@ -37,14 +37,14 @@ constexpr int kMinResolutionPeriodForCheckMs = 900;
extern grpc_address_resolver_vtable* grpc_resolve_address_impl;
static grpc_address_resolver_vtable* default_resolve_address;
static grpc_combiner* g_combiner;
static grpc_core::Combiner* g_combiner;
static grpc_ares_request* (*g_default_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner);
grpc_core::Combiner* combiner);
// Counter incremented by test_resolve_address_impl indicating the number of
// times a system-level resolution has happened.
@ -95,7 +95,7 @@ static grpc_ares_request* test_dns_lookup_ares_locked(
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) {
grpc_core::Combiner* combiner) {
grpc_ares_request* result = g_default_dns_lookup_ares_locked(
dns_server, name, default_port, g_iomgr_args.pollset_set, on_done,
addresses, check_grpclb, service_config_json, query_timeout_ms, combiner);
@ -309,9 +309,9 @@ static void test_cooldown() {
grpc_core::New<OnResolutionCallbackArg>();
res_cb_arg->uri_str = "dns:127.0.0.1";
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(start_test_under_combiner, res_cb_arg,
grpc_combiner_scheduler(g_combiner)),
GRPC_ERROR_NONE);
g_combiner->Run(
GRPC_CLOSURE_CREATE(start_test_under_combiner, res_cb_arg, nullptr),
GRPC_ERROR_NONE);
grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&g_iomgr_args);
iomgr_args_finish(&g_iomgr_args);

@ -28,7 +28,7 @@
#include "src/core/lib/iomgr/combiner.h"
#include "test/core/util/test_config.h"
static grpc_combiner* g_combiner;
static grpc_core::Combiner* g_combiner;
class TestResultHandler : public grpc_core::Resolver::ResultHandler {
void ReturnResult(grpc_core::Resolver::Result /*result*/) override {}

@ -63,7 +63,7 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler {
};
static grpc_core::OrphanablePtr<grpc_core::Resolver> build_fake_resolver(
grpc_combiner* combiner,
grpc_core::Combiner* combiner,
grpc_core::FakeResolverResponseGenerator* response_generator,
grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler> result_handler) {
grpc_core::ResolverFactory* factory =
@ -118,7 +118,7 @@ static grpc_core::Resolver::Result create_new_resolver_result() {
static void test_fake_resolver() {
grpc_core::ExecCtx exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
grpc_core::Combiner* combiner = grpc_combiner_create();
// Create resolver.
ResultHandler* result_handler = grpc_core::New<ResultHandler>();
grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator>

@ -28,7 +28,7 @@
#include "test/core/util/test_config.h"
static grpc_combiner* g_combiner;
static grpc_core::Combiner* g_combiner;
class ResultHandler : public grpc_core::Resolver::ResultHandler {
public:

@ -74,7 +74,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) {
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_endpoint_pair* sfd =
static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));

@ -69,7 +69,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) {
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_endpoint_pair* sfd =
static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));

@ -69,7 +69,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) {
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_endpoint_pair* sfd =
static_cast<grpc_endpoint_pair*>(gpr_malloc(sizeof(grpc_endpoint_pair)));

@ -53,7 +53,7 @@ struct fullstack_secure_fixture_data {
};
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data* ffd =
@ -66,8 +66,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
static void process_auth_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* md, size_t md_count,
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
const grpc_metadata* /*md*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);
@ -136,7 +137,7 @@ static int server_authz_check_async(
// Synchronous implementation of schedule field in
// grpc_tls_credential_reload_config instance that is a part of client-side
// grpc_tls_credentials_options instance.
static int client_cred_reload_sync(void* config_user_data,
static int client_cred_reload_sync(void* /*config_user_data*/,
grpc_tls_credential_reload_arg* arg) {
if (!arg->key_materials_config->pem_key_cert_pair_list().empty()) {
arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;
@ -162,7 +163,7 @@ static int client_cred_reload_sync(void* config_user_data,
// Synchronous implementation of schedule field in
// grpc_tls_credential_reload_config instance that is a part of server-side
// grpc_tls_credentials_options instance.
static int server_cred_reload_sync(void* config_user_data,
static int server_cred_reload_sync(void* /*config_user_data*/,
grpc_tls_credential_reload_arg* arg) {
if (!arg->key_materials_config->pem_key_cert_pair_list().empty()) {
arg->status = GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED;

@ -39,7 +39,7 @@ struct fullstack_secure_fixture_data {
};
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data* ffd =
@ -55,8 +55,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
static void process_auth_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* md, size_t md_count,
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
const grpc_metadata* /*md*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);

@ -60,7 +60,7 @@ ssl_server_certificate_config_callback(
}
static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
fullstack_secure_fixture_data* ffd =
@ -75,8 +75,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
static void process_auth_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* md, size_t md_count,
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
const grpc_metadata* /*md*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);

@ -91,8 +91,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
static void process_auth_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* md, size_t md_count,
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/,
const grpc_metadata* /*md*/,
size_t /*md_count*/,
grpc_process_auth_metadata_done_cb cb,
void* user_data) {
GPR_ASSERT(state == nullptr);

@ -44,7 +44,7 @@ typedef struct fullstack_fixture_data {
static int unique = 1;
static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_end2end_test_fixture f;
fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
gpr_malloc(sizeof(fullstack_fixture_data)));

@ -69,7 +69,7 @@ struct grpc_end2end_http_proxy {
grpc_pollset* pollset;
gpr_refcount users;
grpc_combiner* combiner;
grpc_core::Combiner* combiner;
};
//
@ -154,6 +154,21 @@ enum failure_type {
SERVER_WRITE_FAILED,
};
// Forward declarations
static void on_client_write_done(void* arg, grpc_error* error);
static void on_server_write_done(void* arg, grpc_error* error);
static void on_client_read_done(void* arg, grpc_error* error);
static void on_server_read_done(void* arg, grpc_error* error);
static void on_server_connect_done(void* arg, grpc_error* error);
static void on_read_request_done(void* arg, grpc_error* error);
static void on_client_write_done_locked(void* arg, grpc_error* error);
static void on_server_write_done_locked(void* arg, grpc_error* error);
static void on_client_read_done_locked(void* arg, grpc_error* error);
static void on_server_read_done_locked(void* arg, grpc_error* error);
static void on_server_connect_done_locked(void* arg, grpc_error* error);
static void on_read_request_done_locked(void* arg, grpc_error* error);
// Helper function to shut down the proxy connection.
static void proxy_connection_failed(proxy_connection* conn,
failure_type failure, const char* prefix,
@ -193,7 +208,7 @@ static void proxy_connection_failed(proxy_connection* conn,
}
// Callback for writing proxy data to the client.
static void on_client_write_done(void* arg, grpc_error* error) {
static void on_client_write_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
@ -209,6 +224,8 @@ static void on_client_write_done(void* arg, grpc_error* error) {
grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer,
&conn->client_write_buffer);
conn->client_is_writing = true;
GRPC_CLOSURE_INIT(&conn->on_client_write_done, on_client_write_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done, nullptr);
} else {
@ -217,8 +234,16 @@ static void on_client_write_done(void* arg, grpc_error* error) {
}
}
static void on_client_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_client_write_done, on_client_write_done_locked,
conn, nullptr);
conn->proxy->combiner->Run(&conn->on_client_write_done,
GRPC_ERROR_REF(error));
}
// Callback for writing proxy data to the backend server.
static void on_server_write_done(void* arg, grpc_error* error) {
static void on_server_write_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->server_is_writing = false;
if (error != GRPC_ERROR_NONE) {
@ -234,6 +259,8 @@ static void on_server_write_done(void* arg, grpc_error* error) {
grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer,
&conn->server_write_buffer);
conn->server_is_writing = true;
GRPC_CLOSURE_INIT(&conn->on_server_write_done, on_server_write_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done, nullptr);
} else {
@ -242,9 +269,17 @@ static void on_server_write_done(void* arg, grpc_error* error) {
}
}
static void on_server_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_server_write_done, on_server_write_done_locked,
conn, nullptr);
conn->proxy->combiner->Run(&conn->on_server_write_done,
GRPC_ERROR_REF(error));
}
// Callback for reading data from the client, which will be proxied to
// the backend server.
static void on_client_read_done(void* arg, grpc_error* error) {
static void on_client_read_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, CLIENT_READ_FAILED, "HTTP proxy client read",
@ -265,17 +300,28 @@ static void on_client_read_done(void* arg, grpc_error* error) {
&conn->server_write_buffer);
proxy_connection_ref(conn, "client_read");
conn->server_is_writing = true;
GRPC_CLOSURE_INIT(&conn->on_server_write_done, on_server_write_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done, nullptr);
}
// Read more data.
GRPC_CLOSURE_INIT(&conn->on_client_read_done, on_client_read_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done, /*urgent=*/false);
}
static void on_client_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_client_read_done, on_client_read_done_locked,
conn, nullptr);
conn->proxy->combiner->Run(&conn->on_client_read_done, GRPC_ERROR_REF(error));
}
// Callback for reading data from the backend server, which will be
// proxied to the client.
static void on_server_read_done(void* arg, grpc_error* error) {
static void on_server_read_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, SERVER_READ_FAILED, "HTTP proxy server read",
@ -296,16 +342,27 @@ static void on_server_read_done(void* arg, grpc_error* error) {
&conn->client_write_buffer);
proxy_connection_ref(conn, "server_read");
conn->client_is_writing = true;
GRPC_CLOSURE_INIT(&conn->on_client_write_done, on_client_write_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done, nullptr);
}
// Read more data.
GRPC_CLOSURE_INIT(&conn->on_server_read_done, on_server_read_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done, /*urgent=*/false);
}
static void on_server_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_server_read_done, on_server_read_done_locked,
conn, nullptr);
conn->proxy->combiner->Run(&conn->on_server_read_done, GRPC_ERROR_REF(error));
}
// Callback to write the HTTP response for the CONNECT request.
static void on_write_response_done(void* arg, grpc_error* error) {
static void on_write_response_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
@ -321,15 +378,27 @@ static void on_write_response_done(void* arg, grpc_error* error) {
proxy_connection_ref(conn, "client_read");
proxy_connection_ref(conn, "server_read");
proxy_connection_unref(conn, "write_response");
GRPC_CLOSURE_INIT(&conn->on_client_read_done, on_client_read_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done, /*urgent=*/false);
GRPC_CLOSURE_INIT(&conn->on_server_read_done, on_server_read_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done, /*urgent=*/false);
}
static void on_write_response_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_write_response_done,
on_write_response_done_locked, conn, nullptr);
conn->proxy->combiner->Run(&conn->on_write_response_done,
GRPC_ERROR_REF(error));
}
// Callback to connect to the backend server specified by the HTTP
// CONNECT request.
static void on_server_connect_done(void* arg, grpc_error* error) {
static void on_server_connect_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error
@ -348,10 +417,20 @@ static void on_server_connect_done(void* arg, grpc_error* error) {
grpc_slice_from_copied_string("HTTP/1.0 200 connected\r\n\r\n");
grpc_slice_buffer_add(&conn->client_write_buffer, slice);
conn->client_is_writing = true;
GRPC_CLOSURE_INIT(&conn->on_write_response_done, on_write_response_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_write_response_done, nullptr);
}
static void on_server_connect_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_server_connect_done,
on_server_connect_done_locked, conn, nullptr);
conn->proxy->combiner->Run(&conn->on_server_connect_done,
GRPC_ERROR_REF(error));
}
/**
* Parses the proxy auth header value to check if it matches :-
* Basic <base64_encoded_expected_cred>
@ -378,7 +457,7 @@ static bool proxy_auth_header_matches(char* proxy_auth_header_val,
// the client indicating that the request failed. However, for the purposes
// of this test code, it's fine to pretend this is a client-side error,
// which will cause the client connection to be dropped.
static void on_read_request_done(void* arg, grpc_error* error) {
static void on_read_request_done_locked(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error));
@ -403,6 +482,8 @@ static void on_read_request_done(void* arg, grpc_error* error) {
grpc_slice_buffer_reset_and_unref(&conn->client_read_buffer);
// If we're not done reading the request, read more data.
if (conn->http_parser.state != GRPC_HTTP_BODY) {
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_read_request_done, /*urgent=*/false);
return;
@ -456,12 +537,22 @@ static void on_read_request_done(void* arg, grpc_error* error) {
// The connection callback inherits our reference to conn.
const grpc_millis deadline =
grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn,
grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint,
conn->pollset_set, nullptr,
&resolved_addresses->addrs[0], deadline);
grpc_resolved_addresses_destroy(resolved_addresses);
}
static void on_read_request_done(void* arg, grpc_error* error) {
proxy_connection* conn = static_cast<proxy_connection*>(arg);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done_locked,
conn, nullptr);
conn->proxy->combiner->Run(&conn->on_read_request_done,
GRPC_ERROR_REF(error));
}
static void on_accept(void* arg, grpc_endpoint* endpoint,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
@ -477,20 +568,6 @@ static void on_accept(void* arg, grpc_endpoint* endpoint,
conn->pollset_set = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(conn->pollset_set, proxy->pollset);
grpc_endpoint_add_to_pollset_set(endpoint, conn->pollset_set);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_write_response_done, on_write_response_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_client_read_done, on_client_read_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_client_write_done, on_client_write_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_read_done, on_server_read_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_write_done, on_server_write_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
grpc_slice_buffer_init(&conn->client_read_buffer);
grpc_slice_buffer_init(&conn->client_deferred_write_buffer);
conn->client_is_writing = false;
@ -501,6 +578,8 @@ static void on_accept(void* arg, grpc_endpoint* endpoint,
grpc_slice_buffer_init(&conn->server_write_buffer);
grpc_http_parser_init(&conn->http_parser, GRPC_HTTP_REQUEST,
&conn->http_request);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_schedule_on_exec_ctx);
grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_read_request_done, /*urgent=*/false);
}

@ -38,7 +38,7 @@ typedef struct inproc_fixture_data {
} inproc_fixture_data;
static grpc_end2end_test_fixture inproc_create_fixture(
grpc_channel_args* client_args, grpc_channel_args* server_args) {
grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) {
grpc_end2end_test_fixture f;
inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(
gpr_malloc(sizeof(inproc_fixture_data)));

@ -52,7 +52,7 @@ using grpc_core::testing::input_stream;
bool squelch = true;
bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
static void dont_log(gpr_log_func_args* /*args*/) {}
////////////////////////////////////////////////////////////////////////////////
// global state
@ -358,8 +358,8 @@ static void finish_resolve(void* arg, grpc_error* error) {
grpc_core::Delete(r);
}
void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
void my_resolve_address(const char* addr, const char* /*default_port*/,
grpc_pollset_set* /*interested_parties*/,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
addr_req* r = grpc_core::New<addr_req>();
@ -375,11 +375,11 @@ static grpc_address_resolver_vtable fuzzer_resolver = {my_resolve_address,
nullptr};
grpc_ares_request* my_dns_lookup_ares_locked(
const char* dns_server, const char* addr, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
const char* /*dns_server*/, const char* addr, const char* /*default_port*/,
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout,
grpc_combiner* combiner) {
bool /*check_grpclb*/, char** /*service_config_json*/,
int /*query_timeout*/, grpc_core::Combiner* /*combiner*/) {
addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
@ -450,9 +450,9 @@ static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
}
static void my_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_pollset_set* /*interested_parties*/,
const grpc_channel_args* /*channel_args*/,
const grpc_resolved_address* /*addr*/,
grpc_millis deadline) {
sched_connect(closure, ep,
grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
@ -481,7 +481,7 @@ static void assert_success_and_decrement(void* counter, bool success) {
--*static_cast<int*>(counter);
}
static void decrement(void* counter, bool success) {
static void decrement(void* counter, bool /*success*/) {
--*static_cast<int*>(counter);
}
@ -662,7 +662,7 @@ typedef struct {
uint8_t has_ops;
} batch_info;
static void finished_batch(void* p, bool success) {
static void finished_batch(void* p, bool /*success*/) {
batch_info* bi = static_cast<batch_info*>(p);
--bi->cs->pending_ops;
if ((bi->has_ops & (1u << GRPC_OP_RECV_MESSAGE)) &&

@ -49,7 +49,7 @@ static grpc_ares_request* (*iomgr_dns_lookup_ares_locked)(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner);
grpc_core::Combiner* combiner);
static void (*iomgr_cancel_ares_request_locked)(grpc_ares_request* request);
@ -106,7 +106,7 @@ static grpc_ares_request* my_dns_lookup_ares_locked(
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses,
bool check_grpclb, char** service_config_json, int query_timeout_ms,
grpc_combiner* combiner) {
grpc_core::Combiner* combiner) {
if (0 != strcmp(addr, "test")) {
return iomgr_dns_lookup_ares_locked(
dns_server, addr, default_port, interested_parties, on_done, addresses,

@ -39,13 +39,12 @@ static void set_event_to_true(void* value, grpc_error* /*error*/) {
static void test_execute_one(void) {
gpr_log(GPR_DEBUG, "test_execute_one");
grpc_combiner* lock = grpc_combiner_create();
grpc_core::Combiner* lock = grpc_combiner_create();
gpr_event done;
gpr_event_init(&done);
grpc_core::ExecCtx exec_ctx;
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &done,
grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
lock->Run(GRPC_CLOSURE_CREATE(set_event_to_true, &done, nullptr),
GRPC_ERROR_NONE);
grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
@ -54,7 +53,7 @@ static void test_execute_one(void) {
typedef struct {
size_t ctr;
grpc_combiner* lock;
grpc_core::Combiner* lock;
gpr_event done;
} thd_args;
@ -79,24 +78,22 @@ static void execute_many_loop(void* a) {
ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c)));
c->ctr = &args->ctr;
c->value = n++;
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(
check_one, c, grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
args->lock->Run(GRPC_CLOSURE_CREATE(check_one, c, nullptr),
GRPC_ERROR_NONE);
grpc_core::ExecCtx::Get()->Flush();
}
// sleep for a little bit, to test a combiner draining and another thread
// picking it up
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100));
}
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
args->lock->Run(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done, nullptr),
GRPC_ERROR_NONE);
}
static void test_execute_many(void) {
gpr_log(GPR_DEBUG, "test_execute_many");
grpc_combiner* lock = grpc_combiner_create();
grpc_core::Combiner* lock = grpc_combiner_create();
grpc_core::Thread thds[100];
thd_args ta[GPR_ARRAY_SIZE(thds)];
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) {
@ -122,21 +119,17 @@ static void in_finally(void* /*arg*/, grpc_error* /*error*/) {
}
static void add_finally(void* arg, grpc_error* /*error*/) {
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(in_finally, arg,
grpc_combiner_finally_scheduler(
static_cast<grpc_combiner*>(arg))),
GRPC_ERROR_NONE);
static_cast<grpc_core::Combiner*>(arg)->Run(
GRPC_CLOSURE_CREATE(in_finally, arg, nullptr), GRPC_ERROR_NONE);
}
static void test_execute_finally(void) {
gpr_log(GPR_DEBUG, "test_execute_finally");
grpc_combiner* lock = grpc_combiner_create();
grpc_core::Combiner* lock = grpc_combiner_create();
grpc_core::ExecCtx exec_ctx;
gpr_event_init(&got_in_finally);
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(add_finally, lock, grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
lock->Run(GRPC_CLOSURE_CREATE(add_finally, lock, nullptr), GRPC_ERROR_NONE);
grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&got_in_finally,
grpc_timeout_seconds_to_deadline(5)) != nullptr);

@ -55,7 +55,7 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor {
}
~SimpleFunctorForAdd() {}
static void Run(struct grpc_experimental_completion_queue_functor* cb,
int ok) {
int /*ok*/) {
auto* callback = static_cast<SimpleFunctorForAdd*>(cb);
callback->count_.FetchAdd(1, grpc_core::MemoryOrder::RELAXED);
}
@ -147,7 +147,7 @@ class SimpleFunctorCheckForAdd
}
~SimpleFunctorCheckForAdd() {}
static void Run(struct grpc_experimental_completion_queue_functor* cb,
int ok) {
int /*ok*/) {
auto* callback = static_cast<SimpleFunctorCheckForAdd*>(cb);
(*callback->count_)++;
GPR_ASSERT(*callback->count_ == callback->internal_success);

@ -85,8 +85,8 @@ class TestGrpcUdpHandler : public GrpcUdpHandler {
return false;
}
void OnCanWrite(void* user_data,
grpc_closure* notify_on_write_closure) override {
void OnCanWrite(void* /*user_data*/,
grpc_closure* /*notify_on_write_closure*/) override {
gpr_mu_lock(g_mu);
g_number_of_writes++;
@ -96,7 +96,7 @@ class TestGrpcUdpHandler : public GrpcUdpHandler {
}
void OnFdAboutToOrphan(grpc_closure* orphan_fd_closure,
void* user_data) override {
void* /*user_data*/) override {
gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d",
grpc_fd_wrapped_fd(emfd()));
GRPC_CLOSURE_SCHED(orphan_fd_closure, GRPC_ERROR_NONE);
@ -170,7 +170,7 @@ static test_socket_factory* test_socket_factory_create(void) {
return factory;
}
static void destroy_pollset(void* p, grpc_error* error) {
static void destroy_pollset(void* p, grpc_error* /*error*/) {
grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}

@ -27,7 +27,7 @@
#include "test/core/util/port.h"
#include "test/core/util/subprocess.h"
int main(int argc, char** argv) {
int main(int /*argc*/, char** argv) {
char* me = argv[0];
char* lslash = strrchr(me, '/');
char root[1024];

@ -144,7 +144,7 @@ static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) {
}
/* We have some sort of deadlock, so let's not exit gracefully for now.
When that is resolved, please remove the #include <unistd.h> above. */
static void sigint_handler(int x) { _exit(0); }
static void sigint_handler(int /*x*/) { _exit(0); }
int main(int argc, char** argv) {
grpc_memory_counters_init();

@ -27,9 +27,10 @@
bool squelch = true;
bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
static void dont_log(gpr_log_func_args* /*args*/) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* /*data*/,
size_t /*size*/) {
grpc_init();
if (squelch) gpr_set_log_function(dont_log);
// TODO(veblush): Convert this to upb.

@ -27,9 +27,10 @@
bool squelch = true;
bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
static void dont_log(gpr_log_func_args* /*args*/) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* /*data*/,
size_t /*size*/) {
grpc_init();
if (squelch) gpr_set_log_function(dont_log);
// TODO(veblush): Convert this to upb.

@ -40,7 +40,7 @@ using grpc_core::testing::input_stream;
bool squelch = true;
bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
static void dont_log(gpr_log_func_args* /*args*/) {}
// Add a random number of target service accounts to client options.
static void read_target_service_accounts(

@ -146,7 +146,7 @@ static void test_alts_peer_to_auth_context_success() {
tsi_peer_destruct(&peer);
}
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
/* Test. */
test_invalid_input_failure();
test_empty_certificate_type_failure();

@ -428,8 +428,8 @@ class check_channel_oauth2 final : public grpc_channel_credentials {
grpc_core::RefCountedPtr<grpc_channel_security_connector>
create_security_connector(
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
const char* target, const grpc_channel_args* args,
grpc_channel_args** new_args) override {
const char* /*target*/, const grpc_channel_args* /*args*/,
grpc_channel_args** /*new_args*/) override {
GPR_ASSERT(strcmp(type(), "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type(), GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) ==
@ -501,8 +501,8 @@ class check_channel_oauth2_google_iam final : public grpc_channel_credentials {
grpc_core::RefCountedPtr<grpc_channel_security_connector>
create_security_connector(
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
const char* target, const grpc_channel_args* args,
grpc_channel_args** new_args) override {
const char* /*target*/, const grpc_channel_args* /*args*/,
grpc_channel_args** /*new_args*/) override {
GPR_ASSERT(strcmp(type(), "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(
@ -560,7 +560,7 @@ static void validate_compute_engine_http_request(
}
static int compute_engine_httpcli_get_success_override(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
@ -569,7 +569,7 @@ static int compute_engine_httpcli_get_success_override(
}
static int compute_engine_httpcli_get_failure_override(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
@ -578,17 +578,16 @@ static int compute_engine_httpcli_get_failure_override(
}
static int httpcli_post_should_not_be_called(
const grpc_httpcli_request* request, const char* body_bytes,
size_t body_size, grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
const grpc_httpcli_request* /*request*/, const char* /*body_bytes*/,
size_t /*body_size*/, grpc_millis /*deadline*/, grpc_closure* /*on_done*/,
grpc_httpcli_response* /*response*/) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
static int httpcli_get_should_not_be_called(
const grpc_httpcli_request* /*request*/, grpc_millis /*deadline*/,
grpc_closure* /*on_done*/, grpc_httpcli_response* /*response*/) {
GPR_ASSERT("HTTP GET should not be called" == nullptr);
return 1;
}
@ -664,7 +663,7 @@ static void validate_refresh_token_http_request(
static int refresh_token_httpcli_post_success(
const grpc_httpcli_request* request, const char* body, size_t body_size,
grpc_millis deadline, grpc_closure* on_done,
grpc_millis /*deadline*/, grpc_closure* on_done,
grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
@ -672,9 +671,10 @@ static int refresh_token_httpcli_post_success(
return 1;
}
static int token_httpcli_post_failure(const grpc_httpcli_request* request,
const char* body, size_t body_size,
grpc_millis deadline,
static int token_httpcli_post_failure(const grpc_httpcli_request* /*request*/,
const char* /*body*/,
size_t /*body_size*/,
grpc_millis /*deadline*/,
grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(403, "Not Authorized.");
@ -876,7 +876,7 @@ static void validate_sts_token_http_request(const grpc_httpcli_request* request,
static int sts_token_httpcli_post_success(const grpc_httpcli_request* request,
const char* body, size_t body_size,
grpc_millis deadline,
grpc_millis /*deadline*/,
grpc_closure* on_done,
grpc_httpcli_response* response) {
validate_sts_token_http_request(request, body, body_size);
@ -1021,7 +1021,7 @@ static void validate_jwt_encode_and_sign_params(
}
static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key,
const char* audience,
const char* /*audience*/,
gpr_timespec token_lifetime,
const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
@ -1029,7 +1029,7 @@ static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key,
}
static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
const char* audience,
const char* /*audience*/,
gpr_timespec token_lifetime,
const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
@ -1037,8 +1037,8 @@ static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
}
static char* encode_and_sign_jwt_should_not_be_called(
const grpc_auth_json_key* json_key, const char* audience,
gpr_timespec token_lifetime, const char* scope) {
const grpc_auth_json_key* /*json_key*/, const char* /*audience*/,
gpr_timespec /*token_lifetime*/, const char* /*scope*/) {
GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == nullptr);
return nullptr;
}
@ -1204,7 +1204,7 @@ static void test_google_default_creds_refresh_token(void) {
}
static int default_creds_metadata_server_detection_httpcli_get_success_override(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, "");
grpc_http_header* headers =
@ -1300,7 +1300,7 @@ static void test_google_default_creds_non_gce(void) {
}
static int default_creds_gce_detection_httpcli_get_failure_override(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
@ -1342,10 +1342,10 @@ static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}};
static int plugin_get_metadata_success(
void* state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void* user_data,
grpc_credentials_plugin_metadata_cb /*cb*/, void* /*user_data*/,
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
size_t* num_creds_md, grpc_status_code* status,
const char** error_details) {
size_t* num_creds_md, grpc_status_code* /*status*/,
const char** /*error_details*/) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
GPR_ASSERT(context.channel_auth_context == nullptr);
@ -1367,9 +1367,9 @@ static const char* plugin_error_details = "Could not get metadata for plugin.";
static int plugin_get_metadata_failure(
void* state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void* user_data,
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
size_t* num_creds_md, grpc_status_code* status,
grpc_credentials_plugin_metadata_cb /*cb*/, void* /*user_data*/,
grpc_metadata /*creds_md*/[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
size_t* /*num_creds_md*/, grpc_status_code* status,
const char** error_details) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);

@ -318,15 +318,15 @@ static grpc_httpcli_response http_response(int status, char* body) {
}
static int httpcli_post_should_not_be_called(
const grpc_httpcli_request* request, const char* body_bytes,
size_t body_size, grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
const grpc_httpcli_request* /*request*/, const char* /*body_bytes*/,
size_t /*body_size*/, grpc_millis /*deadline*/, grpc_closure* /*on_done*/,
grpc_httpcli_response* /*response*/) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
static int httpcli_get_google_keys_for_email(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -372,7 +372,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
}
static int httpcli_get_custom_keys_for_email(
const grpc_httpcli_request* request, grpc_millis deadline,
const grpc_httpcli_request* request, grpc_millis /*deadline*/,
grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -405,7 +405,7 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
}
static int httpcli_get_jwk_set(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_millis /*deadline*/, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -416,7 +416,7 @@ static int httpcli_get_jwk_set(const grpc_httpcli_request* request,
}
static int httpcli_get_openid_config(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_millis /*deadline*/,
grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_openid_config));
@ -460,7 +460,7 @@ static void on_verification_key_retrieval_error(void* user_data,
}
static int httpcli_get_bad_json(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_millis /*deadline*/, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -566,10 +566,9 @@ static void test_jwt_verifier_bad_signature(void) {
grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
static int httpcli_get_should_not_be_called(
const grpc_httpcli_request* /*request*/, grpc_millis /*deadline*/,
grpc_closure* /*on_done*/, grpc_httpcli_response* /*response*/) {
GPR_ASSERT(0);
return 1;
}

@ -87,7 +87,7 @@ static size_t base64_infer_length(const char* s) {
EXPECT_SLICE_EQ( \
s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s)));
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
grpc_init();
{
grpc_core::ExecCtx exec_ctx;

@ -49,7 +49,7 @@ void TestExecuteFlushesListVerifier(void* arg, grpc_core::Timestamps* ts,
gpr_atm_rel_store(done, static_cast<gpr_atm>(1));
}
void discard_write(grpc_slice slice) {}
void discard_write(grpc_slice /*slice*/) {}
class ContextListTest : public ::testing::Test {
protected:

@ -30,11 +30,11 @@
bool squelch = true;
bool leak_check = true;
static grpc_error* onhdr(void* ud, grpc_mdelem md) {
static grpc_error* onhdr(void* /*ud*/, grpc_mdelem md) {
GRPC_MDELEM_UNREF(md);
return GRPC_ERROR_NONE;
}
static void dont_log(gpr_log_func_args* args) {}
static void dont_log(gpr_log_func_args* /*args*/) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_test_only_set_slice_hash_seed(0);

@ -32,7 +32,7 @@
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
static void assert_str(const grpc_chttp2_hptbl* tbl, grpc_slice mdstr,
static void assert_str(const grpc_chttp2_hptbl* /*tbl*/, grpc_slice mdstr,
const char* str) {
GPR_ASSERT(grpc_slice_str_cmp(mdstr, str) == 0);
}

@ -205,7 +205,7 @@ class Client {
}
}
static void PollsetDestroy(void* arg, grpc_error* error) {
static void PollsetDestroy(void* arg, grpc_error* /*error*/) {
grpc_pollset* pollset = static_cast<grpc_pollset*>(arg);
grpc_pollset_destroy(pollset);
gpr_free(pollset);

@ -23,7 +23,7 @@
#include <grpc/grpc.h>
#include <grpc/support/log.h>
static void do_nothing(void* arg, grpc_error* error) {}
static void do_nothing(void* /*arg*/, grpc_error* /*error*/) {}
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);

@ -386,7 +386,7 @@ static void alts_test_do_round_trip_all(bool rekey) {
gpr_free(bit_array);
}
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
alts_test_do_round_trip_vector_tests();
alts_test_do_round_trip_all(/*rekey=*/false);
alts_test_do_round_trip_all(/*rekey=*/true);

@ -134,9 +134,10 @@ static grpc_gcp_HandshakerReq* deserialize_handshaker_req(
* A mock grpc_caller used to check if client_start, server_start, and next
* operations correctly handle invalid arguments. It should not be called.
*/
static grpc_call_error check_must_not_be_called(grpc_call* call,
const grpc_op* ops, size_t nops,
grpc_closure* tag) {
static grpc_call_error check_must_not_be_called(grpc_call* /*call*/,
const grpc_op* /*ops*/,
size_t /*nops*/,
grpc_closure* /*tag*/) {
GPR_ASSERT(0);
}
@ -146,7 +147,7 @@ static grpc_call_error check_must_not_be_called(grpc_call* call,
* handshake_security_protocol, application_protocol, and record_protocol, and
* op is correctly populated.
*/
static grpc_call_error check_client_start_success(grpc_call* call,
static grpc_call_error check_client_start_success(grpc_call* /*call*/,
const grpc_op* op,
size_t nops,
grpc_closure* closure) {
@ -191,7 +192,7 @@ static grpc_call_error check_client_start_success(grpc_call* call,
* handshake_security_protocol, application_protocol, and record_protocol, and
* op is correctly populated.
*/
static grpc_call_error check_server_start_success(grpc_call* call,
static grpc_call_error check_server_start_success(grpc_call* /*call*/,
const grpc_op* op,
size_t nops,
grpc_closure* closure) {
@ -234,8 +235,9 @@ static grpc_call_error check_server_start_success(grpc_call* call,
* checks if the next handshaker request is populated with correct information,
* and op is correctly populated.
*/
static grpc_call_error check_next_success(grpc_call* call, const grpc_op* op,
size_t nops, grpc_closure* closure) {
static grpc_call_error check_next_success(grpc_call* /*call*/,
const grpc_op* op, size_t nops,
grpc_closure* closure) {
upb::Arena arena;
alts_handshaker_client* client =
static_cast<alts_handshaker_client*>(closure->cb_arg);
@ -256,9 +258,10 @@ static grpc_call_error check_next_success(grpc_call* call, const grpc_op* op,
* operations correctly handle the situation when the grpc call made to the
* handshaker service fails.
*/
static grpc_call_error check_grpc_call_failure(grpc_call* call,
const grpc_op* op, size_t nops,
grpc_closure* tag) {
static grpc_call_error check_grpc_call_failure(grpc_call* /*call*/,
const grpc_op* /*op*/,
size_t /*nops*/,
grpc_closure* /*tag*/) {
return GRPC_CALL_ERROR;
}
@ -397,7 +400,7 @@ static void schedule_request_grpc_call_failure_test() {
destroy_config(config);
}
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
/* Initialization. */
grpc_init();
grpc_alts_shared_resource_dedicated_init();

@ -181,10 +181,10 @@ static grpc_byte_buffer* generate_handshaker_response(
return buffer;
}
static void check_must_not_be_called(tsi_result status, void* user_data,
const unsigned char* bytes_to_send,
size_t bytes_to_send_size,
tsi_handshaker_result* result) {
static void check_must_not_be_called(tsi_result /*status*/, void* /*user_data*/,
const unsigned char* /*bytes_to_send*/,
size_t /*bytes_to_send_size*/,
tsi_handshaker_result* /*result*/) {
GPR_ASSERT(0);
}
@ -331,7 +331,7 @@ static tsi_result mock_client_start(alts_handshaker_client* client) {
return TSI_OK;
}
static void mock_shutdown(alts_handshaker_client* self) {}
static void mock_shutdown(alts_handshaker_client* /*self*/) {}
static tsi_result mock_server_start(alts_handshaker_client* client,
grpc_slice* bytes_received) {
@ -384,7 +384,7 @@ static tsi_result mock_next(alts_handshaker_client* client,
return TSI_OK;
}
static void mock_destruct(alts_handshaker_client* client) {}
static void mock_destruct(alts_handshaker_client* /*client*/) {}
static alts_handshaker_client_vtable vtable = {mock_client_start,
mock_server_start, mock_next,
@ -484,7 +484,7 @@ static void check_handshaker_next_with_shutdown() {
tsi_handshaker_destroy(handshaker);
}
static void check_handle_response_with_shutdown(void* unused) {
static void check_handle_response_with_shutdown(void* /*unused*/) {
wait(&caller_to_tsi_notification);
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
}
@ -627,7 +627,7 @@ static void check_handle_response_invalid_resp() {
notification_destroy(&tsi_to_caller_notification);
}
static void check_handle_response_success(void* unused) {
static void check_handle_response_success(void* /*unused*/) {
/* Client start. */
wait(&caller_to_tsi_notification);
alts_handshaker_client_handle_response(cb_event, true /* is_ok */);
@ -750,7 +750,7 @@ void check_handshaker_success() {
notification_destroy(&tsi_to_caller_notification);
}
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
/* Initialization. */
grpc_init();
grpc_alts_shared_resource_dedicated_init();

@ -66,7 +66,7 @@ static void deserialize_response_test() {
grpc_byte_buffer_destroy(buffer);
}
int main(int argc, char** argv) {
int main(int /*argc*/, char** /*argv*/) {
/* Tests. */
deserialize_response_test();
convert_to_tsi_result_test();

@ -29,13 +29,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
extern bool squelch;
extern bool leak_check;
int main(int /*argc*/, char** argv) {
int main(int argc, char** argv) {
grpc_slice buffer;
squelch = false;
leak_check = false;
/* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace
* grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with
* grpc_shutdown */
GPR_ASSERT(argc > 1); /* Make sure that we have a filename argument */
GPR_ASSERT(
GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer)));
LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer),

@ -508,10 +508,6 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
data = [
"xds_bootstrap.json",
"xds_bootstrap_bad.json",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
)

@ -1884,6 +1884,7 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) {
std::shared_ptr<CallCredentials> creds1 =
GoogleIAMCredentials("wrong_token", "wrong_selector");
context.set_credentials(creds1);
EXPECT_EQ(context.credentials(), creds1);
request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true);
@ -1907,9 +1908,11 @@ TEST_P(SecureEnd2endTest, OverridePerCallCredentials) {
std::shared_ptr<CallCredentials> creds1 =
GoogleIAMCredentials("fake_token1", "fake_selector1");
context.set_credentials(creds1);
EXPECT_EQ(context.credentials(), creds1);
std::shared_ptr<CallCredentials> creds2 =
GoogleIAMCredentials("fake_token2", "fake_selector2");
context.set_credentials(creds2);
EXPECT_EQ(context.credentials(), creds2);
request.set_message("Hello");
request.mutable_param()->set_echo_metadata(true);

@ -309,7 +309,7 @@ typedef ::testing::Types<
CommonStressTestAsyncServer<CommonStressTestInproc<
grpc::testing::EchoTestService::AsyncService, false>>>
CommonTypes;
TYPED_TEST_CASE(End2endTest, CommonTypes);
TYPED_TEST_SUITE(End2endTest, CommonTypes);
TYPED_TEST(End2endTest, ThreadStress) {
this->common_.ResetStub();
std::vector<std::thread> threads;
@ -408,7 +408,7 @@ class AsyncClientEnd2endTest : public ::testing::Test {
int rpcs_outstanding_;
};
TYPED_TEST_CASE(AsyncClientEnd2endTest, CommonTypes);
TYPED_TEST_SUITE(AsyncClientEnd2endTest, CommonTypes);
TYPED_TEST(AsyncClientEnd2endTest, ThreadStress) {
this->common_.ResetStub();
std::vector<std::thread> send_threads, completion_threads;

@ -1,22 +0,0 @@
{
"xds_server": {
"server_uri": "fake:///lb",
"channel_creds": [
{
"type": "fake"
}
]
},
"node": {
"id": "xds_end2end_test",
"cluster": "test",
"metadata": {
"foo": "bar"
},
"locality": {
"region": "corp",
"zone": "svl",
"subzone": "mp3"
}
}
}

@ -1,12 +0,0 @@
{
"xds_server": {
"server_uri": "fake:///wrong_lb",
"channel_creds": [
{
"type": "fake"
}
]
},
"node": {
}
}

@ -39,6 +39,7 @@
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/ext/filters/client_channel/server_address.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/gpr/tmpfile.h"
#include "src/core/lib/gprpp/map.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/sync.h"
@ -102,6 +103,59 @@ constexpr char kThrottleDropType[] = "throttle";
constexpr int kDefaultLocalityWeight = 3;
constexpr int kDefaultLocalityPriority = 0;
constexpr char kBootstrapFile[] =
"{\n"
" \"xds_server\": {\n"
" \"server_uri\": \"fake:///lb\",\n"
" \"channel_creds\": [\n"
" {\n"
" \"type\": \"fake\"\n"
" }\n"
" ]\n"
" },\n"
" \"node\": {\n"
" \"id\": \"xds_end2end_test\",\n"
" \"cluster\": \"test\",\n"
" \"metadata\": {\n"
" \"foo\": \"bar\"\n"
" },\n"
" \"locality\": {\n"
" \"region\": \"corp\",\n"
" \"zone\": \"svl\",\n"
" \"subzone\": \"mp3\"\n"
" }\n"
" }\n"
"}\n";
constexpr char kBootstrapFileBad[] =
"{\n"
" \"xds_server\": {\n"
" \"server_uri\": \"fake:///wrong_lb\",\n"
" \"channel_creds\": [\n"
" {\n"
" \"type\": \"fake\"\n"
" }\n"
" ]\n"
" },\n"
" \"node\": {\n"
" }\n"
"}\n";
char* g_bootstrap_file;
char* g_bootstrap_file_bad;
void WriteBootstrapFiles() {
char* bootstrap_file;
FILE* out = gpr_tmpfile("xds_bootstrap", &bootstrap_file);
fputs(kBootstrapFile, out);
fclose(out);
g_bootstrap_file = bootstrap_file;
out = gpr_tmpfile("xds_bootstrap_bad", &bootstrap_file);
fputs(kBootstrapFileBad, out);
fclose(out);
g_bootstrap_file_bad = bootstrap_file;
}
template <typename ServiceType>
class CountedService : public ServiceType {
public:
@ -266,16 +320,19 @@ class AdsServiceImpl : public AdsService {
struct Locality {
Locality(const grpc::string& sub_zone, std::vector<int> ports,
int lb_weight = kDefaultLocalityWeight,
int priority = kDefaultLocalityPriority)
int priority = kDefaultLocalityPriority,
std::vector<envoy::api::v2::HealthStatus> health_statuses = {})
: sub_zone(std::move(sub_zone)),
ports(std::move(ports)),
lb_weight(lb_weight),
priority(priority) {}
priority(priority),
health_statuses(std::move(health_statuses)) {}
const grpc::string sub_zone;
std::vector<int> ports;
int lb_weight;
int priority;
std::vector<envoy::api::v2::HealthStatus> health_statuses;
};
ResponseArgs() = default;
@ -356,8 +413,14 @@ class AdsServiceImpl : public AdsService {
endpoints->mutable_locality()->set_region(kDefaultLocalityRegion);
endpoints->mutable_locality()->set_zone(kDefaultLocalityZone);
endpoints->mutable_locality()->set_sub_zone(locality.sub_zone);
for (const int& port : locality.ports) {
for (size_t i = 0; i < locality.ports.size(); ++i) {
const int& port = locality.ports[i];
auto* lb_endpoints = endpoints->add_lb_endpoints();
if (locality.health_statuses.size() > i &&
locality.health_statuses[i] !=
envoy::api::v2::HealthStatus::UNKNOWN) {
lb_endpoints->set_health_status(locality.health_statuses[i]);
}
auto* endpoint = lb_endpoints->mutable_endpoint();
auto* address = endpoint->mutable_address();
auto* socket_address = address->mutable_socket_address();
@ -512,7 +575,27 @@ class LrsServiceImpl : public LrsService {
bool load_report_ready_ = false;
};
class XdsEnd2endTest : public ::testing::TestWithParam<bool> {
class TestType {
public:
TestType(bool use_xds_resolver, bool enable_load_reporting)
: use_xds_resolver_(use_xds_resolver),
enable_load_reporting_(enable_load_reporting) {}
bool use_xds_resolver() const { return use_xds_resolver_; }
bool enable_load_reporting() const { return enable_load_reporting_; }
grpc::string AsString() const {
grpc::string retval = (use_xds_resolver_ ? "XdsResolver" : "FakeResolver");
if (enable_load_reporting_) retval += "WithLoadReporting";
return retval;
}
private:
const bool use_xds_resolver_;
const bool enable_load_reporting_;
};
class XdsEnd2endTest : public ::testing::TestWithParam<TestType> {
protected:
XdsEnd2endTest(size_t num_backends, size_t num_balancers,
int client_load_reporting_interval_seconds)
@ -536,7 +619,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam<bool> {
static void TearDownTestCase() { grpc_shutdown(); }
void SetUp() override {
gpr_setenv("GRPC_XDS_BOOTSTRAP", "test/cpp/end2end/xds_bootstrap.json");
gpr_setenv("GRPC_XDS_BOOTSTRAP", g_bootstrap_file);
response_generator_ =
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>();
lb_channel_response_generator_ =
@ -591,12 +674,14 @@ class XdsEnd2endTest : public ::testing::TestWithParam<bool> {
// channel never uses a response generator, and we inject the xds
// channel's response generator here.
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR,
GetParam() ? lb_channel_response_generator_.get()
: response_generator_.get());
GetParam().use_xds_resolver()
? lb_channel_response_generator_.get()
: response_generator_.get());
if (!expected_targets.empty()) {
args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets);
}
grpc::string scheme = GetParam() ? "xds-experimental" : "fake";
grpc::string scheme =
GetParam().use_xds_resolver() ? "xds-experimental" : "fake";
std::ostringstream uri;
uri << scheme << ":///" << kApplicationTargetName_;
// TODO(dgq): templatize tests to run everything using both secure and
@ -686,19 +771,20 @@ class XdsEnd2endTest : public ::testing::TestWithParam<bool> {
}
void SetNextResolution(const std::vector<int>& ports,
const char* service_config_json = nullptr,
grpc_core::FakeResolverResponseGenerator*
lb_channel_response_generator = nullptr) {
if (GetParam()) return; // Not used with xds resolver.
if (GetParam().use_xds_resolver()) return; // Not used with xds resolver.
grpc_core::ExecCtx exec_ctx;
grpc_core::Resolver::Result result;
result.addresses = CreateAddressListFromPortList(ports);
if (service_config_json != nullptr) {
grpc_error* error = GRPC_ERROR_NONE;
result.service_config =
grpc_core::ServiceConfig::Create(service_config_json, &error);
GRPC_ERROR_UNREF(error);
}
grpc_error* error = GRPC_ERROR_NONE;
const char* service_config_json =
GetParam().enable_load_reporting()
? kDefaultServiceConfig_
: kDefaultServiceConfigWithoutLoadReporting_;
result.service_config =
grpc_core::ServiceConfig::Create(service_config_json, &error);
GRPC_ERROR_UNREF(error);
grpc_arg arg = grpc_core::FakeResolverResponseGenerator::MakeChannelArg(
lb_channel_response_generator == nullptr
? lb_channel_response_generator_.get()
@ -914,11 +1000,21 @@ class XdsEnd2endTest : public ::testing::TestWithParam<bool> {
lb_channel_response_generator_;
const grpc::string kRequestMessage_ = "Live long and prosper.";
const grpc::string kApplicationTargetName_ = "application_target_name";
const grpc::string kDefaultServiceConfig_ =
const char* kDefaultServiceConfig_ =
"{\n"
" \"loadBalancingConfig\":[\n"
" { \"does_not_exist\":{} },\n"
" { \"xds_experimental\":{\n"
" \"lrsLoadReportingServerName\": \"\"\n"
" } }\n"
" ]\n"
"}";
const char* kDefaultServiceConfigWithoutLoadReporting_ =
"{\n"
" \"loadBalancingConfig\":[\n"
" { \"does_not_exist\":{} },\n"
" { \"xds_experimental\":{} }\n"
" { \"xds_experimental\":{\n"
" } }\n"
" ]\n"
"}";
};
@ -931,7 +1027,7 @@ class BasicTest : public XdsEnd2endTest {
// Tests that the balancer sends the correct response to the client, and the
// client sends RPCs to the backends using the default child policy.
TEST_P(BasicTest, Vanilla) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcsPerAddress = 100;
AdsServiceImpl::ResponseArgs args({
@ -956,10 +1052,40 @@ TEST_P(BasicTest, Vanilla) {
EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName());
}
TEST_P(BasicTest, IgnoresUnhealthyEndpoints) {
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcsPerAddress = 100;
AdsServiceImpl::ResponseArgs args({
{"locality0",
GetBackendPorts(),
kDefaultLocalityWeight,
kDefaultLocalityPriority,
{envoy::api::v2::HealthStatus::DRAINING}},
});
ScheduleResponseForBalancer(0, AdsServiceImpl::BuildResponse(args), 0);
// Make sure that trying to connect works without a call.
channel_->GetState(true /* try_to_connect */);
// We need to wait for all backends to come online.
WaitForAllBackends(/*start_index=*/1);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * (num_backends_ - 1));
// Each backend should have gotten 100 requests.
for (size_t i = 1; i < backends_.size(); ++i) {
EXPECT_EQ(kNumRpcsPerAddress,
backends_[i]->backend_service()->request_count());
}
// The ADS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->ads_service()->request_count());
EXPECT_EQ(1U, balancers_[0]->ads_service()->response_count());
// Check LB policy name for the channel.
EXPECT_EQ("xds_experimental", channel_->GetLoadBalancingPolicyName());
}
// Tests that subchannel sharing works when the same backend is listed multiple
// times.
TEST_P(BasicTest, SameBackendListedMultipleTimes) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
// Same backend listed twice.
std::vector<int> ports(2, backends_[0]->port());
@ -982,7 +1108,7 @@ TEST_P(BasicTest, SameBackendListedMultipleTimes) {
// Tests that RPCs will be blocked until a non-empty serverlist is received.
TEST_P(BasicTest, InitiallyEmptyServerlist) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor();
const int kCallDeadlineMs = kServerlistDelayMs * 2;
@ -1018,7 +1144,7 @@ TEST_P(BasicTest, InitiallyEmptyServerlist) {
// Tests that RPCs will fail with UNAVAILABLE instead of DEADLINE_EXCEEDED if
// all the servers are unreachable.
TEST_P(BasicTest, AllServersUnreachableFailFast) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumUnreachableServers = 5;
std::vector<int> ports;
@ -1040,7 +1166,7 @@ TEST_P(BasicTest, AllServersUnreachableFailFast) {
// Tests that RPCs fail when the backends are down, and will succeed again after
// the backends are restarted.
TEST_P(BasicTest, BackendsRestart) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts()},
@ -1062,7 +1188,7 @@ using SecureNamingTest = BasicTest;
TEST_P(SecureNamingTest, TargetNameIsExpected) {
// TODO(juanlishen): Use separate fake creds for the balancer channel.
ResetStub(0, 0, kApplicationTargetName_ + ";lb");
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannel({balancers_[0]->port()});
const size_t kNumRpcsPerAddress = 100;
AdsServiceImpl::ResponseArgs args({
@ -1087,14 +1213,14 @@ TEST_P(SecureNamingTest, TargetNameIsExpected) {
// Tests that secure naming check fails if target name is unexpected.
TEST_P(SecureNamingTest, TargetNameIsUnexpected) {
gpr_setenv("GRPC_XDS_BOOTSTRAP", "test/cpp/end2end/xds_bootstrap_bad.json");
gpr_setenv("GRPC_XDS_BOOTSTRAP", g_bootstrap_file_bad);
::testing::FLAGS_gtest_death_test_style = "threadsafe";
// Make sure that we blow up (via abort() from the security connector) when
// the name from the balancer doesn't match expectations.
ASSERT_DEATH_IF_SUPPORTED(
{
ResetStub(0, 0, kApplicationTargetName_ + ";lb");
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannel({balancers_[0]->port()});
channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1));
},
@ -1106,7 +1232,7 @@ using LocalityMapTest = BasicTest;
// Tests that the localities in a locality map are picked according to their
// weights.
TEST_P(LocalityMapTest, WeightedRoundRobin) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 5000;
const int kLocalityWeight0 = 2;
@ -1150,7 +1276,7 @@ TEST_P(LocalityMapTest, WeightedRoundRobin) {
// Tests that the locality map can work properly even when it contains a large
// number of localities.
TEST_P(LocalityMapTest, StressTest) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumLocalities = 100;
// The first ADS response contains kNumLocalities localities, each of which
@ -1185,7 +1311,7 @@ TEST_P(LocalityMapTest, StressTest) {
// Tests that the localities in a locality map are picked correctly after update
// (addition, modification, deletion).
TEST_P(LocalityMapTest, UpdateMap) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 1000;
// The locality weight for the first 3 localities.
@ -1282,7 +1408,7 @@ class FailoverTest : public BasicTest {
// Localities with the highest priority are used when multiple priority exist.
TEST_P(FailoverTest, ChooseHighestPriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
@ -1303,7 +1429,7 @@ TEST_P(FailoverTest, ChooseHighestPriority) {
// If the higher priority localities are not reachable, failover to the highest
// priority among the rest.
TEST_P(FailoverTest, Failover) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
@ -1327,7 +1453,7 @@ TEST_P(FailoverTest, Failover) {
// If a locality with higher priority than the current one becomes ready,
// switch to it.
TEST_P(FailoverTest, SwitchBackToHigherPriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 100;
AdsServiceImpl::ResponseArgs args({
@ -1356,7 +1482,7 @@ TEST_P(FailoverTest, SwitchBackToHigherPriority) {
// The first update only contains unavailable priorities. The second update
// contains available priorities.
TEST_P(FailoverTest, UpdateInitialUnavailable) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 0},
@ -1391,7 +1517,7 @@ TEST_P(FailoverTest, UpdateInitialUnavailable) {
// Tests that after the localities' priorities are updated, we still choose the
// highest READY priority with the updated localities.
TEST_P(FailoverTest, UpdatePriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 100;
AdsServiceImpl::ResponseArgs args({
@ -1424,7 +1550,7 @@ using DropTest = BasicTest;
// Tests that RPCs are dropped according to the drop config.
TEST_P(DropTest, Vanilla) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 5000;
const uint32_t kDropPerMillionForLb = 100000;
@ -1470,7 +1596,7 @@ TEST_P(DropTest, Vanilla) {
// Tests that drop config is converted correctly from per hundred.
TEST_P(DropTest, DropPerHundred) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 5000;
const uint32_t kDropPerHundredForLb = 10;
@ -1511,7 +1637,7 @@ TEST_P(DropTest, DropPerHundred) {
// Tests that drop config is converted correctly from per ten thousand.
TEST_P(DropTest, DropPerTenThousand) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 5000;
const uint32_t kDropPerTenThousandForLb = 1000;
@ -1552,7 +1678,7 @@ TEST_P(DropTest, DropPerTenThousand) {
// Tests that drop is working correctly after update.
TEST_P(DropTest, Update) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 1000;
const uint32_t kDropPerMillionForLb = 100000;
@ -1648,7 +1774,7 @@ TEST_P(DropTest, Update) {
// Tests that all the RPCs are dropped if any drop category drops 100%.
TEST_P(DropTest, DropAll) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 1000;
const uint32_t kDropPerMillionForLb = 100000;
@ -1681,8 +1807,7 @@ TEST_P(FallbackTest, Vanilla) {
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor();
const size_t kNumBackendsInResolution = backends_.size() / 2;
ResetStub(kFallbackTimeoutMs);
SetNextResolution(GetBackendPorts(0, kNumBackendsInResolution),
kDefaultServiceConfig_.c_str());
SetNextResolution(GetBackendPorts(0, kNumBackendsInResolution));
SetNextResolutionForLbChannelAllBalancers();
// Send non-empty serverlist only after kServerlistDelayMs.
AdsServiceImpl::ResponseArgs args({
@ -1731,8 +1856,7 @@ TEST_P(FallbackTest, Update) {
const size_t kNumBackendsInResolution = backends_.size() / 3;
const size_t kNumBackendsInResolutionUpdate = backends_.size() / 3;
ResetStub(kFallbackTimeoutMs);
SetNextResolution(GetBackendPorts(0, kNumBackendsInResolution),
kDefaultServiceConfig_.c_str());
SetNextResolution(GetBackendPorts(0, kNumBackendsInResolution));
SetNextResolutionForLbChannelAllBalancers();
// Send non-empty serverlist only after kServerlistDelayMs.
AdsServiceImpl::ResponseArgs args({
@ -1755,10 +1879,9 @@ TEST_P(FallbackTest, Update) {
for (size_t i = kNumBackendsInResolution; i < backends_.size(); ++i) {
EXPECT_EQ(0U, backends_[i]->backend_service()->request_count());
}
SetNextResolution(GetBackendPorts(kNumBackendsInResolution,
kNumBackendsInResolution +
kNumBackendsInResolutionUpdate),
kDefaultServiceConfig_.c_str());
SetNextResolution(GetBackendPorts(
kNumBackendsInResolution,
kNumBackendsInResolution + kNumBackendsInResolutionUpdate));
// Wait until the resolution update has been processed and all the new
// fallback backends are reachable.
WaitForAllBackends(kNumBackendsInResolution /* start_index */,
@ -1808,7 +1931,7 @@ TEST_P(FallbackTest, FallbackEarlyWhenBalancerChannelFails) {
const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor();
ResetStub(kFallbackTimeoutMs);
// Return an unreachable balancer and one fallback backend.
SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str());
SetNextResolution({backends_[0]->port()});
SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()});
// Send RPC with deadline less than the fallback timeout and make sure it
// succeeds.
@ -1821,7 +1944,7 @@ TEST_P(FallbackTest, FallbackEarlyWhenBalancerCallFails) {
const int kFallbackTimeoutMs = 10000 * grpc_test_slowdown_factor();
ResetStub(kFallbackTimeoutMs);
// Return one balancer and one fallback backend.
SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str());
SetNextResolution({backends_[0]->port()});
SetNextResolutionForLbChannelAllBalancers();
// Balancer drops call without sending a serverlist.
balancers_[0]->ads_service()->NotifyDoneWithAdsCall();
@ -1836,7 +1959,7 @@ TEST_P(FallbackTest, FallbackEarlyWhenBalancerCallFails) {
TEST_P(FallbackTest, FallbackIfResponseReceivedButChildNotReady) {
const int kFallbackTimeoutMs = 500 * grpc_test_slowdown_factor();
ResetStub(kFallbackTimeoutMs);
SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str());
SetNextResolution({backends_[0]->port()});
SetNextResolutionForLbChannelAllBalancers();
// Send a serverlist that only contains an unreachable backend before fallback
// timeout.
@ -1853,7 +1976,7 @@ TEST_P(FallbackTest, FallbackIfResponseReceivedButChildNotReady) {
// all the calls.
TEST_P(FallbackTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) {
// Return an unreachable balancer and one fallback backend.
SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str());
SetNextResolution({backends_[0]->port()});
SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()});
// Enter fallback mode because the LB channel fails to connect.
WaitForBackend(0);
@ -1877,7 +2000,7 @@ TEST_P(FallbackTest, FallbackModeIsExitedWhenBalancerSaysToDropAllCalls) {
// Tests that fallback mode is exited if the child policy becomes ready.
TEST_P(FallbackTest, FallbackModeIsExitedAfterChildRready) {
// Return an unreachable balancer and one fallback backend.
SetNextResolution({backends_[0]->port()}, kDefaultServiceConfig_.c_str());
SetNextResolution({backends_[0]->port()});
SetNextResolutionForLbChannel({grpc_pick_unused_port_or_die()});
// Enter fallback mode because the LB channel fails to connect.
WaitForBackend(0);
@ -1915,7 +2038,7 @@ class BalancerUpdateTest : public XdsEnd2endTest {
// Tests that the old LB call is still used after the balancer address update as
// long as that call is still alive.
TEST_P(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", {backends_[0]->port()}},
@ -1968,7 +2091,7 @@ TEST_P(BalancerUpdateTest, UpdateBalancersButKeepUsingOriginalBalancer) {
// xds keeps the initial connection (which by definition is also present in the
// update).
TEST_P(BalancerUpdateTest, Repeated) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
AdsServiceImpl::ResponseArgs args({
{"locality0", {backends_[0]->port()}},
@ -2033,7 +2156,7 @@ TEST_P(BalancerUpdateTest, Repeated) {
// backends according to the last balancer response, until a new balancer is
// reachable.
TEST_P(BalancerUpdateTest, DeadUpdate) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannel({balancers_[0]->port()});
AdsServiceImpl::ResponseArgs args({
{"locality0", {backends_[0]->port()}},
@ -2112,7 +2235,7 @@ class ClientLoadReportingTest : public XdsEnd2endTest {
// Tests that the load report received at the balancer is correct.
TEST_P(ClientLoadReportingTest, Vanilla) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannel({balancers_[0]->port()});
const size_t kNumRpcsPerAddress = 100;
// TODO(juanlishen): Partition the backends after multiple localities is
@ -2153,7 +2276,7 @@ TEST_P(ClientLoadReportingTest, Vanilla) {
// Tests that if the balancer restarts, the client load report contains the
// stats before and after the restart correctly.
TEST_P(ClientLoadReportingTest, BalancerRestart) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannel({balancers_[0]->port()});
const size_t kNumBackendsFirstPass = backends_.size() / 2;
const size_t kNumBackendsSecondPass =
@ -2219,7 +2342,7 @@ class ClientLoadReportingWithDropTest : public XdsEnd2endTest {
// Tests that the drop stats are correctly reported by client load reporting.
TEST_P(ClientLoadReportingWithDropTest, Vanilla) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolution({});
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 3000;
const uint32_t kDropPerMillionForLb = 100000;
@ -2281,28 +2404,66 @@ TEST_P(ClientLoadReportingWithDropTest, Vanilla) {
EXPECT_EQ(1U, balancers_[0]->ads_service()->response_count());
}
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, BasicTest, ::testing::Bool());
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, SecureNamingTest, ::testing::Bool());
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, LocalityMapTest, ::testing::Bool());
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, FailoverTest, ::testing::Bool());
grpc::string TestTypeName(const ::testing::TestParamInfo<TestType>& info) {
return info.param.AsString();
}
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, DropTest, ::testing::Bool());
// TODO(juanlishen): Load reporting disabled is currently tested only with DNS
// resolver. Once we implement CDS, test it via the xds resolver too.
INSTANTIATE_TEST_SUITE_P(XdsTest, BasicTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
INSTANTIATE_TEST_SUITE_P(XdsTest, SecureNamingTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
INSTANTIATE_TEST_SUITE_P(XdsTest, LocalityMapTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
INSTANTIATE_TEST_SUITE_P(XdsTest, FailoverTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
INSTANTIATE_TEST_SUITE_P(XdsTest, DropTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
// Fallback does not work with xds resolver.
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, FallbackTest,
::testing::Values(false));
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, BalancerUpdateTest,
::testing::Bool());
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, ClientLoadReportingTest,
::testing::Bool());
INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, ClientLoadReportingWithDropTest,
::testing::Bool());
INSTANTIATE_TEST_SUITE_P(XdsTest, FallbackTest,
::testing::Values(TestType(false, true),
TestType(false, false)),
&TestTypeName);
INSTANTIATE_TEST_SUITE_P(XdsTest, BalancerUpdateTest,
::testing::Values(TestType(false, true),
TestType(false, false),
TestType(true, true)),
&TestTypeName);
// Load reporting tests are not run with load reporting disabled.
INSTANTIATE_TEST_SUITE_P(XdsTest, ClientLoadReportingTest,
::testing::Values(TestType(false, true),
TestType(true, true)),
&TestTypeName);
// Load reporting tests are not run with load reporting disabled.
INSTANTIATE_TEST_SUITE_P(XdsTest, ClientLoadReportingWithDropTest,
::testing::Values(TestType(false, true),
TestType(true, true)),
&TestTypeName);
} // namespace
} // namespace testing
@ -2311,6 +2472,7 @@ INSTANTIATE_TEST_SUITE_P(UsesXdsResolver, ClientLoadReportingWithDropTest,
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc::testing::WriteBootstrapFiles();
const auto result = RUN_ALL_TESTS();
return result;
}

@ -76,7 +76,7 @@ grpc::string GetOauth2AccessToken() {
}
void UpdateActions(
std::unordered_map<grpc::string, std::function<bool()>>* actions) {}
std::unordered_map<grpc::string, std::function<bool()>>* /*actions*/) {}
std::shared_ptr<Channel> CreateChannelForTestCase(
const grpc::string& test_case,

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save