Merge branch 'transport-refs-2' into transport-refs-3

pull/36509/head
Craig Tiller 10 months ago
commit 0a3e1f60db
  1. 33
      BUILD
  2. 17
      CMakeLists.txt
  3. 1
      Makefile
  4. 1
      Package.swift
  5. 8
      build_autogenerated.yaml
  6. 2
      gRPC-C++.podspec
  7. 2
      gRPC-Core.podspec
  8. 1
      grpc.gemspec
  9. 1
      include/grpc/module.modulemap
  10. 62
      include/grpc/passive_listener.h
  11. 27
      include/grpcpp/passive_listener.h
  12. 1
      include/grpcpp/security/server_credentials.h
  13. 28
      include/grpcpp/server_builder.h
  14. 1
      package.xml
  15. 18
      src/core/BUILD
  16. 18
      src/core/ext/transport/binder/client/binder_connector.cc
  17. 17
      src/core/ext/transport/binder/client/channel_create.cc
  18. 6
      src/core/ext/transport/binder/client/channel_create_impl.cc
  19. 3
      src/core/ext/transport/binder/client/connection_id_generator.cc
  20. 12
      src/core/ext/transport/binder/client/endpoint_binder_pool.cc
  21. 4
      src/core/ext/transport/binder/client/jni_utils.cc
  22. 6
      src/core/ext/transport/binder/client/security_policy_setting.cc
  23. 12
      src/core/ext/transport/binder/security_policy/binder_security_policy.cc
  24. 10
      src/core/ext/transport/binder/server/binder_server.cc
  25. 4
      src/core/ext/transport/binder/server/binder_server_credentials.cc
  26. 29
      src/core/ext/transport/binder/transport/binder_transport.cc
  27. 3
      src/core/ext/transport/binder/transport/binder_transport.h
  28. 6
      src/core/ext/transport/binder/utils/ndk_binder.cc
  29. 8
      src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc
  30. 3
      src/core/ext/transport/binder/wire_format/binder_android.cc
  31. 21
      src/core/ext/transport/binder/wire_format/transaction.h
  32. 9
      src/core/ext/transport/binder/wire_format/wire_reader_impl.cc
  33. 15
      src/core/ext/transport/binder/wire_format/wire_writer.cc
  34. 7
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc
  35. 4
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.h
  36. 4
      src/core/ext/transport/chttp2/alpn/alpn.cc
  37. 15
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  38. 250
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  39. 33
      src/core/ext/transport/chttp2/server/chttp2_server.h
  40. 9
      src/core/ext/transport/chttp2/transport/bin_decoder.cc
  41. 12
      src/core/ext/transport/chttp2/transport/bin_encoder.cc
  42. 92
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  43. 5
      src/core/ext/transport/chttp2/transport/flow_control.cc
  44. 5
      src/core/ext/transport/chttp2/transport/flow_control.h
  45. 5
      src/core/ext/transport/chttp2/transport/frame.cc
  46. 3
      src/core/ext/transport/chttp2/transport/frame_data.cc
  47. 7
      src/core/ext/transport/chttp2/transport/frame_goaway.cc
  48. 3
      src/core/ext/transport/chttp2/transport/frame_ping.cc
  49. 3
      src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
  50. 5
      src/core/ext/transport/chttp2/transport/frame_window_update.cc
  51. 4
      src/core/ext/transport/chttp2/transport/hpack_encoder.cc
  52. 16
      src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc
  53. 3
      src/core/ext/transport/chttp2/transport/hpack_parse_result.cc
  54. 3
      src/core/ext/transport/chttp2/transport/hpack_parse_result.h
  55. 45
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  56. 7
      src/core/ext/transport/chttp2/transport/hpack_parser_table.cc
  57. 4
      src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc
  58. 23
      src/core/ext/transport/chttp2/transport/parsing.cc
  59. 3
      src/core/ext/transport/chttp2/transport/ping_callbacks.cc
  60. 12
      src/core/ext/transport/chttp2/transport/stream_lists.cc
  61. 4
      src/core/ext/transport/chttp2/transport/varint.h
  62. 4
      src/core/ext/transport/chttp2/transport/write_size_policy.cc
  63. 5
      src/core/ext/transport/chttp2/transport/writing.cc
  64. 7
      src/core/lib/event_engine/extensions/supports_fd.h
  65. 33
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  66. 2
      src/core/lib/event_engine/posix_engine/posix_engine.h
  67. 13
      src/core/lib/gpr/log.cc
  68. 14
      src/core/server/server.h
  69. 70
      src/core/tsi/alts/handshaker/alts_handshaker_client.cc
  70. 6
      src/core/tsi/alts/handshaker/alts_shared_resource.cc
  71. 36
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
  72. 6
      src/core/tsi/alts/handshaker/alts_tsi_utils.cc
  73. 6
      src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc
  74. 11
      src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc
  75. 6
      src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
  76. 7
      src/core/tsi/fake_transport_security.cc
  77. 8
      src/core/tsi/ssl/key_logging/ssl_key_logging.cc
  78. 18
      src/core/tsi/ssl/session_cache/ssl_session_cache.cc
  79. 6
      src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
  80. 35
      src/core/tsi/ssl_transport_security.cc
  81. 17
      src/core/tsi/ssl_transport_security_utils.cc
  82. 60
      src/cpp/server/server_builder.cc
  83. 65
      test/core/event_engine/event_engine_test_utils.h
  84. 1
      test/cpp/server/BUILD
  85. 55
      test/cpp/server/server_builder_test.cc
  86. 6
      test/cpp/util/BUILD
  87. 44
      test/cpp/util/channelz_sampler.cc
  88. 21
      test/cpp/util/channelz_sampler_test.cc
  89. 13
      test/cpp/util/cli_credentials.cc
  90. 10
      test/cpp/util/metrics_server.cc
  91. 106
      test/cpp/util/proto_reflection_descriptor_database.cc
  92. 5
      test/cpp/util/test_credentials_provider.cc
  93. 4
      tools/distrib/check_namespace_qualification.py
  94. 9
      tools/distrib/check_redundant_namespace_qualifiers.py
  95. 2
      tools/doxygen/Doxyfile.c++
  96. 2
      tools/doxygen/Doxyfile.c++.internal
  97. 1
      tools/doxygen/Doxyfile.core
  98. 1
      tools/doxygen/Doxyfile.core.internal
  99. 6
      tools/internal_ci/linux/grpc_xds_k8s_lb.cfg
  100. 193
      tools/internal_ci/linux/grpc_xds_k8s_lb.sh
  101. Some files were not shown because too many files have changed in this diff Show More

33
BUILD

@ -296,7 +296,6 @@ GRPC_PUBLIC_HDRS = [
"include/grpc/grpc_posix.h", "include/grpc/grpc_posix.h",
"include/grpc/grpc_security.h", "include/grpc/grpc_security.h",
"include/grpc/grpc_security_constants.h", "include/grpc/grpc_security_constants.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h", "include/grpc/slice.h",
"include/grpc/slice_buffer.h", "include/grpc/slice_buffer.h",
"include/grpc/status.h", "include/grpc/status.h",
@ -458,7 +457,6 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/service_type.h", "include/grpcpp/impl/service_type.h",
"include/grpcpp/impl/status.h", "include/grpcpp/impl/status.h",
"include/grpcpp/impl/sync.h", "include/grpcpp/impl/sync.h",
"include/grpcpp/passive_listener.h",
"include/grpcpp/resource_quota.h", "include/grpcpp/resource_quota.h",
"include/grpcpp/security/audit_logging.h", "include/grpcpp/security/audit_logging.h",
"include/grpcpp/security/tls_crl_provider.h", "include/grpcpp/security/tls_crl_provider.h",
@ -788,7 +786,6 @@ grpc_cc_library(
"absl/base:log_severity", "absl/base:log_severity",
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/log", "absl/log",
"absl/log:globals",
"absl/memory", "absl/memory",
"absl/random", "absl/random",
"absl/status", "absl/status",
@ -884,7 +881,7 @@ grpc_cc_library(
grpc_cc_library( grpc_cc_library(
name = "grpc_public_hdrs", name = "grpc_public_hdrs",
hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, hdrs = GRPC_PUBLIC_HDRS,
external_deps = [ external_deps = [
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -1134,6 +1131,7 @@ grpc_cc_library(
"absl/container:flat_hash_map", "absl/container:flat_hash_map",
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/hash", "absl/hash",
"absl/log:check",
"absl/memory", "absl/memory",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/status", "absl/status",
@ -2508,7 +2506,6 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider", "//src/core:grpc_backend_metric_provider",
"//src/core:grpc_crl_provider", "//src/core:grpc_crl_provider",
"//src/core:grpc_service_config", "//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc", "//src/core:grpc_transport_inproc",
"//src/core:json", "//src/core:json",
"//src/core:json_reader", "//src/core:json_reader",
@ -2567,7 +2564,6 @@ grpc_cc_library(
"grpc_security_base", "grpc_security_base",
"grpc_service_config_impl", "grpc_service_config_impl",
"grpc_trace", "grpc_trace",
"grpc_transport_chttp2",
"grpc_unsecure", "grpc_unsecure",
"grpcpp_backend_metric_recorder", "grpcpp_backend_metric_recorder",
"grpcpp_call_metric_recorder", "grpcpp_call_metric_recorder",
@ -2589,7 +2585,6 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider", "//src/core:grpc_backend_metric_provider",
"//src/core:grpc_insecure_credentials", "//src/core:grpc_insecure_credentials",
"//src/core:grpc_service_config", "//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc", "//src/core:grpc_transport_inproc",
"//src/core:ref_counted", "//src/core:ref_counted",
"//src/core:resource_quota", "//src/core:resource_quota",
@ -3963,6 +3958,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"//src/core:tsi/fake_transport_security.h", "//src/core:tsi/fake_transport_security.h",
], ],
external_deps = [
"absl/log:check",
],
language = "c++", language = "c++",
visibility = [ visibility = [
"@grpc:public", "@grpc:public",
@ -4080,6 +4078,7 @@ grpc_cc_library(
"//src/core:tsi/alts/handshaker/alts_tsi_utils.h", "//src/core:tsi/alts/handshaker/alts_tsi_utils.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/strings", "absl/strings",
"@com_google_protobuf//upb:base", "@com_google_protobuf//upb:base",
"@com_google_protobuf//upb:mem", "@com_google_protobuf//upb:mem",
@ -4139,6 +4138,7 @@ grpc_cc_library(
"//src/core:tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h", "//src/core:tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/types:span", "absl/types:span",
"libcrypto", "libcrypto",
"libssl", "libssl",
@ -4169,6 +4169,7 @@ grpc_cc_library(
"//src/core:tsi/ssl/session_cache/ssl_session_cache.h", "//src/core:tsi/ssl/session_cache/ssl_session_cache.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/memory", "absl/memory",
"libssl", "libssl",
], ],
@ -4452,6 +4453,7 @@ grpc_cc_library(
"//src/core:ext/transport/chttp2/transport/frame.h", "//src/core:ext/transport/chttp2/transport/frame.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -4497,6 +4499,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/functional:function_ref", "absl/functional:function_ref",
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
], ],
@ -4523,6 +4526,7 @@ grpc_cc_library(
"//src/core:ext/transport/chttp2/transport/hpack_parse_result.h", "//src/core:ext/transport/chttp2/transport/hpack_parse_result.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
"absl/strings:str_format", "absl/strings:str_format",
@ -4551,6 +4555,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/random:bit_gen_ref", "absl/random:bit_gen_ref",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
@ -4591,7 +4596,10 @@ grpc_cc_library(
hdrs = [ hdrs = [
"//src/core:ext/transport/chttp2/transport/hpack_encoder.h", "//src/core:ext/transport/chttp2/transport/hpack_encoder.h",
], ],
external_deps = ["absl/strings"], external_deps = [
"absl/log:check",
"absl/strings",
],
deps = [ deps = [
"chttp2_bin_encoder", "chttp2_bin_encoder",
"chttp2_legacy_frame", "chttp2_legacy_frame",
@ -4621,6 +4629,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"//src/core:ext/transport/chttp2/transport/bin_encoder.h", "//src/core:ext/transport/chttp2/transport/bin_encoder.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [ deps = [
"gpr", "gpr",
"gpr_platform", "gpr_platform",
@ -4637,7 +4648,10 @@ grpc_cc_library(
hdrs = [ hdrs = [
"//src/core:ext/transport/chttp2/transport/varint.h", "//src/core:ext/transport/chttp2/transport/varint.h",
], ],
external_deps = ["absl/base:core_headers"], external_deps = [
"absl/base:core_headers",
"absl/log:check",
],
deps = ["gpr"], deps = ["gpr"],
) )
@ -4696,6 +4710,7 @@ grpc_cc_library(
"absl/base:core_headers", "absl/base:core_headers",
"absl/container:flat_hash_map", "absl/container:flat_hash_map",
"absl/hash", "absl/hash",
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random", "absl/random",
"absl/random:bit_gen_ref", "absl/random:bit_gen_ref",

17
CMakeLists.txt generated

@ -1749,7 +1749,6 @@ target_link_libraries(gpr
absl::flags_marshalling absl::flags_marshalling
absl::any_invocable absl::any_invocable
absl::check absl::check
absl::log_globals
absl::log absl::log
absl::memory absl::memory
absl::random_random absl::random_random
@ -2747,7 +2746,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h include/grpc/impl/slice_type.h
include/grpc/load_reporting.h include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h include/grpc/slice.h
include/grpc/slice_buffer.h include/grpc/slice_buffer.h
include/grpc/status.h include/grpc/status.h
@ -3449,7 +3447,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h include/grpc/impl/slice_type.h
include/grpc/load_reporting.h include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h include/grpc/slice.h
include/grpc/slice_buffer.h include/grpc/slice_buffer.h
include/grpc/status.h include/grpc/status.h
@ -4318,7 +4315,6 @@ foreach(_hdr
include/grpcpp/impl/service_type.h include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h include/grpcpp/security/auth_context.h
@ -5059,7 +5055,6 @@ foreach(_hdr
include/grpcpp/impl/service_type.h include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h include/grpcpp/security/auth_context.h
@ -5511,7 +5506,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h include/grpc/impl/slice_type.h
include/grpc/load_reporting.h include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h include/grpc/slice.h
include/grpc/slice_buffer.h include/grpc/slice_buffer.h
include/grpc/status.h include/grpc/status.h
@ -26840,7 +26834,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h
test/core/event_engine/event_engine_test_utils.cc
test/core/test_util/cmdline.cc test/core/test_util/cmdline.cc
test/core/test_util/fuzzer_util.cc test/core/test_util/fuzzer_util.cc
test/core/test_util/grpc_profiler.cc test/core/test_util/grpc_profiler.cc
@ -36929,7 +36922,7 @@ generate_pkgconfig(
"gpr" "gpr"
"gRPC platform support library" "gRPC platform support library"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_globals absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant" "absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
"" ""
"-lgpr" "-lgpr"
"" ""
@ -36940,7 +36933,7 @@ generate_pkgconfig(
"gRPC" "gRPC"
"high performance general RPC framework" "high performance general RPC framework"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares openssl re2 zlib" "libcares openssl re2 zlib"
"-lgrpc" "-lgrpc"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36951,7 +36944,7 @@ generate_pkgconfig(
"gRPC unsecure" "gRPC unsecure"
"high performance general RPC framework without SSL" "high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares zlib" "libcares zlib"
"-lgrpc_unsecure" "-lgrpc_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36962,7 +36955,7 @@ generate_pkgconfig(
"gRPC++" "gRPC++"
"C++ wrapper for gRPC" "C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"libcares openssl re2 zlib" "libcares openssl re2 zlib"
"-lgrpc++" "-lgrpc++"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36973,7 +36966,7 @@ generate_pkgconfig(
"gRPC++ unsecure" "gRPC++ unsecure"
"C++ wrapper for gRPC without SSL" "C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure" "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"libcares zlib" "libcares zlib"
"-lgrpc++_unsecure" "-lgrpc++_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" "-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"

1
Makefile generated

@ -1776,7 +1776,6 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/propagation_bits.h \ include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \ include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \ include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \ include/grpc/slice.h \
include/grpc/slice_buffer.h \ include/grpc/slice_buffer.h \
include/grpc/status.h \ include/grpc/status.h \

1
Package.swift generated

@ -93,7 +93,6 @@ let package = Package(
"include/grpc/impl/propagation_bits.h", "include/grpc/impl/propagation_bits.h",
"include/grpc/impl/slice_type.h", "include/grpc/impl/slice_type.h",
"include/grpc/load_reporting.h", "include/grpc/load_reporting.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h", "include/grpc/slice.h",
"include/grpc/slice_buffer.h", "include/grpc/slice_buffer.h",
"include/grpc/status.h", "include/grpc/status.h",

@ -130,7 +130,6 @@ libs:
- absl/flags:marshalling - absl/flags:marshalling
- absl/functional:any_invocable - absl/functional:any_invocable
- absl/log:check - absl/log:check
- absl/log:globals
- absl/log:log - absl/log:log
- absl/memory:memory - absl/memory:memory
- absl/random:random - absl/random:random
@ -198,7 +197,6 @@ libs:
- include/grpc/impl/propagation_bits.h - include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h - include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h - include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h - include/grpc/slice.h
- include/grpc/slice_buffer.h - include/grpc/slice_buffer.h
- include/grpc/status.h - include/grpc/status.h
@ -2186,7 +2184,6 @@ libs:
- include/grpc/impl/propagation_bits.h - include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h - include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h - include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h - include/grpc/slice.h
- include/grpc/slice_buffer.h - include/grpc/slice_buffer.h
- include/grpc/status.h - include/grpc/status.h
@ -3794,7 +3791,6 @@ libs:
- include/grpcpp/impl/service_type.h - include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h - include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h - include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h - include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h - include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h - include/grpcpp/security/auth_context.h
@ -4222,7 +4218,6 @@ libs:
- include/grpcpp/impl/service_type.h - include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h - include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h - include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h - include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h - include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h - include/grpcpp/security/auth_context.h
@ -4371,7 +4366,6 @@ libs:
- include/grpc/impl/propagation_bits.h - include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h - include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h - include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h - include/grpc/slice.h
- include/grpc/slice_buffer.h - include/grpc/slice_buffer.h
- include/grpc/status.h - include/grpc/status.h
@ -17796,7 +17790,6 @@ targets:
build: test build: test
language: c++ language: c++
headers: headers:
- test/core/event_engine/event_engine_test_utils.h
- test/core/test_util/cmdline.h - test/core/test_util/cmdline.h
- test/core/test_util/evaluate_args_test_util.h - test/core/test_util/evaluate_args_test_util.h
- test/core/test_util/fuzzer_util.h - test/core/test_util/fuzzer_util.h
@ -17812,7 +17805,6 @@ targets:
- src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/simple_messages.proto - src/proto/grpc/testing/simple_messages.proto
- src/proto/grpc/testing/xds/v3/orca_load_report.proto - src/proto/grpc/testing/xds/v3/orca_load_report.proto
- test/core/event_engine/event_engine_test_utils.cc
- test/core/test_util/cmdline.cc - test/core/test_util/cmdline.cc
- test/core/test_util/fuzzer_util.cc - test/core/test_util/fuzzer_util.cc
- test/core/test_util/grpc_profiler.cc - test/core/test_util/grpc_profiler.cc

2
gRPC-C++.podspec generated

@ -176,7 +176,6 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/service_type.h', 'include/grpcpp/impl/service_type.h',
'include/grpcpp/impl/status.h', 'include/grpcpp/impl/status.h',
'include/grpcpp/impl/sync.h', 'include/grpcpp/impl/sync.h',
'include/grpcpp/passive_listener.h',
'include/grpcpp/resource_quota.h', 'include/grpcpp/resource_quota.h',
'include/grpcpp/security/audit_logging.h', 'include/grpcpp/security/audit_logging.h',
'include/grpcpp/security/auth_context.h', 'include/grpcpp/security/auth_context.h',
@ -245,7 +244,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version ss.dependency 'abseil/meta/type_traits', abseil_version

2
gRPC-Core.podspec generated

@ -168,7 +168,6 @@ Pod::Spec.new do |s|
'include/grpc/impl/propagation_bits.h', 'include/grpc/impl/propagation_bits.h',
'include/grpc/impl/slice_type.h', 'include/grpc/impl/slice_type.h',
'include/grpc/load_reporting.h', 'include/grpc/load_reporting.h',
'include/grpc/passive_listener.h',
'include/grpc/slice.h', 'include/grpc/slice.h',
'include/grpc/slice_buffer.h', 'include/grpc/slice_buffer.h',
'include/grpc/status.h', 'include/grpc/status.h',
@ -217,7 +216,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version ss.dependency 'abseil/meta/type_traits', abseil_version

1
grpc.gemspec generated

@ -99,7 +99,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/propagation_bits.h ) s.files += %w( include/grpc/impl/propagation_bits.h )
s.files += %w( include/grpc/impl/slice_type.h ) s.files += %w( include/grpc/impl/slice_type.h )
s.files += %w( include/grpc/load_reporting.h ) s.files += %w( include/grpc/load_reporting.h )
s.files += %w( include/grpc/passive_listener.h )
s.files += %w( include/grpc/slice.h ) s.files += %w( include/grpc/slice.h )
s.files += %w( include/grpc/slice_buffer.h ) s.files += %w( include/grpc/slice_buffer.h )
s.files += %w( include/grpc/status.h ) s.files += %w( include/grpc/status.h )

@ -38,7 +38,6 @@ header "byte_buffer.h"
header "impl/propagation_bits.h" header "impl/propagation_bits.h"
header "impl/slice_type.h" header "impl/slice_type.h"
header "load_reporting.h" header "load_reporting.h"
header "passive_listener.h"
header "slice.h" header "slice.h"
header "slice_buffer.h" header "slice_buffer.h"
header "status.h" header "status.h"

@ -1,62 +0,0 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_PASSIVE_LISTENER_H
#define GRPC_PASSIVE_LISTENER_H
#include <memory>
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
// #include <grpc/support/port_platform.h>
namespace grpc_core {
class Server;
namespace experimental {
class PassiveListenerImpl;
/// -- EXPERIMENTAL API --
/// Interface for used for Server Endpoint injection.
class PassiveListener {
public:
virtual ~PassiveListener() = default;
/// -- EXPERIMENTAL API --
///
/// Takes an Endpoint for an established connection, and treats it as if the
/// connection had been accepted by the server.
///
/// The server must be started before endpoints can be accepted.
virtual absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) = 0;
/// -- EXPERIMENTAL API --
///
/// Takes a connected file descriptor, and treats it as if the server had
/// accepted the connection itself.
///
/// Returns a failure status if the server's active EventEngine does not
/// support Endpoint creation from fds.
virtual absl::Status AcceptConnectedFd(int fd) = 0;
};
} // namespace experimental
} // namespace grpc_core
absl::Status grpc_server_add_passive_listener(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
#endif /* GRPC_PASSIVE_LISTENER_H */

@ -1,27 +0,0 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_PASSIVE_LISTENER_H
#define GRPCPP_PASSIVE_LISTENER_H
#include <grpc/passive_listener.h>
namespace grpc {
namespace experimental {
using grpc_core::experimental::PassiveListener;
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_PASSIVE_LISTENER_H

@ -84,7 +84,6 @@ class ServerCredentials : private grpc::internal::GrpcLibrary {
// Needed for access to AddPortToServer. // Needed for access to AddPortToServer.
friend class Server; friend class Server;
// Needed for access to c_creds_. // Needed for access to c_creds_.
friend class ServerBuilder;
friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials( friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials(
const std::shared_ptr<ServerCredentials>& fallback_credentials); const std::shared_ptr<ServerCredentials>& fallback_credentials);

@ -25,17 +25,13 @@
#include <vector> #include <vector>
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/passive_listener.h>
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/workaround_list.h> #include <grpc/support/workaround_list.h>
#include <grpcpp/impl/channel_argument_option.h> #include <grpcpp/impl/channel_argument_option.h>
#include <grpcpp/impl/server_builder_option.h> #include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/impl/server_builder_plugin.h> #include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/passive_listener.h>
#include <grpcpp/security/authorization_policy_provider.h> #include <grpcpp/security/authorization_policy_provider.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h> #include <grpcpp/server.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
#include <grpcpp/support/server_interceptor.h> #include <grpcpp/support/server_interceptor.h>
@ -295,18 +291,6 @@ class ServerBuilder {
void EnableCallMetricRecording( void EnableCallMetricRecording(
experimental::ServerMetricRecorder* server_metric_recorder = nullptr); experimental::ServerMetricRecorder* server_metric_recorder = nullptr);
// Creates a passive listener for Server Endpoint injection.
///
/// \a PasiveListener lets applications provide pre-established connections
/// to gRPC Servers. The server will behave as if it accepted the connection
/// itself on its own listening addresses.
///
/// This can be called multiple times to create passive listeners with
/// different server credentials.
ServerBuilder& AddPassiveListener(
std::shared_ptr<grpc::ServerCredentials> creds,
std::unique_ptr<grpc::experimental::PassiveListener>& passive_listener);
private: private:
ServerBuilder* builder_; ServerBuilder* builder_;
}; };
@ -380,17 +364,6 @@ class ServerBuilder {
private: private:
friend class grpc::testing::ServerBuilderPluginTest; friend class grpc::testing::ServerBuilderPluginTest;
struct UnstartedPassiveListener {
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener;
std::shared_ptr<grpc::ServerCredentials> credentials;
UnstartedPassiveListener(
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl> listener,
std::shared_ptr<grpc::ServerCredentials> creds)
: passive_listener(std::move(listener)),
credentials(std::move(creds)) {}
};
struct SyncServerSettings { struct SyncServerSettings {
SyncServerSettings() SyncServerSettings()
: num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
@ -415,7 +388,6 @@ class ServerBuilder {
std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_; std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
std::vector<std::unique_ptr<NamedService>> services_; std::vector<std::unique_ptr<NamedService>> services_;
std::vector<Port> ports_; std::vector<Port> ports_;
std::vector<UnstartedPassiveListener> unstarted_passive_listeners_;
SyncServerSettings sync_server_settings_; SyncServerSettings sync_server_settings_;

1
package.xml generated

@ -81,7 +81,6 @@
<file baseinstalldir="/" name="include/grpc/impl/propagation_bits.h" role="src" /> <file baseinstalldir="/" name="include/grpc/impl/propagation_bits.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/slice_type.h" role="src" /> <file baseinstalldir="/" name="include/grpc/impl/slice_type.h" role="src" />
<file baseinstalldir="/" name="include/grpc/load_reporting.h" role="src" /> <file baseinstalldir="/" name="include/grpc/load_reporting.h" role="src" />
<file baseinstalldir="/" name="include/grpc/passive_listener.h" role="src" />
<file baseinstalldir="/" name="include/grpc/slice.h" role="src" /> <file baseinstalldir="/" name="include/grpc/slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/slice_buffer.h" role="src" /> <file baseinstalldir="/" name="include/grpc/slice_buffer.h" role="src" />
<file baseinstalldir="/" name="include/grpc/status.h" role="src" /> <file baseinstalldir="/" name="include/grpc/status.h" role="src" />

@ -6599,6 +6599,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"ext/transport/chttp2/transport/hpack_encoder_table.h", "ext/transport/chttp2/transport/hpack_encoder_table.h",
], ],
external_deps = [
"absl/log:check",
],
language = "c++", language = "c++",
deps = [ deps = [
"hpack_constants", "hpack_constants",
@ -6616,6 +6619,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/functional:function_ref", "absl/functional:function_ref",
"absl/log:check",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
"absl/strings:str_format", "absl/strings:str_format",
@ -6665,6 +6669,7 @@ grpc_cc_library(
"absl/container:flat_hash_map", "absl/container:flat_hash_map",
"absl/functional:any_invocable", "absl/functional:any_invocable",
"absl/hash", "absl/hash",
"absl/log:check",
"absl/meta:type_traits", "absl/meta:type_traits",
"absl/random:bit_gen_ref", "absl/random:bit_gen_ref",
"absl/random:distributions", "absl/random:distributions",
@ -6687,6 +6692,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"ext/transport/chttp2/transport/write_size_policy.h", "ext/transport/chttp2/transport/write_size_policy.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [ deps = [
"time", "time",
"//:gpr", "//:gpr",
@ -6725,6 +6733,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"ext/transport/chttp2/transport/max_concurrent_streams_policy.h", "ext/transport/chttp2/transport/max_concurrent_streams_policy.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [ deps = [
"//:gpr", "//:gpr",
"//:gpr_platform", "//:gpr_platform",
@ -6782,6 +6793,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"ext/transport/chttp2/alpn/alpn.h", "ext/transport/chttp2/alpn/alpn.h",
], ],
external_deps = [
"absl/log:check",
],
language = "c++", language = "c++",
deps = [ deps = [
"useful", "useful",
@ -6799,6 +6813,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings:str_format", "absl/strings:str_format",
@ -6855,6 +6870,7 @@ grpc_cc_library(
], ],
external_deps = [ external_deps = [
"absl/base:core_headers", "absl/base:core_headers",
"absl/log:check",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
"absl/strings", "absl/strings",
@ -6869,8 +6885,6 @@ grpc_cc_library(
"connection_quota", "connection_quota",
"error", "error",
"error_utils", "error_utils",
"event_engine_extensions",
"event_engine_query_extensions",
"grpc_insecure_credentials", "grpc_insecure_credentials",
"handshaker_registry", "handshaker_registry",
"iomgr_fwd", "iomgr_fwd",

@ -33,6 +33,8 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include "absl/log/check.h"
#include <grpcpp/security/binder_security_policy.h> #include <grpcpp/security/binder_security_policy.h>
#include "src/core/client_channel/connector.h" #include "src/core/client_channel/connector.h"
@ -60,21 +62,21 @@ class BinderConnector : public grpc_core::SubchannelConnector {
size_t id_length = args.address->len - sizeof(un->sun_family); size_t id_length = args.address->len - sizeof(un->sun_family);
// The c-style string at least will have a null terminator, and the // The c-style string at least will have a null terminator, and the
// connection id itself should not be empty // connection id itself should not be empty
GPR_ASSERT(id_length >= 2); CHECK_GE(id_length, 2u);
// Make sure there is null terminator at the expected location before // Make sure there is null terminator at the expected location before
// reading from it // reading from it
GPR_ASSERT(un->sun_path[id_length - 1] == '\0'); CHECK_EQ(un->sun_path[id_length - 1], '\0');
conn_id_ = un->sun_path; conn_id_ = un->sun_path;
} }
#else #else
GPR_ASSERT(0); CHECK(0);
#endif #endif
gpr_log(GPR_INFO, "BinderConnector %p conn_id_ = %s", this, gpr_log(GPR_INFO, "BinderConnector %p conn_id_ = %s", this,
conn_id_.c_str()); conn_id_.c_str());
args_ = args; args_ = args;
GPR_ASSERT(notify_ == nullptr); CHECK_EQ(notify_, nullptr);
GPR_ASSERT(notify != nullptr); CHECK_NE(notify, nullptr);
notify_ = notify; notify_ = notify;
result_ = result; result_ = result;
@ -86,15 +88,15 @@ class BinderConnector : public grpc_core::SubchannelConnector {
} }
void OnConnected(std::unique_ptr<grpc_binder::Binder> endpoint_binder) { void OnConnected(std::unique_ptr<grpc_binder::Binder> endpoint_binder) {
GPR_ASSERT(endpoint_binder != nullptr); CHECK(endpoint_binder != nullptr);
grpc_core::Transport* transport = grpc_create_binder_transport_client( grpc_core::Transport* transport = grpc_create_binder_transport_client(
std::move(endpoint_binder), std::move(endpoint_binder),
grpc_binder::GetSecurityPolicySetting()->Get(conn_id_)); grpc_binder::GetSecurityPolicySetting()->Get(conn_id_));
GPR_ASSERT(transport != nullptr); CHECK_NE(transport, nullptr);
result_->channel_args = args_.channel_args; result_->channel_args = args_.channel_args;
result_->transport = transport; result_->transport = transport;
GPR_ASSERT(notify_ != nullptr); CHECK_NE(notify_, nullptr);
// ExecCtx is required here for running grpc_closure because this callback // ExecCtx is required here for running grpc_closure because this callback
// might be invoked from non-gRPC code // might be invoked from non-gRPC code
if (grpc_core::ExecCtx::Get() == nullptr) { if (grpc_core::ExecCtx::Get() == nullptr) {

@ -34,6 +34,7 @@
#ifdef GPR_SUPPORT_BINDER_TRANSPORT #ifdef GPR_SUPPORT_BINDER_TRANSPORT
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
@ -102,8 +103,8 @@ std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
const ChannelArguments& args) { const ChannelArguments& args) {
grpc_init(); grpc_init();
GPR_ASSERT(jni_env_void != nullptr); CHECK_NE(jni_env_void, nullptr);
GPR_ASSERT(security_policy != nullptr); CHECK_NE(security_policy, nullptr);
// Generate an unique connection ID that identifies this connection (Useful // Generate an unique connection ID that identifies this connection (Useful
// for mapping connection between Java and C++ code). // for mapping connection between Java and C++ code).
@ -163,7 +164,7 @@ std::shared_ptr<grpc::Channel> CreateBinderChannel(
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }
@ -175,7 +176,7 @@ std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }
@ -186,7 +187,7 @@ std::shared_ptr<grpc::Channel> CreateBinderChannel(
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }
@ -198,7 +199,7 @@ std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }
@ -207,7 +208,7 @@ bool InitializeBinderChannelJavaClass(void* jni_env_void) {
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }
@ -217,7 +218,7 @@ bool InitializeBinderChannelJavaClass(
"This APK is compiled with Android API level = %d, which is not " "This APK is compiled with Android API level = %d, which is not "
"supported. See port_platform.h for supported versions.", "supported. See port_platform.h for supported versions.",
__ANDROID_API__); __ANDROID_API__);
GPR_ASSERT(0); CHECK(0);
return {}; return {};
} }

@ -21,6 +21,8 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "src/core/ext/transport/binder/client/binder_connector.h" #include "src/core/ext/transport/binder/client/binder_connector.h"
#include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/transport/binder_transport.h"
#include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/ext/transport/binder/wire_format/binder.h"
@ -50,7 +52,7 @@ grpc_channel* CreateDirectBinderChannelImplForTesting(
grpc_core::Transport* transport = grpc_create_binder_transport_client( grpc_core::Transport* transport = grpc_create_binder_transport_client(
std::move(endpoint_binder), security_policy); std::move(endpoint_binder), security_policy);
GPR_ASSERT(transport != nullptr); CHECK_NE(transport, nullptr);
auto channel_args = grpc_core::CoreConfiguration::Get() auto channel_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning() .channel_args_preconditioning()
@ -60,7 +62,7 @@ grpc_channel* CreateDirectBinderChannelImplForTesting(
grpc_core::ChannelCreate("binder_target_placeholder", channel_args, grpc_core::ChannelCreate("binder_target_placeholder", channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, transport); GRPC_CLIENT_DIRECT_CHANNEL, transport);
// TODO(mingcl): Handle error properly // TODO(mingcl): Handle error properly
GPR_ASSERT(channel.ok()); CHECK(channel.ok());
grpc_channel_args_destroy(args); grpc_channel_args_destroy(args);
return channel->release()->c_ptr(); return channel->release()->c_ptr();
} }

@ -18,6 +18,7 @@
#ifndef GRPC_NO_BINDER #ifndef GRPC_NO_BINDER
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
namespace { namespace {
@ -55,7 +56,7 @@ std::string ConnectionIdGenerator::Generate(absl::string_view uri) {
// Insert a hyphen before serial number // Insert a hyphen before serial number
ret = absl::StrCat(s, "-", ++count_); ret = absl::StrCat(s, "-", ++count_);
} }
GPR_ASSERT(ret.length() < kPathLengthLimit); CHECK_LT(ret.length(), kPathLengthLimit);
return ret; return ret;
} }

@ -14,6 +14,8 @@
#include "src/core/ext/transport/binder/client/endpoint_binder_pool.h" #include "src/core/ext/transport/binder/client/endpoint_binder_pool.h"
#include "absl/log/check.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifndef GRPC_NO_BINDER #ifndef GRPC_NO_BINDER
@ -35,12 +37,12 @@ Java_io_grpc_binder_cpp_GrpcBinderConnection_notifyConnected__Ljava_lang_String_
jboolean isCopy; jboolean isCopy;
const char* conn_id = jni_env->GetStringUTFChars(conn_id_jstring, &isCopy); const char* conn_id = jni_env->GetStringUTFChars(conn_id_jstring, &isCopy);
gpr_log(GPR_INFO, "%s invoked with conn_id = %s", __func__, conn_id); gpr_log(GPR_INFO, "%s invoked with conn_id = %s", __func__, conn_id);
GPR_ASSERT(ibinder != nullptr); CHECK_NE(ibinder, nullptr);
grpc_binder::ndk_util::SpAIBinder aibinder = grpc_binder::ndk_util::SpAIBinder aibinder =
grpc_binder::FromJavaBinder(jni_env, ibinder); grpc_binder::FromJavaBinder(jni_env, ibinder);
gpr_log(GPR_INFO, "%s got aibinder = %p", __func__, aibinder.get()); gpr_log(GPR_INFO, "%s got aibinder = %p", __func__, aibinder.get());
auto b = std::make_unique<grpc_binder::BinderAndroid>(aibinder); auto b = std::make_unique<grpc_binder::BinderAndroid>(aibinder);
GPR_ASSERT(b != nullptr); CHECK(b != nullptr);
grpc_binder::GetEndpointBinderPool()->AddEndpointBinder(conn_id, grpc_binder::GetEndpointBinderPool()->AddEndpointBinder(conn_id,
std::move(b)); std::move(b));
if (isCopy == JNI_TRUE) { if (isCopy == JNI_TRUE) {
@ -63,7 +65,7 @@ void EndpointBinderPool::GetEndpointBinder(
if (binder_map_.count(conn_id)) { if (binder_map_.count(conn_id)) {
b = std::move(binder_map_[conn_id]); b = std::move(binder_map_[conn_id]);
binder_map_.erase(conn_id); binder_map_.erase(conn_id);
GPR_ASSERT(b != nullptr); CHECK(b != nullptr);
} else { } else {
if (pending_requests_.count(conn_id) != 0) { if (pending_requests_.count(conn_id) != 0) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
@ -75,14 +77,14 @@ void EndpointBinderPool::GetEndpointBinder(
return; return;
} }
} }
GPR_ASSERT(b != nullptr); CHECK(b != nullptr);
cb(std::move(b)); cb(std::move(b));
} }
void EndpointBinderPool::AddEndpointBinder( void EndpointBinderPool::AddEndpointBinder(
std::string conn_id, std::unique_ptr<grpc_binder::Binder> b) { std::string conn_id, std::unique_ptr<grpc_binder::Binder> b) {
gpr_log(GPR_INFO, "EndpointBinder added. conn_id = %s", conn_id.c_str()); gpr_log(GPR_INFO, "EndpointBinder added. conn_id = %s", conn_id.c_str());
GPR_ASSERT(b != nullptr); CHECK(b != nullptr);
// cb will be set in the following block if there is a pending callback // cb will be set in the following block if there is a pending callback
std::function<void(std::unique_ptr<grpc_binder::Binder>)> cb = nullptr; std::function<void(std::unique_ptr<grpc_binder::Binder>)> cb = nullptr;
{ {

@ -14,6 +14,8 @@
#include "src/core/ext/transport/binder/client/jni_utils.h" #include "src/core/ext/transport/binder/client/jni_utils.h"
#include "absl/log/check.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifndef GRPC_NO_BINDER #ifndef GRPC_NO_BINDER
@ -41,7 +43,7 @@ jclass FindNativeConnectionHelper(
} }
jclass global_cl = static_cast<jclass>(env->NewGlobalRef(cl)); jclass global_cl = static_cast<jclass>(env->NewGlobalRef(cl));
env->DeleteLocalRef(cl); env->DeleteLocalRef(cl);
GPR_ASSERT(global_cl != nullptr); CHECK_NE(global_cl, nullptr);
return global_cl; return global_cl;
}; };
static jclass connection_helper_class = do_find(); static jclass connection_helper_class = do_find();

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/log/check.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifndef GRPC_NO_BINDER #ifndef GRPC_NO_BINDER
@ -25,14 +27,14 @@ void SecurityPolicySetting::Set(
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
security_policy) { security_policy) {
grpc_core::MutexLock l(&m_); grpc_core::MutexLock l(&m_);
GPR_ASSERT(security_policy_map_.count(std::string(connection_id)) == 0); CHECK_EQ(security_policy_map_.count(std::string(connection_id)), 0u);
security_policy_map_[std::string(connection_id)] = security_policy; security_policy_map_[std::string(connection_id)] = security_policy;
} }
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
SecurityPolicySetting::Get(absl::string_view connection_id) { SecurityPolicySetting::Get(absl::string_view connection_id) {
grpc_core::MutexLock l(&m_); grpc_core::MutexLock l(&m_);
GPR_ASSERT(security_policy_map_.count(std::string(connection_id)) != 0); CHECK_NE(security_policy_map_.count(std::string(connection_id)), 0u);
return security_policy_map_[std::string(connection_id)]; return security_policy_map_[std::string(connection_id)];
} }

@ -23,6 +23,8 @@
#include <jni.h> #include <jni.h>
#include <unistd.h> #include <unistd.h>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/ext/transport/binder/client/jni_utils.h" #include "src/core/ext/transport/binder/client/jni_utils.h"
@ -61,8 +63,8 @@ JNIEnv* GetEnv(JavaVM* vm) {
JNIEnv* result = nullptr; JNIEnv* result = nullptr;
jint attach = vm->AttachCurrentThread(&result, nullptr); jint attach = vm->AttachCurrentThread(&result, nullptr);
GPR_ASSERT(JNI_OK == attach); CHECK(JNI_OK == attach);
GPR_ASSERT(nullptr != result); CHECK_NE(result, nullptr);
return result; return result;
} }
} // namespace } // namespace
@ -70,14 +72,14 @@ JNIEnv* GetEnv(JavaVM* vm) {
SameSignatureSecurityPolicy::SameSignatureSecurityPolicy(JavaVM* jvm, SameSignatureSecurityPolicy::SameSignatureSecurityPolicy(JavaVM* jvm,
jobject context) jobject context)
: jvm_(jvm) { : jvm_(jvm) {
GPR_ASSERT(jvm != nullptr); CHECK_NE(jvm, nullptr);
GPR_ASSERT(context != nullptr); CHECK_NE(context, nullptr);
JNIEnv* env = GetEnv(jvm_); JNIEnv* env = GetEnv(jvm_);
// Make sure the context is still valid when IsAuthorized() is called // Make sure the context is still valid when IsAuthorized() is called
context_ = env->NewGlobalRef(context); context_ = env->NewGlobalRef(context);
GPR_ASSERT(context_ != nullptr); CHECK_NE(context_, nullptr);
} }
SameSignatureSecurityPolicy::~SameSignatureSecurityPolicy() { SameSignatureSecurityPolicy::~SameSignatureSecurityPolicy() {

@ -22,6 +22,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -159,7 +160,7 @@ class BinderServerListener : public Server::ListenerInterface {
on_destroy_done_ = on_destroy_done; on_destroy_done_ = on_destroy_done;
} }
void Orphan() override { Unref(); } void Orphan() override { delete this; }
~BinderServerListener() override { ~BinderServerListener() override {
ExecCtx::Get()->Flush(); ExecCtx::Get()->Flush();
@ -212,7 +213,7 @@ class BinderServerListener : public Server::ListenerInterface {
// grpc_create_binder_transport_server(). // grpc_create_binder_transport_server().
Transport* server_transport = grpc_create_binder_transport_server( Transport* server_transport = grpc_create_binder_transport_server(
std::move(client_binder), security_policy_); std::move(client_binder), security_policy_);
GPR_ASSERT(server_transport); CHECK(server_transport);
grpc_error_handle error = server_->SetupTransport( grpc_error_handle error = server_->SetupTransport(
server_transport, nullptr, server_->channel_args(), nullptr); server_transport, nullptr, server_->channel_args(), nullptr);
return grpc_error_to_absl_status(error); return grpc_error_to_absl_status(error);
@ -239,8 +240,9 @@ bool AddBinderPort(const std::string& addr, grpc_server* server,
} }
std::string conn_id = addr.substr(kBinderUriScheme.size()); std::string conn_id = addr.substr(kBinderUriScheme.size());
Server* core_server = Server::FromC(server); Server* core_server = Server::FromC(server);
core_server->AddListener(MakeOrphanable<BinderServerListener>( core_server->AddListener(
core_server, conn_id, std::move(factory), security_policy)); OrphanablePtr<Server::ListenerInterface>(new BinderServerListener(
core_server, conn_id, std::move(factory), security_policy)));
return true; return true;
} }

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/log/check.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifndef GRPC_NO_BINDER #ifndef GRPC_NO_BINDER
@ -59,7 +61,7 @@ class BinderServerCredentialsImpl final : public ServerCredentials {
std::shared_ptr<ServerCredentials> BinderServerCredentials( std::shared_ptr<ServerCredentials> BinderServerCredentials(
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
security_policy) { security_policy) {
GPR_ASSERT(security_policy != nullptr); CHECK_NE(security_policy, nullptr);
return std::shared_ptr<ServerCredentials>( return std::shared_ptr<ServerCredentials>(
new BinderServerCredentialsImpl(security_policy)); new BinderServerCredentialsImpl(security_policy));
} }

@ -23,6 +23,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
@ -142,7 +143,7 @@ static void cancel_stream_locked(grpc_binder_transport* transport,
grpc_error_handle error) { grpc_error_handle error) {
gpr_log(GPR_INFO, "cancel_stream_locked"); gpr_log(GPR_INFO, "cancel_stream_locked");
if (!stream->is_closed) { if (!stream->is_closed) {
GPR_ASSERT(stream->cancel_self_error.ok()); CHECK(stream->cancel_self_error.ok());
stream->is_closed = true; stream->is_closed = true;
stream->cancel_self_error = error; stream->cancel_self_error = error;
transport->transport_stream_receiver->CancelStream(stream->tx_code); transport->transport_stream_receiver->CancelStream(stream->tx_code);
@ -196,8 +197,8 @@ static void recv_initial_metadata_locked(void* arg,
if (!stream->is_closed) { if (!stream->is_closed) {
grpc_error_handle error = [&] { grpc_error_handle error = [&] {
GPR_ASSERT(stream->recv_initial_metadata); CHECK(stream->recv_initial_metadata);
GPR_ASSERT(stream->recv_initial_metadata_ready); CHECK(stream->recv_initial_metadata_ready);
if (!args->initial_metadata.ok()) { if (!args->initial_metadata.ok()) {
gpr_log(GPR_ERROR, "Failed to parse initial metadata"); gpr_log(GPR_ERROR, "Failed to parse initial metadata");
return absl_status_to_grpc_error(args->initial_metadata.status()); return absl_status_to_grpc_error(args->initial_metadata.status());
@ -233,8 +234,8 @@ static void recv_message_locked(void* arg, grpc_error_handle /*error*/) {
if (!stream->is_closed) { if (!stream->is_closed) {
grpc_error_handle error = [&] { grpc_error_handle error = [&] {
GPR_ASSERT(stream->recv_message); CHECK(stream->recv_message);
GPR_ASSERT(stream->recv_message_ready); CHECK(stream->recv_message_ready);
if (!args->message.ok()) { if (!args->message.ok()) {
gpr_log(GPR_ERROR, "Failed to receive message"); gpr_log(GPR_ERROR, "Failed to receive message");
if (args->message.status().message() == if (args->message.status().message() ==
@ -277,8 +278,8 @@ static void recv_trailing_metadata_locked(void* arg,
if (!stream->is_closed) { if (!stream->is_closed) {
grpc_error_handle error = [&] { grpc_error_handle error = [&] {
GPR_ASSERT(stream->recv_trailing_metadata); CHECK(stream->recv_trailing_metadata);
GPR_ASSERT(stream->recv_trailing_metadata_finished); CHECK(stream->recv_trailing_metadata_finished);
if (!args->trailing_metadata.ok()) { if (!args->trailing_metadata.ok()) {
gpr_log(GPR_ERROR, "Failed to receive trailing metadata"); gpr_log(GPR_ERROR, "Failed to receive trailing metadata");
return absl_status_to_grpc_error(args->trailing_metadata.status()); return absl_status_to_grpc_error(args->trailing_metadata.status());
@ -339,11 +340,11 @@ class MetadataEncoder {
void Encode(grpc_core::HttpPathMetadata, const grpc_core::Slice& value) { void Encode(grpc_core::HttpPathMetadata, const grpc_core::Slice& value) {
// TODO(b/192208403): Figure out if it is correct to simply drop '/' // TODO(b/192208403): Figure out if it is correct to simply drop '/'
// prefix and treat it as rpc method name // prefix and treat it as rpc method name
GPR_ASSERT(value[0] == '/'); CHECK(value[0] == '/');
std::string path = std::string(value.as_string_view().substr(1)); std::string path = std::string(value.as_string_view().substr(1));
// Only client send method ref. // Only client send method ref.
GPR_ASSERT(is_client_); CHECK(is_client_);
tx_->SetMethodRef(path); tx_->SetMethodRef(path);
} }
@ -390,7 +391,7 @@ static void perform_stream_op_locked(void* stream_op,
grpc_binder_transport* transport = stream->t; grpc_binder_transport* transport = stream->t;
if (op->cancel_stream) { if (op->cancel_stream) {
// TODO(waynetu): Is this true? // TODO(waynetu): Is this true?
GPR_ASSERT(!op->send_initial_metadata && !op->send_message && CHECK(!op->send_initial_metadata && !op->send_message &&
!op->send_trailing_metadata && !op->recv_initial_metadata && !op->send_trailing_metadata && !op->recv_initial_metadata &&
!op->recv_message && !op->recv_trailing_metadata); !op->recv_message && !op->recv_trailing_metadata);
gpr_log(GPR_INFO, "cancel_stream is_client = %d", stream->is_client); gpr_log(GPR_INFO, "cancel_stream is_client = %d", stream->is_client);
@ -741,8 +742,8 @@ grpc_core::Transport* grpc_create_binder_transport_client(
security_policy) { security_policy) {
gpr_log(GPR_INFO, __func__); gpr_log(GPR_INFO, __func__);
GPR_ASSERT(endpoint_binder != nullptr); CHECK(endpoint_binder != nullptr);
GPR_ASSERT(security_policy != nullptr); CHECK_NE(security_policy, nullptr);
grpc_binder_transport* t = new grpc_binder_transport( grpc_binder_transport* t = new grpc_binder_transport(
std::move(endpoint_binder), /*is_client=*/true, security_policy); std::move(endpoint_binder), /*is_client=*/true, security_policy);
@ -756,8 +757,8 @@ grpc_core::Transport* grpc_create_binder_transport_server(
security_policy) { security_policy) {
gpr_log(GPR_INFO, __func__); gpr_log(GPR_INFO, __func__);
GPR_ASSERT(client_binder != nullptr); CHECK(client_binder != nullptr);
GPR_ASSERT(security_policy != nullptr); CHECK_NE(security_policy, nullptr);
grpc_binder_transport* t = new grpc_binder_transport( grpc_binder_transport* t = new grpc_binder_transport(
std::move(client_binder), /*is_client=*/false, security_policy); std::move(client_binder), /*is_client=*/false, security_policy);

@ -22,6 +22,7 @@
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -74,7 +75,7 @@ struct grpc_binder_transport final : public grpc_core::FilterStackTransport {
// TODO(mingcl): Wrap around when all tx codes are used. "If we do detect a // TODO(mingcl): Wrap around when all tx codes are used. "If we do detect a
// collision however, we will fail the new call with UNAVAILABLE, and shut // collision however, we will fail the new call with UNAVAILABLE, and shut
// down the transport gracefully." // down the transport gracefully."
GPR_ASSERT(next_free_tx_code <= LAST_CALL_TRANSACTION); CHECK(next_free_tx_code <= LAST_CALL_TRANSACTION);
return next_free_tx_code++; return next_free_tx_code++;
} }

@ -22,6 +22,8 @@
#include <dlfcn.h> #include <dlfcn.h>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
@ -36,7 +38,7 @@ void* GetNdkBinderHandle() {
gpr_log( gpr_log(
GPR_ERROR, GPR_ERROR,
"Cannot open libbinder_ndk.so. Does this device support API level 29?"); "Cannot open libbinder_ndk.so. Does this device support API level 29?");
GPR_ASSERT(0); CHECK(0);
} }
return handle; return handle;
} }
@ -102,7 +104,7 @@ namespace ndk_util {
"dlsym failed. Cannot find %s in libbinder_ndk.so. " \ "dlsym failed. Cannot find %s in libbinder_ndk.so. " \
"BinderTransport requires API level >= 33", \ "BinderTransport requires API level >= 33", \
#name); \ #name); \
GPR_ASSERT(0); \ CHECK(0); \
} \ } \
return ptr return ptr

@ -22,6 +22,8 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
@ -38,7 +40,7 @@ void TransportStreamReceiverImpl::RegisterRecvInitialMetadata(
absl::StatusOr<Metadata> initial_metadata{}; absl::StatusOr<Metadata> initial_metadata{};
{ {
grpc_core::MutexLock l(&m_); grpc_core::MutexLock l(&m_);
GPR_ASSERT(initial_metadata_cbs_.count(id) == 0); CHECK_EQ(initial_metadata_cbs_.count(id), 0u);
auto iter = pending_initial_metadata_.find(id); auto iter = pending_initial_metadata_.find(id);
if (iter == pending_initial_metadata_.end()) { if (iter == pending_initial_metadata_.end()) {
if (trailing_metadata_recvd_.count(id)) { if (trailing_metadata_recvd_.count(id)) {
@ -66,7 +68,7 @@ void TransportStreamReceiverImpl::RegisterRecvMessage(
absl::StatusOr<std::string> message{}; absl::StatusOr<std::string> message{};
{ {
grpc_core::MutexLock l(&m_); grpc_core::MutexLock l(&m_);
GPR_ASSERT(message_cbs_.count(id) == 0); CHECK_EQ(message_cbs_.count(id), 0u);
auto iter = pending_message_.find(id); auto iter = pending_message_.find(id);
if (iter == pending_message_.end()) { if (iter == pending_message_.end()) {
// If we'd already received trailing-metadata and there's no pending // If we'd already received trailing-metadata and there's no pending
@ -100,7 +102,7 @@ void TransportStreamReceiverImpl::RegisterRecvTrailingMetadata(
std::pair<absl::StatusOr<Metadata>, int> trailing_metadata{}; std::pair<absl::StatusOr<Metadata>, int> trailing_metadata{};
{ {
grpc_core::MutexLock l(&m_); grpc_core::MutexLock l(&m_);
GPR_ASSERT(trailing_metadata_cbs_.count(id) == 0); CHECK_EQ(trailing_metadata_cbs_.count(id), 0u);
auto iter = pending_trailing_metadata_.find(id); auto iter = pending_trailing_metadata_.find(id);
if (iter == pending_trailing_metadata_.end()) { if (iter == pending_trailing_metadata_.end()) {
trailing_metadata_cbs_[id] = std::move(cb); trailing_metadata_cbs_[id] = std::move(cb);

@ -20,6 +20,7 @@
#include <map> #include <map>
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -152,7 +153,7 @@ TransactionReceiverAndroid::TransactionReceiverAndroid(
args.wire_reader_ref = wire_reader_ref; args.wire_reader_ref = wire_reader_ref;
args.callback = &transact_cb_; args.callback = &transact_cb_;
binder_ = ndk_util::AIBinder_new(aibinder_class, &args); binder_ = ndk_util::AIBinder_new(aibinder_class, &args);
GPR_ASSERT(binder_); CHECK(binder_);
gpr_log(GPR_INFO, "ndk_util::AIBinder_associateClass = %d", gpr_log(GPR_INFO, "ndk_util::AIBinder_associateClass = %d",
static_cast<int>( static_cast<int>(
ndk_util::AIBinder_associateClass(binder_, aibinder_class))); ndk_util::AIBinder_associateClass(binder_, aibinder_class)));

@ -18,6 +18,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -45,33 +46,33 @@ class Transaction {
// TODO(mingcl): Consider using string_view // TODO(mingcl): Consider using string_view
void SetPrefix(Metadata prefix_metadata) { void SetPrefix(Metadata prefix_metadata) {
prefix_metadata_ = prefix_metadata; prefix_metadata_ = prefix_metadata;
GPR_ASSERT((flags_ & kFlagPrefix) == 0); CHECK_EQ((flags_ & kFlagPrefix), 0);
flags_ |= kFlagPrefix; flags_ |= kFlagPrefix;
} }
void SetMethodRef(std::string method_ref) { void SetMethodRef(std::string method_ref) {
GPR_ASSERT(is_client_); CHECK(is_client_);
method_ref_ = method_ref; method_ref_ = method_ref;
} }
void SetData(std::string message_data) { void SetData(std::string message_data) {
message_data_ = message_data; message_data_ = message_data;
GPR_ASSERT((flags_ & kFlagMessageData) == 0); CHECK_EQ((flags_ & kFlagMessageData), 0);
flags_ |= kFlagMessageData; flags_ |= kFlagMessageData;
} }
void SetSuffix(Metadata suffix_metadata) { void SetSuffix(Metadata suffix_metadata) {
if (is_client_) GPR_ASSERT(suffix_metadata.empty()); if (is_client_) CHECK(suffix_metadata.empty());
suffix_metadata_ = suffix_metadata; suffix_metadata_ = suffix_metadata;
GPR_ASSERT((flags_ & kFlagSuffix) == 0); CHECK_EQ((flags_ & kFlagSuffix), 0);
flags_ |= kFlagSuffix; flags_ |= kFlagSuffix;
} }
void SetStatusDescription(std::string status_desc) { void SetStatusDescription(std::string status_desc) {
GPR_ASSERT(!is_client_); CHECK(!is_client_);
GPR_ASSERT((flags_ & kFlagStatusDescription) == 0); CHECK_EQ((flags_ & kFlagStatusDescription), 0);
status_desc_ = status_desc; status_desc_ = status_desc;
} }
void SetStatus(int status) { void SetStatus(int status) {
GPR_ASSERT(!is_client_); CHECK(!is_client_);
GPR_ASSERT((flags_ >> 16) == 0); CHECK_EQ((flags_ >> 16), 0);
GPR_ASSERT(status < (1 << 16)); CHECK(status < (1 << 16));
flags_ |= (status << 16); flags_ |= (status << 16);
} }

@ -25,6 +25,7 @@
#include <vector> #include <vector>
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -305,7 +306,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransaction(
absl::Seconds(5))) { absl::Seconds(5))) {
return absl::DeadlineExceededError("wire_writer_ is not ready in time!"); return absl::DeadlineExceededError("wire_writer_ is not ready in time!");
} }
GPR_ASSERT(wire_writer_); CHECK(wire_writer_);
// wire_writer_ should not be accessed while holding mu_! // wire_writer_ should not be accessed while holding mu_!
// Otherwise, it is possible that // Otherwise, it is possible that
// 1. wire_writer_::mu_ is acquired before mu_ (NDK call back during // 1. wire_writer_::mu_ is acquired before mu_ (NDK call back during
@ -323,7 +324,7 @@ absl::Status WireReaderImpl::ProcessStreamingTransaction(
absl::Status WireReaderImpl::ProcessStreamingTransactionImpl( absl::Status WireReaderImpl::ProcessStreamingTransactionImpl(
transaction_code_t code, ReadableParcel* parcel, int* cancellation_flags, transaction_code_t code, ReadableParcel* parcel, int* cancellation_flags,
std::queue<absl::AnyInvocable<void() &&>>& deferred_func_queue) { std::queue<absl::AnyInvocable<void() &&>>& deferred_func_queue) {
GPR_ASSERT(cancellation_flags); CHECK(cancellation_flags);
num_incoming_bytes_ += parcel->GetDataSize(); num_incoming_bytes_ += parcel->GetDataSize();
gpr_log(GPR_INFO, "Total incoming bytes: %" PRId64, num_incoming_bytes_); gpr_log(GPR_INFO, "Total incoming bytes: %" PRId64, num_incoming_bytes_);
@ -360,8 +361,8 @@ absl::Status WireReaderImpl::ProcessStreamingTransactionImpl(
// TODO(waynetu): According to the protocol, "The sequence number will wrap // TODO(waynetu): According to the protocol, "The sequence number will wrap
// around to 0 if more than 2^31 messages are sent." For now we'll just // around to 0 if more than 2^31 messages are sent." For now we'll just
// assert that it never reach such circumstances. // assert that it never reach such circumstances.
GPR_ASSERT(expectation < std::numeric_limits<int32_t>::max() && CHECK(expectation < std::numeric_limits<int32_t>::max())
"Sequence number too large"); << "Sequence number too large";
expectation++; expectation++;
gpr_log(GPR_DEBUG, "sequence number = %d", seq_num); gpr_log(GPR_DEBUG, "sequence number = %d", seq_num);
if (flags & kFlagPrefix) { if (flags & kFlagPrefix) {

@ -21,6 +21,7 @@
#include <utility> #include <utility>
#include "absl/cleanup/cleanup.h" #include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/types/variant.h" #include "absl/types/variant.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -122,7 +123,7 @@ absl::Status WireWriterImpl::MakeBinderTransaction(
gpr_log(GPR_INFO, "Total outgoing bytes: %" PRId64, gpr_log(GPR_INFO, "Total outgoing bytes: %" PRId64,
num_outgoing_bytes_.load()); num_outgoing_bytes_.load());
} }
GPR_ASSERT(!is_transacting_); CHECK(!is_transacting_);
is_transacting_ = true; is_transacting_ = true;
absl::Status result = binder_->Transact(tx_code); absl::Status result = binder_->Transact(tx_code);
is_transacting_ = false; is_transacting_ = false;
@ -155,10 +156,10 @@ absl::Status WireWriterImpl::RunStreamTx(
bool* is_last_chunk) { bool* is_last_chunk) {
Transaction* tx = stream_tx->tx.get(); Transaction* tx = stream_tx->tx.get();
// Transaction without data flag should go to fast path. // Transaction without data flag should go to fast path.
GPR_ASSERT(tx->GetFlags() & kFlagMessageData); CHECK(tx->GetFlags() & kFlagMessageData);
absl::string_view data = tx->GetMessageData(); absl::string_view data = tx->GetMessageData();
GPR_ASSERT(stream_tx->bytes_sent <= static_cast<int64_t>(data.size())); CHECK(stream_tx->bytes_sent <= static_cast<int64_t>(data.size()));
int flags = kFlagMessageData; int flags = kFlagMessageData;
@ -206,7 +207,7 @@ absl::Status WireWriterImpl::RunStreamTx(
} }
void WireWriterImpl::RunScheduledTxInternal(RunScheduledTxArgs* args) { void WireWriterImpl::RunScheduledTxInternal(RunScheduledTxArgs* args) {
GPR_ASSERT(args->writer == this); CHECK(args->writer == this);
if (absl::holds_alternative<RunScheduledTxArgs::AckTx>(args->tx)) { if (absl::holds_alternative<RunScheduledTxArgs::AckTx>(args->tx)) {
int64_t num_bytes = int64_t num_bytes =
absl::get<RunScheduledTxArgs::AckTx>(args->tx).num_bytes; absl::get<RunScheduledTxArgs::AckTx>(args->tx).num_bytes;
@ -223,7 +224,7 @@ void WireWriterImpl::RunScheduledTxInternal(RunScheduledTxArgs* args) {
delete args; delete args;
return; return;
} }
GPR_ASSERT(absl::holds_alternative<RunScheduledTxArgs::StreamTx>(args->tx)); CHECK(absl::holds_alternative<RunScheduledTxArgs::StreamTx>(args->tx));
RunScheduledTxArgs::StreamTx* stream_tx = RunScheduledTxArgs::StreamTx* stream_tx =
&absl::get<RunScheduledTxArgs::StreamTx>(args->tx); &absl::get<RunScheduledTxArgs::StreamTx>(args->tx);
// Be reservative. Decrease CombinerTxCount after the data size of this // Be reservative. Decrease CombinerTxCount after the data size of this
@ -232,7 +233,7 @@ void WireWriterImpl::RunScheduledTxInternal(RunScheduledTxArgs* args) {
auto decrease_combiner_tx_count = absl::MakeCleanup([this]() { auto decrease_combiner_tx_count = absl::MakeCleanup([this]() {
{ {
grpc_core::MutexLock lock(&flow_control_mu_); grpc_core::MutexLock lock(&flow_control_mu_);
GPR_ASSERT(num_non_acked_tx_in_combiner_ > 0); CHECK_GT(num_non_acked_tx_in_combiner_, 0);
num_non_acked_tx_in_combiner_--; num_non_acked_tx_in_combiner_--;
} }
// New transaction might be ready to be scheduled. // New transaction might be ready to be scheduled.
@ -271,7 +272,7 @@ void WireWriterImpl::RunScheduledTxInternal(RunScheduledTxArgs* args) {
absl::Status WireWriterImpl::RpcCall(std::unique_ptr<Transaction> tx) { absl::Status WireWriterImpl::RpcCall(std::unique_ptr<Transaction> tx) {
// TODO(mingcl): check tx_code <= last call id // TODO(mingcl): check tx_code <= last call id
GPR_ASSERT(tx->GetTxCode() >= kFirstCallId); CHECK(tx->GetTxCode() >= kFirstCallId);
auto args = new RunScheduledTxArgs(); auto args = new RunScheduledTxArgs();
args->writer = this; args->writer = this;
args->tx = RunScheduledTxArgs::StreamTx(); args->tx = RunScheduledTxArgs::StreamTx();

@ -103,8 +103,8 @@ absl::StatusOr<int> ChaoticGoodServerListener::Bind(
str.ok() ? str->c_str() : str.status().ToString().c_str()); str.ok() ? str->c_str() : str.status().ToString().c_str());
} }
EventEngine::Listener::AcceptCallback accept_cb = EventEngine::Listener::AcceptCallback accept_cb =
[self = RefAsSubclass<ChaoticGoodServerListener>()]( [self = Ref()](std::unique_ptr<EventEngine::Endpoint> ep,
std::unique_ptr<EventEngine::Endpoint> ep, MemoryAllocator) { MemoryAllocator) {
ExecCtx exec_ctx; ExecCtx exec_ctx;
MutexLock lock(&self->mu_); MutexLock lock(&self->mu_);
if (self->shutdown_) return; if (self->shutdown_) return;
@ -149,8 +149,7 @@ absl::Status ChaoticGoodServerListener::StartListening() {
ChaoticGoodServerListener::ActiveConnection::ActiveConnection( ChaoticGoodServerListener::ActiveConnection::ActiveConnection(
RefCountedPtr<ChaoticGoodServerListener> listener, RefCountedPtr<ChaoticGoodServerListener> listener,
std::unique_ptr<EventEngine::Endpoint> endpoint) std::unique_ptr<EventEngine::Endpoint> endpoint)
: memory_allocator_(listener->memory_allocator_), : memory_allocator_(listener->memory_allocator_), listener_(listener) {
listener_(std::move(listener)) {
handshaking_state_ = MakeRefCounted<HandshakingState>(Ref()); handshaking_state_ = MakeRefCounted<HandshakingState>(Ref());
handshaking_state_->Start(std::move(endpoint)); handshaking_state_->Start(std::move(endpoint));
} }

@ -49,7 +49,9 @@
namespace grpc_core { namespace grpc_core {
namespace chaotic_good { namespace chaotic_good {
class ChaoticGoodServerListener final : public Server::ListenerInterface { class ChaoticGoodServerListener final
: public Server::ListenerInterface,
public RefCounted<ChaoticGoodServerListener> {
public: public:
static absl::AnyInvocable<std::string()> DefaultConnectionIDGenerator() { static absl::AnyInvocable<std::string()> DefaultConnectionIDGenerator() {
return [bitgen = absl::BitGen()]() mutable { return [bitgen = absl::BitGen()]() mutable {

@ -18,6 +18,8 @@
#include "src/core/ext/transport/chttp2/alpn/alpn.h" #include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -42,6 +44,6 @@ size_t grpc_chttp2_num_alpn_versions(void) {
} }
const char* grpc_chttp2_get_alpn_version_index(size_t i) { const char* grpc_chttp2_get_alpn_version_index(size_t i) {
GPR_ASSERT(i < GPR_ARRAY_SIZE(supported_versions)); CHECK_LT(i, GPR_ARRAY_SIZE(supported_versions));
return supported_versions[i]; return supported_versions[i];
} }

@ -24,6 +24,7 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -104,11 +105,11 @@ void Chttp2Connector::Connect(const Args& args, Result* result,
grpc_closure* notify) { grpc_closure* notify) {
{ {
MutexLock lock(&mu_); MutexLock lock(&mu_);
GPR_ASSERT(notify_ == nullptr); CHECK_EQ(notify_, nullptr);
args_ = args; args_ = args;
result_ = result; result_ = result;
notify_ = notify; notify_ = notify;
GPR_ASSERT(endpoint_ == nullptr); CHECK_EQ(endpoint_, nullptr);
event_engine_ = args_.channel_args.GetObject<EventEngine>(); event_engine_ = args_.channel_args.GetObject<EventEngine>();
} }
absl::StatusOr<std::string> address = grpc_sockaddr_to_uri(args.address); absl::StatusOr<std::string> address = grpc_sockaddr_to_uri(args.address);
@ -166,7 +167,7 @@ void Chttp2Connector::OnHandshakeDone(void* arg, grpc_error_handle error) {
} else if (args->endpoint != nullptr) { } else if (args->endpoint != nullptr) {
self->result_->transport = self->result_->transport =
grpc_create_chttp2_transport(args->args, args->endpoint, true); grpc_create_chttp2_transport(args->args, args->endpoint, true);
GPR_ASSERT(self->result_->transport != nullptr); CHECK_NE(self->result_->transport, nullptr);
self->result_->socket_node = self->result_->socket_node =
grpc_chttp2_transport_get_socket_node(self->result_->transport); grpc_chttp2_transport_get_socket_node(self->result_->transport);
self->result_->channel_args = args->args; self->result_->channel_args = args->args;
@ -188,7 +189,7 @@ void Chttp2Connector::OnHandshakeDone(void* arg, grpc_error_handle error) {
// If the handshaking succeeded but there is no endpoint, then the // If the handshaking succeeded but there is no endpoint, then the
// handshaker may have handed off the connection to some external // handshaker may have handed off the connection to some external
// code. Just verify that exit_early flag is set. // code. Just verify that exit_early flag is set.
GPR_DEBUG_ASSERT(args->exit_early); DCHECK(args->exit_early);
NullThenSchedClosure(DEBUG_LOCATION, &self->notify_, error); NullThenSchedClosure(DEBUG_LOCATION, &self->notify_, error);
} }
self->handshake_mgr_.reset(); self->handshake_mgr_.reset();
@ -396,14 +397,14 @@ grpc_channel* grpc_channel_create_from_fd(const char* target, int fd,
.SetObject(creds->Ref()); .SetObject(creds->Ref());
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); CHECK_EQ(fcntl(fd, F_SETFL, flags | O_NONBLOCK), 0);
grpc_endpoint* client = grpc_tcp_create_from_fd( grpc_endpoint* client = grpc_tcp_create_from_fd(
grpc_fd_create(fd, "client", true), grpc_fd_create(fd, "client", true),
grpc_event_engine::experimental::ChannelArgsEndpointConfig(final_args), grpc_event_engine::experimental::ChannelArgsEndpointConfig(final_args),
"fd-client"); "fd-client");
grpc_core::Transport* transport = grpc_core::Transport* transport =
grpc_create_chttp2_transport(final_args, client, true); grpc_create_chttp2_transport(final_args, client, true);
GPR_ASSERT(transport); CHECK(transport);
auto channel = grpc_core::ChannelCreate( auto channel = grpc_core::ChannelCreate(
target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
if (channel.ok()) { if (channel.ok()) {
@ -424,7 +425,7 @@ grpc_channel* grpc_channel_create_from_fd(const char* /* target */,
int /* fd */, int /* fd */,
grpc_channel_credentials* /* creds*/, grpc_channel_credentials* /* creds*/,
const grpc_channel_args* /* args */) { const grpc_channel_args* /* args */) {
GPR_ASSERT(0); CHECK(0);
return nullptr; return nullptr;
} }

@ -29,6 +29,7 @@
#include <vector> #include <vector>
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -41,7 +42,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_posix.h> #include <grpc/grpc_posix.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/passive_listener.h>
#include <grpc/slice_buffer.h> #include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -58,8 +58,6 @@
#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/event_engine/extensions/supports_fd.h"
#include "src/core/lib/event_engine/query_extensions.h"
#include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -69,7 +67,6 @@
#include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/gprpp/unique_type_name.h"
#include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/event_engine_shims/endpoint.h"
#include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resolve_address.h"
@ -96,11 +93,9 @@
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
namespace grpc_core { namespace grpc_core {
namespace {
using grpc_event_engine::experimental::ChannelArgsEndpointConfig; using ::grpc_event_engine::experimental::EventEngine;
using grpc_event_engine::experimental::EventEngine;
using grpc_event_engine::experimental::EventEngineSupportsFdExtension;
using grpc_event_engine::experimental::QueryExtension;
const char kUnixUriPrefix[] = "unix:"; const char kUnixUriPrefix[] = "unix:";
const char kUnixAbstractUriPrefix[] = "unix-abstract:"; const char kUnixAbstractUriPrefix[] = "unix-abstract:";
@ -117,23 +112,14 @@ class Chttp2ServerListener : public Server::ListenerInterface {
Server* server, const char* name, const ChannelArgs& args, Server* server, const char* name, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier); Chttp2ServerArgsModifier args_modifier);
static Chttp2ServerListener* CreateForPassiveListener(
Server* server, const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener);
// Do not instantiate directly. Use one of the factory methods above. // Do not instantiate directly. Use one of the factory methods above.
Chttp2ServerListener(Server* server, const ChannelArgs& args, Chttp2ServerListener(Server* server, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier, Chttp2ServerArgsModifier args_modifier);
grpc_server_config_fetcher* config_fetcher,
std::shared_ptr<experimental::PassiveListenerImpl>
passive_listener = nullptr);
~Chttp2ServerListener() override; ~Chttp2ServerListener() override;
void Start(Server* server, void Start(Server* server,
const std::vector<grpc_pollset*>* pollsets) override; const std::vector<grpc_pollset*>* pollsets) override;
void AcceptConnectedEndpoint(std::unique_ptr<EventEngine::Endpoint> endpoint);
channelz::ListenSocketNode* channelz_listen_socket_node() const override { channelz::ListenSocketNode* channelz_listen_socket_node() const override {
return channelz_listen_socket_.get(); return channelz_listen_socket_.get();
} }
@ -143,8 +129,6 @@ class Chttp2ServerListener : public Server::ListenerInterface {
void Orphan() override; void Orphan() override;
private: private:
friend class experimental::PassiveListenerImpl;
class ConfigFetcherWatcher class ConfigFetcherWatcher
: public grpc_server_config_fetcher::WatcherInterface { : public grpc_server_config_fetcher::WatcherInterface {
public: public:
@ -251,8 +235,34 @@ class Chttp2ServerListener : public Server::ListenerInterface {
static void DestroyListener(Server* /*server*/, void* arg, static void DestroyListener(Server* /*server*/, void* arg,
grpc_closure* destroy_done); grpc_closure* destroy_done);
Server* const server_ = nullptr; // The interface required by RefCountedPtr<> has been manually implemented
grpc_tcp_server* tcp_server_ = nullptr; // here to take a ref on tcp_server_ instead. Note that, the handshaker
// needs tcp_server_ to exist for the lifetime of the handshake since it's
// needed by acceptor. Sharing refs between the listener and tcp_server_ is
// just an optimization to avoid taking additional refs on the listener,
// since TcpServerShutdownComplete already holds a ref to the listener.
void IncrementRefCount() { grpc_tcp_server_ref(tcp_server_); }
void IncrementRefCount(const DebugLocation& /* location */,
const char* /* reason */) {
IncrementRefCount();
}
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref() {
IncrementRefCount();
return RefCountedPtr<Chttp2ServerListener>(this);
}
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref(
const DebugLocation& /* location */, const char* /* reason */) {
return Ref();
}
void Unref() { grpc_tcp_server_unref(tcp_server_); }
void Unref(const DebugLocation& /* location */, const char* /* reason */) {
Unref();
}
Server* const server_;
grpc_tcp_server* tcp_server_;
grpc_resolved_address resolved_address_; grpc_resolved_address resolved_address_;
Chttp2ServerArgsModifier const args_modifier_; Chttp2ServerArgsModifier const args_modifier_;
ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr; ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr;
@ -275,10 +285,6 @@ class Chttp2ServerListener : public Server::ListenerInterface {
RefCountedPtr<channelz::ListenSocketNode> channelz_listen_socket_; RefCountedPtr<channelz::ListenSocketNode> channelz_listen_socket_;
MemoryQuotaRefPtr memory_quota_; MemoryQuotaRefPtr memory_quota_;
ConnectionQuotaRefPtr connection_quota_; ConnectionQuotaRefPtr connection_quota_;
grpc_server_config_fetcher* config_fetcher_ = nullptr;
// TODO(yashykt): consider using absl::variant<> to minimize memory usage for
// disjoint cases where different fields are used.
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener_;
}; };
// //
@ -303,7 +309,7 @@ void Chttp2ServerListener::ConfigFetcherWatcher::UpdateConnectionManager(
void set_connections( void set_connections(
std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>> std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>>
connections) { connections) {
GPR_ASSERT(connections_.empty()); CHECK(connections_.empty());
connections_ = std::move(connections); connections_ = std::move(connections);
} }
@ -329,7 +335,7 @@ void Chttp2ServerListener::ConfigFetcherWatcher::UpdateConnectionManager(
StatusToString(error).c_str()); StatusToString(error).c_str());
// TODO(yashykt): We wouldn't need to assert here if we bound to the // TODO(yashykt): We wouldn't need to assert here if we bound to the
// port earlier during AddPort. // port earlier during AddPort.
GPR_ASSERT(0); CHECK(0);
} }
listener_->StartListening(); listener_->StartListening();
{ {
@ -375,17 +381,13 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
handshake_mgr_(MakeRefCounted<HandshakeManager>()), handshake_mgr_(MakeRefCounted<HandshakeManager>()),
deadline_(GetConnectionDeadline(args)), deadline_(GetConnectionDeadline(args)),
interested_parties_(grpc_pollset_set_create()) { interested_parties_(grpc_pollset_set_create()) {
if (accepting_pollset != nullptr) {
grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_);
}
CoreConfiguration::Get().handshaker_registry().AddHandshakers( CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get()); HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get());
} }
Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() { Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() {
if (accepting_pollset_ != nullptr) {
grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_);
}
grpc_pollset_set_destroy(interested_parties_); grpc_pollset_set_destroy(interested_parties_);
gpr_free(acceptor_); gpr_free(acceptor_);
} }
@ -707,18 +709,19 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() {
grpc_error_handle Chttp2ServerListener::Create( grpc_error_handle Chttp2ServerListener::Create(
Server* server, grpc_resolved_address* addr, const ChannelArgs& args, Server* server, grpc_resolved_address* addr, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier, int* port_num) { Chttp2ServerArgsModifier args_modifier, int* port_num) {
Chttp2ServerListener* listener = nullptr;
// The bulk of this method is inside of a lambda to make cleanup
// easier without using goto.
grpc_error_handle error = [&]() {
grpc_error_handle error;
// Create Chttp2ServerListener. // Create Chttp2ServerListener.
OrphanablePtr<Chttp2ServerListener> listener = listener = new Chttp2ServerListener(server, args, args_modifier);
MakeOrphanable<Chttp2ServerListener>(server, args, args_modifier, error = grpc_tcp_server_create(
server->config_fetcher()); &listener->tcp_server_shutdown_complete_,
// The tcp_server will be unreffed when the listener is orphaned, which could grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
// be at the end of this function if the listener was not added to the OnAccept, listener, &listener->tcp_server_);
// server's set of listeners.
grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args),
OnAccept, listener.get(), &listener->tcp_server_);
if (!error.ok()) return error; if (!error.ok()) return error;
if (listener->config_fetcher_ != nullptr) { if (server->config_fetcher() != nullptr) {
listener->resolved_address_ = *addr; listener->resolved_address_ = *addr;
// TODO(yashykt): Consider binding so as to be able to return the port // TODO(yashykt): Consider binding so as to be able to return the port
// number. // number.
@ -735,54 +738,54 @@ grpc_error_handle Chttp2ServerListener::Create(
} }
listener->channelz_listen_socket_ = listener->channelz_listen_socket_ =
MakeRefCounted<channelz::ListenSocketNode>( MakeRefCounted<channelz::ListenSocketNode>(
*string_address, absl::StrCat("chttp2 listener ", *string_address)); *string_address,
absl::StrCat("chttp2 listener ", *string_address));
} }
// Register with the server only upon success // Register with the server only upon success
server->AddListener(std::move(listener)); server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
return absl::OkStatus(); return absl::OkStatus();
}();
if (!error.ok()) {
if (listener != nullptr) {
if (listener->tcp_server_ != nullptr) {
// listener is deleted when tcp_server_ is shutdown.
grpc_tcp_server_unref(listener->tcp_server_);
} else {
delete listener;
}
}
}
return error;
} }
grpc_error_handle Chttp2ServerListener::CreateWithAcceptor( grpc_error_handle Chttp2ServerListener::CreateWithAcceptor(
Server* server, const char* name, const ChannelArgs& args, Server* server, const char* name, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier) { Chttp2ServerArgsModifier args_modifier) {
auto listener = MakeOrphanable<Chttp2ServerListener>( Chttp2ServerListener* listener =
server, args, args_modifier, server->config_fetcher()); new Chttp2ServerListener(server, args, args_modifier);
grpc_error_handle error = grpc_tcp_server_create( grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), &listener->tcp_server_shutdown_complete_,
OnAccept, listener.get(), &listener->tcp_server_); grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
if (!error.ok()) return error; OnAccept, listener, &listener->tcp_server_);
if (!error.ok()) {
delete listener;
return error;
}
// TODO(yangg) channelz // TODO(yangg) channelz
TcpServerFdHandler** arg_val = args.GetPointer<TcpServerFdHandler*>(name); TcpServerFdHandler** arg_val = args.GetPointer<TcpServerFdHandler*>(name);
*arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_); *arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_);
server->AddListener(std::move(listener)); server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
return absl::OkStatus(); return absl::OkStatus();
} }
Chttp2ServerListener* Chttp2ServerListener::CreateForPassiveListener(
Server* server, const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener) {
// TODO(hork): figure out how to handle channelz in this case
auto listener = MakeOrphanable<Chttp2ServerListener>(
server, args, /*args_modifier=*/
[](const ChannelArgs& args, grpc_error_handle*) { return args; }, nullptr,
std::move(passive_listener));
auto listener_ptr = listener.get();
server->AddListener(std::move(listener));
return listener_ptr;
}
Chttp2ServerListener::Chttp2ServerListener( Chttp2ServerListener::Chttp2ServerListener(
Server* server, const ChannelArgs& args, Server* server, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier, Chttp2ServerArgsModifier args_modifier)
grpc_server_config_fetcher* config_fetcher,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener)
: server_(server), : server_(server),
args_modifier_(args_modifier), args_modifier_(args_modifier),
args_(args), args_(args),
memory_quota_(args.GetObject<ResourceQuota>()->memory_quota()), memory_quota_(args.GetObject<ResourceQuota>()->memory_quota()),
connection_quota_(MakeRefCounted<ConnectionQuota>()), connection_quota_(MakeRefCounted<ConnectionQuota>()) {
config_fetcher_(config_fetcher),
passive_listener_(std::move(passive_listener)) {
auto max_allowed_incoming_connections = auto max_allowed_incoming_connections =
args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS); args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS);
if (max_allowed_incoming_connections.has_value()) { if (max_allowed_incoming_connections.has_value()) {
@ -797,9 +800,6 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Flush queued work before destroying handshaker factory, since that // Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref. // may do a synchronous unref.
ExecCtx::Get()->Flush(); ExecCtx::Get()->Flush();
if (passive_listener_ != nullptr) {
passive_listener_->ListenerDestroyed();
}
if (on_destroy_done_ != nullptr) { if (on_destroy_done_ != nullptr) {
ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus()); ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus());
ExecCtx::Get()->Flush(); ExecCtx::Get()->Flush();
@ -809,11 +809,10 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Server callback: start listening on our ports // Server callback: start listening on our ports
void Chttp2ServerListener::Start( void Chttp2ServerListener::Start(
Server* /*server*/, const std::vector<grpc_pollset*>* /* pollsets */) { Server* /*server*/, const std::vector<grpc_pollset*>* /* pollsets */) {
if (config_fetcher_ != nullptr) { if (server_->config_fetcher() != nullptr) {
auto watcher = std::make_unique<ConfigFetcherWatcher>( auto watcher = std::make_unique<ConfigFetcherWatcher>(Ref());
RefAsSubclass<Chttp2ServerListener>());
config_fetcher_watcher_ = watcher.get(); config_fetcher_watcher_ = watcher.get();
config_fetcher_->StartWatch( server_->config_fetcher()->StartWatch(
grpc_sockaddr_to_string(&resolved_address_, false).value(), grpc_sockaddr_to_string(&resolved_address_, false).value(),
std::move(watcher)); std::move(watcher));
} else { } else {
@ -827,9 +826,7 @@ void Chttp2ServerListener::Start(
} }
void Chttp2ServerListener::StartListening() { void Chttp2ServerListener::StartListening() {
if (tcp_server_ != nullptr) {
grpc_tcp_server_start(tcp_server_, &server_->pollsets()); grpc_tcp_server_start(tcp_server_, &server_->pollsets());
}
} }
void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) {
@ -837,12 +834,6 @@ void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) {
on_destroy_done_ = on_destroy_done; on_destroy_done_ = on_destroy_done;
} }
void Chttp2ServerListener::AcceptConnectedEndpoint(
std::unique_ptr<EventEngine::Endpoint> endpoint) {
OnAccept(this, grpc_event_engine_endpoint_create(std::move(endpoint)),
/*accepting_pollset=*/nullptr, /*acceptor=*/nullptr);
}
void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset, grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) { grpc_tcp_server_acceptor* acceptor) {
@ -867,7 +858,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
endpoint_cleanup(error); endpoint_cleanup(error);
return; return;
} }
if (self->config_fetcher_ != nullptr) { if (self->server_->config_fetcher() != nullptr) {
if (connection_manager == nullptr) { if (connection_manager == nullptr) {
grpc_error_handle error = GRPC_ERROR_CREATE( grpc_error_handle error = GRPC_ERROR_CREATE(
"No ConnectionManager configured. Closing connection."); "No ConnectionManager configured. Closing connection.");
@ -908,7 +899,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
// heap-use-after-free issues where `Ref()` is invoked when the ref of // heap-use-after-free issues where `Ref()` is invoked when the ref of
// tcp_server_ has already reached 0. (Ref() implementation of // tcp_server_ has already reached 0. (Ref() implementation of
// Chttp2ServerListener is grpc_tcp_server_ref().) // Chttp2ServerListener is grpc_tcp_server_ref().)
listener_ref = self->RefAsSubclass<Chttp2ServerListener>(); listener_ref = self->Ref();
self->connections_.emplace(connection.get(), std::move(connection)); self->connections_.emplace(connection.get(), std::move(connection));
} }
} }
@ -923,7 +914,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete(
void* arg, grpc_error_handle /*error*/) { void* arg, grpc_error_handle /*error*/) {
Chttp2ServerListener* self = static_cast<Chttp2ServerListener*>(arg); Chttp2ServerListener* self = static_cast<Chttp2ServerListener*>(arg);
self->channelz_listen_socket_.reset(); self->channelz_listen_socket_.reset();
self->Unref(); delete self;
} }
// Server callback: destroy the tcp listener (so we don't generate further // Server callback: destroy the tcp listener (so we don't generate further
@ -932,8 +923,7 @@ void Chttp2ServerListener::Orphan() {
// Cancel the watch before shutting down so as to avoid holding a ref to the // Cancel the watch before shutting down so as to avoid holding a ref to the
// listener in the watcher. // listener in the watcher.
if (config_fetcher_watcher_ != nullptr) { if (config_fetcher_watcher_ != nullptr) {
GPR_ASSERT(config_fetcher_ != nullptr); server_->config_fetcher()->CancelWatch(config_fetcher_watcher_);
config_fetcher_->CancelWatch(config_fetcher_watcher_);
} }
std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>> connections; std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>> connections;
grpc_tcp_server* tcp_server; grpc_tcp_server* tcp_server;
@ -951,14 +941,12 @@ void Chttp2ServerListener::Orphan() {
} }
tcp_server = tcp_server_; tcp_server = tcp_server_;
} }
if (tcp_server != nullptr) {
grpc_tcp_server_shutdown_listeners(tcp_server); grpc_tcp_server_shutdown_listeners(tcp_server);
grpc_tcp_server_unref(tcp_server); grpc_tcp_server_unref(tcp_server);
} else {
Unref();
}
} }
} // namespace
// //
// Chttp2ServerAddPort() // Chttp2ServerAddPort()
// //
@ -1013,7 +1001,7 @@ grpc_error_handle Chttp2ServerAddPort(Server* server, const char* addr,
if (*port_num == -1) { if (*port_num == -1) {
*port_num = port_temp; *port_num = port_temp;
} else { } else {
GPR_ASSERT(*port_num == port_temp); CHECK(*port_num == port_temp);
} }
} }
} }
@ -1059,50 +1047,6 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args,
} }
} // namespace } // namespace
namespace experimental {
absl::Status PassiveListenerImpl::AcceptConnectedEndpoint(
std::unique_ptr<EventEngine::Endpoint> endpoint) {
GPR_ASSERT(server_ != nullptr);
RefCountedPtr<Chttp2ServerListener> listener;
{
MutexLock lock(&mu_);
if (listener_ != nullptr) {
listener =
listener_->RefIfNonZero().TakeAsSubclass<Chttp2ServerListener>();
}
}
if (listener == nullptr) {
return absl::UnavailableError("passive listener already shut down");
}
ExecCtx exec_ctx;
listener->AcceptConnectedEndpoint(std::move(endpoint));
return absl::OkStatus();
}
absl::Status PassiveListenerImpl::AcceptConnectedFd(int fd) {
GPR_ASSERT(server_ != nullptr);
ExecCtx exec_ctx;
auto& args = server_->channel_args();
auto* supports_fd = QueryExtension<EventEngineSupportsFdExtension>(
/*engine=*/args.GetObjectRef<EventEngine>().get());
if (supports_fd == nullptr) {
return absl::UnimplementedError(
"The server's EventEngine does not support adding endpoints from "
"connected file descriptors.");
}
auto endpoint =
supports_fd->CreateEndpointFromFd(fd, ChannelArgsEndpointConfig(args));
return AcceptConnectedEndpoint(std::move(endpoint));
}
void PassiveListenerImpl::ListenerDestroyed() {
MutexLock lock(&mu_);
listener_ = nullptr;
}
} // namespace experimental
} // namespace grpc_core } // namespace grpc_core
int grpc_server_add_http2_port(grpc_server* server, const char* addr, int grpc_server_add_http2_port(grpc_server* server, const char* addr,
@ -1196,35 +1140,7 @@ void grpc_server_add_channel_from_fd(grpc_server* server, int fd,
void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */, void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */,
grpc_server_credentials* /* creds */) { grpc_server_credentials* /* creds */) {
GPR_ASSERT(0); CHECK(0);
} }
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
absl::Status grpc_server_add_passive_listener(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_add_passive_listener(server=%p, credentials=%p)",
2, (server, credentials));
// Create security context.
if (credentials == nullptr) {
return absl::UnavailableError(
"No credentials specified for passive listener");
}
auto sc = credentials->create_security_connector(grpc_core::ChannelArgs());
if (sc == nullptr) {
return absl::UnavailableError(
absl::StrCat("Unable to create secure server with credentials of type ",
credentials->type().name()));
}
auto args = server->channel_args()
.SetObject(credentials->Ref())
.SetObject(std::move(sc));
passive_listener->listener_ =
grpc_core::Chttp2ServerListener::CreateForPassiveListener(
server, args, passive_listener);
passive_listener->server_ = server->Ref();
return absl::OkStatus();
}

@ -21,7 +21,6 @@
#include <functional> #include <functional>
#include <grpc/passive_listener.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -43,38 +42,6 @@ grpc_error_handle Chttp2ServerAddPort(
Server* server, const char* addr, const ChannelArgs& args, Server* server, const char* addr, const ChannelArgs& args,
Chttp2ServerArgsModifier connection_args_modifier, int* port_num); Chttp2ServerArgsModifier connection_args_modifier, int* port_num);
class Chttp2ServerListener;
namespace experimental {
// An implementation of the public C++ passive listener interface.
// The server builder holds a weak_ptr to one of these objects, and the
// application owns the instance.
class PassiveListenerImpl final : public PassiveListener {
public:
absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) override ABSL_LOCKS_EXCLUDED(mu_);
absl::Status AcceptConnectedFd(GRPC_UNUSED int fd) override
ABSL_LOCKS_EXCLUDED(mu_);
void ListenerDestroyed() ABSL_LOCKS_EXCLUDED(mu_);
private:
// note: the grpc_core::Server redundant namespace qualification is
// required for older gcc versions.
friend absl::Status(::grpc_server_add_passive_listener)(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
Mutex mu_;
// Data members will be populated when initialized.
RefCountedPtr<Server> server_;
Chttp2ServerListener* listener_;
};
} // namespace experimental
} // namespace grpc_core } // namespace grpc_core
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H

@ -19,6 +19,7 @@
#include "src/core/ext/transport/chttp2/transport/bin_decoder.h" #include "src/core/ext/transport/chttp2/transport/bin_decoder.h"
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -198,8 +199,8 @@ grpc_slice grpc_chttp2_base64_decode(const grpc_slice& input) {
grpc_core::CSliceUnref(output); grpc_core::CSliceUnref(output);
return grpc_empty_slice(); return grpc_empty_slice();
} }
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output)); CHECK(ctx.output_cur == GRPC_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur == GRPC_SLICE_END_PTR(input)); CHECK(ctx.input_cur == GRPC_SLICE_END_PTR(input));
return output; return output;
} }
@ -245,7 +246,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(const grpc_slice& input,
grpc_core::CSliceUnref(output); grpc_core::CSliceUnref(output);
return grpc_empty_slice(); return grpc_empty_slice();
} }
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output)); CHECK(ctx.output_cur == GRPC_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur <= GRPC_SLICE_END_PTR(input)); CHECK(ctx.input_cur <= GRPC_SLICE_END_PTR(input));
return output; return output;
} }

@ -21,6 +21,8 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -87,8 +89,8 @@ grpc_slice grpc_chttp2_base64_encode(const grpc_slice& input) {
break; break;
} }
GPR_ASSERT(out == (char*)GRPC_SLICE_END_PTR(output)); CHECK(out == (char*)GRPC_SLICE_END_PTR(output));
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input)); CHECK(in == GRPC_SLICE_END_PTR(input));
return output; return output;
} }
@ -131,7 +133,7 @@ grpc_slice grpc_chttp2_huffman_compress(const grpc_slice& input) {
static_cast<uint8_t>(0xffu >> temp_length)); static_cast<uint8_t>(0xffu >> temp_length));
} }
GPR_ASSERT(out == GRPC_SLICE_END_PTR(output)); CHECK(out == GRPC_SLICE_END_PTR(output));
return output; return output;
} }
@ -227,9 +229,9 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
static_cast<uint8_t>(0xffu >> out.temp_length)); static_cast<uint8_t>(0xffu >> out.temp_length));
} }
GPR_ASSERT(out.out <= GRPC_SLICE_END_PTR(output)); CHECK(out.out <= GRPC_SLICE_END_PTR(output));
GRPC_SLICE_SET_LENGTH(output, out.out - start_out); GRPC_SLICE_SET_LENGTH(output, out.out - start_out);
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input)); CHECK(in == GRPC_SLICE_END_PTR(input));
return output; return output;
} }

@ -34,6 +34,7 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/hash/hash.h" #include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
#include "absl/random/random.h" #include "absl/random/random.h"
#include "absl/status/status.h" #include "absl/status/status.h"
@ -398,11 +399,11 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
grpc_chttp2_goaway_parser_destroy(&goaway_parser); grpc_chttp2_goaway_parser_destroy(&goaway_parser);
for (i = 0; i < STREAM_LIST_COUNT; i++) { for (i = 0; i < STREAM_LIST_COUNT; i++) {
GPR_ASSERT(lists[i].head == nullptr); CHECK_EQ(lists[i].head, nullptr);
GPR_ASSERT(lists[i].tail == nullptr); CHECK_EQ(lists[i].tail, nullptr);
} }
GPR_ASSERT(stream_map.empty()); CHECK(stream_map.empty());
GRPC_COMBINER_UNREF(combiner, "chttp2_transport"); GRPC_COMBINER_UNREF(combiner, "chttp2_transport");
while (write_cb_pool) { while (write_cb_pool) {
@ -573,7 +574,7 @@ static void read_channel_args(grpc_chttp2_transport* t,
static void init_keepalive_pings_if_enabled_locked( static void init_keepalive_pings_if_enabled_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t, grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
GRPC_UNUSED grpc_error_handle error) { GRPC_UNUSED grpc_error_handle error) {
GPR_DEBUG_ASSERT(error.ok()); DCHECK(error.ok());
if (t->keepalive_time != grpc_core::Duration::Infinity()) { if (t->keepalive_time != grpc_core::Duration::Infinity()) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
t->keepalive_ping_timer_handle = t->keepalive_ping_timer_handle =
@ -616,7 +617,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
deframe_state(is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0), deframe_state(is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0),
is_client(is_client) { is_client(is_client) {
cl = new grpc_core::ContextList(); cl = new grpc_core::ContextList();
GPR_ASSERT(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) == CHECK(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) ==
GRPC_CHTTP2_CLIENT_CONNECT_STRLEN); GRPC_CHTTP2_CLIENT_CONNECT_STRLEN);
grpc_slice_buffer_init(&read_buffer); grpc_slice_buffer_init(&read_buffer);
@ -706,7 +707,7 @@ static void close_transport_locked(grpc_chttp2_transport* t,
grpc_error_add_child(t->close_transport_on_writes_finished, error); grpc_error_add_child(t->close_transport_on_writes_finished, error);
return; return;
} }
GPR_ASSERT(!error.ok()); CHECK(!error.ok());
t->closed_with_error = error; t->closed_with_error = error;
connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(), connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(),
"close_transport"); "close_transport");
@ -750,7 +751,7 @@ static void close_transport_locked(grpc_chttp2_transport* t,
while (grpc_chttp2_list_pop_writable_stream(t, &s)) { while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:close"); GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:close");
} }
GPR_ASSERT(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE); CHECK(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_endpoint_shutdown(t->ep, error); grpc_endpoint_shutdown(t->ep, error);
} }
if (t->notify_on_receive_settings != nullptr) { if (t->notify_on_receive_settings != nullptr) {
@ -826,9 +827,9 @@ grpc_chttp2_stream::~grpc_chttp2_stream() {
} }
} }
GPR_ASSERT((write_closed && read_closed) || id == 0); CHECK((write_closed && read_closed) || id == 0);
if (id != 0) { if (id != 0) {
GPR_ASSERT(t->stream_map.count(id) == 0); CHECK_EQ(t->stream_map.count(id), 0u);
} }
grpc_slice_buffer_destroy(&frame_storage); grpc_slice_buffer_destroy(&frame_storage);
@ -841,11 +842,11 @@ grpc_chttp2_stream::~grpc_chttp2_stream() {
} }
} }
GPR_ASSERT(send_initial_metadata_finished == nullptr); CHECK_EQ(send_initial_metadata_finished, nullptr);
GPR_ASSERT(send_trailing_metadata_finished == nullptr); CHECK_EQ(send_trailing_metadata_finished, nullptr);
GPR_ASSERT(recv_initial_metadata_ready == nullptr); CHECK_EQ(recv_initial_metadata_ready, nullptr);
GPR_ASSERT(recv_message_ready == nullptr); CHECK_EQ(recv_message_ready, nullptr);
GPR_ASSERT(recv_trailing_metadata_finished == nullptr); CHECK_EQ(recv_trailing_metadata_finished, nullptr);
grpc_slice_buffer_destroy(&flow_controlled_buffer); grpc_slice_buffer_destroy(&flow_controlled_buffer);
grpc_core::ExecCtx::Run(DEBUG_LOCATION, destroy_stream_arg, absl::OkStatus()); grpc_core::ExecCtx::Run(DEBUG_LOCATION, destroy_stream_arg, absl::OkStatus());
} }
@ -878,7 +879,7 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
return nullptr; return nullptr;
} }
grpc_chttp2_stream* accepting = nullptr; grpc_chttp2_stream* accepting = nullptr;
GPR_ASSERT(t->accepting_stream == nullptr); CHECK_EQ(t->accepting_stream, nullptr);
t->accepting_stream = &accepting; t->accepting_stream = &accepting;
t->accept_stream_cb(t->accept_stream_cb_user_data, t, t->accept_stream_cb(t->accept_stream_cb_user_data, t,
reinterpret_cast<void*>(id)); reinterpret_cast<void*>(id));
@ -980,7 +981,7 @@ static const char* begin_writing_desc(bool partial) {
static void write_action_begin_locked( static void write_action_begin_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t, grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
grpc_error_handle /*error_ignored*/) { grpc_error_handle /*error_ignored*/) {
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE); CHECK(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_chttp2_begin_write_result r; grpc_chttp2_begin_write_result r;
if (!t->closed_with_error.ok()) { if (!t->closed_with_error.ok()) {
r.writing = false; r.writing = false;
@ -994,7 +995,7 @@ static void write_action_begin_locked(
begin_writing_desc(r.partial)); begin_writing_desc(r.partial));
write_action(t.get()); write_action(t.get());
if (t->reading_paused_on_pending_induced_frames) { if (t->reading_paused_on_pending_induced_frames) {
GPR_ASSERT(t->num_pending_induced_frames == 0); CHECK_EQ(t->num_pending_induced_frames, 0u);
// We had paused reading, because we had many induced frames (SETTINGS // We had paused reading, because we had many induced frames (SETTINGS
// ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have // ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have
// been able to flush qbuf, we can resume reading. // been able to flush qbuf, we can resume reading.
@ -1211,7 +1212,7 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
"HTTP:%s: Transport %p allocating new grpc_chttp2_stream %p to id %d", "HTTP:%s: Transport %p allocating new grpc_chttp2_stream %p to id %d",
t->is_client ? "CLI" : "SVR", t, s, t->next_stream_id)); t->is_client ? "CLI" : "SVR", t, s, t->next_stream_id));
GPR_ASSERT(s->id == 0); CHECK_EQ(s->id, 0u);
s->id = t->next_stream_id; s->id = t->next_stream_id;
t->next_stream_id += 2; t->next_stream_id += 2;
@ -1384,7 +1385,7 @@ static void perform_stream_op_locked(void* stream_op,
if (t->is_client && t->channelz_socket != nullptr) { if (t->is_client && t->channelz_socket != nullptr) {
t->channelz_socket->RecordStreamStartedFromLocal(); t->channelz_socket->RecordStreamStartedFromLocal();
} }
GPR_ASSERT(s->send_initial_metadata_finished == nullptr); CHECK_EQ(s->send_initial_metadata_finished, nullptr);
on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; on_complete->next_data.scratch |= t->closure_barrier_may_cover_write;
s->send_initial_metadata_finished = add_closure_barrier(on_complete); s->send_initial_metadata_finished = add_closure_barrier(on_complete);
@ -1402,7 +1403,7 @@ static void perform_stream_op_locked(void* stream_op,
if (!s->write_closed) { if (!s->write_closed) {
if (t->is_client) { if (t->is_client) {
if (t->closed_with_error.ok()) { if (t->closed_with_error.ok()) {
GPR_ASSERT(s->id == 0); CHECK_EQ(s->id, 0u);
grpc_chttp2_list_add_waiting_for_concurrency(t, s); grpc_chttp2_list_add_waiting_for_concurrency(t, s);
maybe_start_some_streams(t); maybe_start_some_streams(t);
} else { } else {
@ -1419,7 +1420,7 @@ static void perform_stream_op_locked(void* stream_op,
false); false);
} }
} else { } else {
GPR_ASSERT(s->id != 0); CHECK_NE(s->id, 0u);
grpc_chttp2_mark_stream_writable(t, s); grpc_chttp2_mark_stream_writable(t, s);
if (!(op->send_message && if (!(op->send_message &&
(op->payload->send_message.flags & GRPC_WRITE_BUFFER_HINT))) { (op->payload->send_message.flags & GRPC_WRITE_BUFFER_HINT))) {
@ -1520,7 +1521,7 @@ static void perform_stream_op_locked(void* stream_op,
} }
if (op->send_trailing_metadata) { if (op->send_trailing_metadata) {
GPR_ASSERT(s->send_trailing_metadata_finished == nullptr); CHECK_EQ(s->send_trailing_metadata_finished, nullptr);
on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; on_complete->next_data.scratch |= t->closure_barrier_may_cover_write;
s->send_trailing_metadata_finished = add_closure_barrier(on_complete); s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
s->send_trailing_metadata = s->send_trailing_metadata =
@ -1550,7 +1551,7 @@ static void perform_stream_op_locked(void* stream_op,
} }
if (op->recv_initial_metadata) { if (op->recv_initial_metadata) {
GPR_ASSERT(s->recv_initial_metadata_ready == nullptr); CHECK_EQ(s->recv_initial_metadata_ready, nullptr);
s->recv_initial_metadata_ready = s->recv_initial_metadata_ready =
op_payload->recv_initial_metadata.recv_initial_metadata_ready; op_payload->recv_initial_metadata.recv_initial_metadata_ready;
s->recv_initial_metadata = s->recv_initial_metadata =
@ -1564,7 +1565,7 @@ static void perform_stream_op_locked(void* stream_op,
} }
if (op->recv_message) { if (op->recv_message) {
GPR_ASSERT(s->recv_message_ready == nullptr); CHECK_EQ(s->recv_message_ready, nullptr);
s->recv_message_ready = op_payload->recv_message.recv_message_ready; s->recv_message_ready = op_payload->recv_message.recv_message_ready;
s->recv_message = op_payload->recv_message.recv_message; s->recv_message = op_payload->recv_message.recv_message;
s->recv_message->emplace(); s->recv_message->emplace();
@ -1575,9 +1576,9 @@ static void perform_stream_op_locked(void* stream_op,
} }
if (op->recv_trailing_metadata) { if (op->recv_trailing_metadata) {
GPR_ASSERT(s->collecting_stats == nullptr); CHECK_EQ(s->collecting_stats, nullptr);
s->collecting_stats = op_payload->recv_trailing_metadata.collect_stats; s->collecting_stats = op_payload->recv_trailing_metadata.collect_stats;
GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr); CHECK_EQ(s->recv_trailing_metadata_finished, nullptr);
s->recv_trailing_metadata_finished = s->recv_trailing_metadata_finished =
op_payload->recv_trailing_metadata.recv_trailing_metadata_ready; op_payload->recv_trailing_metadata.recv_trailing_metadata_ready;
s->recv_trailing_metadata = s->recv_trailing_metadata =
@ -1600,12 +1601,12 @@ void grpc_chttp2_transport::PerformStreamOp(
if (!is_client) { if (!is_client) {
if (op->send_initial_metadata) { if (op->send_initial_metadata) {
GPR_ASSERT(!op->payload->send_initial_metadata.send_initial_metadata CHECK(!op->payload->send_initial_metadata.send_initial_metadata
->get(grpc_core::GrpcTimeoutMetadata()) ->get(grpc_core::GrpcTimeoutMetadata())
.has_value()); .has_value());
} }
if (op->send_trailing_metadata) { if (op->send_trailing_metadata) {
GPR_ASSERT(!op->payload->send_trailing_metadata.send_trailing_metadata CHECK(!op->payload->send_trailing_metadata.send_trailing_metadata
->get(grpc_core::GrpcTimeoutMetadata()) ->get(grpc_core::GrpcTimeoutMetadata())
.has_value()); .has_value());
} }
@ -1699,8 +1700,8 @@ void grpc_chttp2_retry_initiate_ping(
static void retry_initiate_ping_locked( static void retry_initiate_ping_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t, grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
GRPC_UNUSED grpc_error_handle error) { GRPC_UNUSED grpc_error_handle error) {
GPR_DEBUG_ASSERT(error.ok()); DCHECK(error.ok());
GPR_ASSERT(t->delayed_ping_timer_handle != TaskHandle::kInvalid); CHECK(t->delayed_ping_timer_handle != TaskHandle::kInvalid);
t->delayed_ping_timer_handle = TaskHandle::kInvalid; t->delayed_ping_timer_handle = TaskHandle::kInvalid;
grpc_chttp2_initiate_write(t.get(), grpc_chttp2_initiate_write(t.get(),
GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
@ -2020,7 +2021,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
} else { } else {
if (s->frame_storage.length != 0) { if (s->frame_storage.length != 0) {
while (true) { while (true) {
GPR_ASSERT(s->frame_storage.length > 0); CHECK_GT(s->frame_storage.length, 0u);
int64_t min_progress_size; int64_t min_progress_size;
auto r = grpc_deframe_unprocessed_incoming_frames( auto r = grpc_deframe_unprocessed_incoming_frames(
s, &min_progress_size, &**s->recv_message, s->recv_message_flags); s, &min_progress_size, &**s->recv_message, s->recv_message_flags);
@ -2106,7 +2107,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
static grpc_chttp2_transport::RemovedStreamHandle remove_stream( static grpc_chttp2_transport::RemovedStreamHandle remove_stream(
grpc_chttp2_transport* t, uint32_t id, grpc_error_handle error) { grpc_chttp2_transport* t, uint32_t id, grpc_error_handle error) {
grpc_chttp2_stream* s = t->stream_map.extract(id).mapped(); grpc_chttp2_stream* s = t->stream_map.extract(id).mapped();
GPR_DEBUG_ASSERT(s); DCHECK(s);
if (t->incoming_stream == s) { if (t->incoming_stream == s) {
t->incoming_stream = nullptr; t->incoming_stream = nullptr;
grpc_chttp2_parsing_become_skip_parser(t); grpc_chttp2_parsing_become_skip_parser(t);
@ -2358,7 +2359,8 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_error_get_status(error, s->deadline, &grpc_status, &message, nullptr, grpc_error_get_status(error, s->deadline, &grpc_status, &message, nullptr,
nullptr); nullptr);
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100); CHECK_GE(grpc_status, 0);
CHECK_LT((int)grpc_status, 100);
auto remove_stream_handle = grpc_chttp2_mark_stream_closed(t, s, 1, 1, error); auto remove_stream_handle = grpc_chttp2_mark_stream_closed(t, s, 1, 1, error);
grpc_core::MaybeTarpit( grpc_core::MaybeTarpit(
@ -2399,7 +2401,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
*p++ = '2'; *p++ = '2';
*p++ = '0'; *p++ = '0';
*p++ = '0'; *p++ = '0';
GPR_ASSERT(p == GRPC_SLICE_END_PTR(http_status_hdr)); CHECK(p == GRPC_SLICE_END_PTR(http_status_hdr));
len += static_cast<uint32_t> GRPC_SLICE_LENGTH(http_status_hdr); len += static_cast<uint32_t> GRPC_SLICE_LENGTH(http_status_hdr);
content_type_hdr = GRPC_SLICE_MALLOC(31); content_type_hdr = GRPC_SLICE_MALLOC(31);
@ -2435,7 +2437,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
*p++ = 'r'; *p++ = 'r';
*p++ = 'p'; *p++ = 'p';
*p++ = 'c'; *p++ = 'c';
GPR_ASSERT(p == GRPC_SLICE_END_PTR(content_type_hdr)); CHECK(p == GRPC_SLICE_END_PTR(content_type_hdr));
len += static_cast<uint32_t> GRPC_SLICE_LENGTH(content_type_hdr); len += static_cast<uint32_t> GRPC_SLICE_LENGTH(content_type_hdr);
} }
@ -2462,11 +2464,11 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
*p++ = static_cast<uint8_t>('0' + (grpc_status / 10)); *p++ = static_cast<uint8_t>('0' + (grpc_status / 10));
*p++ = static_cast<uint8_t>('0' + (grpc_status % 10)); *p++ = static_cast<uint8_t>('0' + (grpc_status % 10));
} }
GPR_ASSERT(p == GRPC_SLICE_END_PTR(status_hdr)); CHECK(p == GRPC_SLICE_END_PTR(status_hdr));
len += static_cast<uint32_t> GRPC_SLICE_LENGTH(status_hdr); len += static_cast<uint32_t> GRPC_SLICE_LENGTH(status_hdr);
size_t msg_len = message.length(); size_t msg_len = message.length();
GPR_ASSERT(msg_len <= UINT32_MAX); CHECK(msg_len <= UINT32_MAX);
grpc_core::VarintWriter<1> msg_len_writer( grpc_core::VarintWriter<1> msg_len_writer(
static_cast<uint32_t>(msg_len)); static_cast<uint32_t>(msg_len));
message_pfx = GRPC_SLICE_MALLOC(14 + msg_len_writer.length()); message_pfx = GRPC_SLICE_MALLOC(14 + msg_len_writer.length());
@ -2487,7 +2489,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
*p++ = 'e'; *p++ = 'e';
msg_len_writer.Write(0, p); msg_len_writer.Write(0, p);
p += msg_len_writer.length(); p += msg_len_writer.length();
GPR_ASSERT(p == GRPC_SLICE_END_PTR(message_pfx)); CHECK(p == GRPC_SLICE_END_PTR(message_pfx));
len += static_cast<uint32_t> GRPC_SLICE_LENGTH(message_pfx); len += static_cast<uint32_t> GRPC_SLICE_LENGTH(message_pfx);
len += static_cast<uint32_t>(msg_len); len += static_cast<uint32_t>(msg_len);
@ -2503,7 +2505,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
*p++ = static_cast<uint8_t>(id >> 16); *p++ = static_cast<uint8_t>(id >> 16);
*p++ = static_cast<uint8_t>(id >> 8); *p++ = static_cast<uint8_t>(id >> 8);
*p++ = static_cast<uint8_t>(id); *p++ = static_cast<uint8_t>(id);
GPR_ASSERT(p == GRPC_SLICE_END_PTR(hdr)); CHECK(p == GRPC_SLICE_END_PTR(hdr));
grpc_slice_buffer_add(&t->qbuf, hdr); grpc_slice_buffer_add(&t->qbuf, hdr);
if (!sent_initial_metadata) { if (!sent_initial_metadata) {
@ -2821,7 +2823,7 @@ static void finish_bdp_ping_locked(
t->flow_control.bdp_estimator()->CompletePing(); t->flow_control.bdp_estimator()->CompletePing();
grpc_chttp2_act_on_flowctl_action(t->flow_control.PeriodicUpdate(), t.get(), grpc_chttp2_act_on_flowctl_action(t->flow_control.PeriodicUpdate(), t.get(),
nullptr); nullptr);
GPR_ASSERT(t->next_bdp_ping_timer_handle == TaskHandle::kInvalid); CHECK(t->next_bdp_ping_timer_handle == TaskHandle::kInvalid);
t->next_bdp_ping_timer_handle = t->next_bdp_ping_timer_handle =
t->event_engine->RunAfter(next_ping - grpc_core::Timestamp::Now(), [t] { t->event_engine->RunAfter(next_ping - grpc_core::Timestamp::Now(), [t] {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
@ -2840,7 +2842,7 @@ static void next_bdp_ping_timer_expired(grpc_chttp2_transport* t) {
static void next_bdp_ping_timer_expired_locked( static void next_bdp_ping_timer_expired_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t, grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
GRPC_UNUSED grpc_error_handle error) { GRPC_UNUSED grpc_error_handle error) {
GPR_DEBUG_ASSERT(error.ok()); DCHECK(error.ok());
t->next_bdp_ping_timer_handle = TaskHandle::kInvalid; t->next_bdp_ping_timer_handle = TaskHandle::kInvalid;
if (t->flow_control.bdp_estimator()->accumulator() == 0) { if (t->flow_control.bdp_estimator()->accumulator() == 0) {
// Block the bdp ping till we receive more data. // Block the bdp ping till we receive more data.
@ -2908,9 +2910,9 @@ static void init_keepalive_ping(
static void init_keepalive_ping_locked( static void init_keepalive_ping_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t, grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
GRPC_UNUSED grpc_error_handle error) { GRPC_UNUSED grpc_error_handle error) {
GPR_DEBUG_ASSERT(error.ok()); DCHECK(error.ok());
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING); CHECK(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
GPR_ASSERT(t->keepalive_ping_timer_handle != TaskHandle::kInvalid); CHECK(t->keepalive_ping_timer_handle != TaskHandle::kInvalid);
t->keepalive_ping_timer_handle = TaskHandle::kInvalid; t->keepalive_ping_timer_handle = TaskHandle::kInvalid;
if (t->destroying || !t->closed_with_error.ok()) { if (t->destroying || !t->closed_with_error.ok()) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@ -2952,7 +2954,7 @@ static void finish_keepalive_ping_locked(
std::string(t->peer_string.as_string_view()).c_str()); std::string(t->peer_string.as_string_view()).c_str());
} }
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GPR_ASSERT(t->keepalive_ping_timer_handle == TaskHandle::kInvalid); CHECK(t->keepalive_ping_timer_handle == TaskHandle::kInvalid);
t->keepalive_ping_timer_handle = t->keepalive_ping_timer_handle =
t->event_engine->RunAfter(t->keepalive_time, [t] { t->event_engine->RunAfter(t->keepalive_time, [t] {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;

@ -27,6 +27,7 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
@ -336,7 +337,7 @@ void StreamFlowControl::SentUpdate(uint32_t announce) {
TransportFlowControl::IncomingUpdateContext tfc_upd(tfc_); TransportFlowControl::IncomingUpdateContext tfc_upd(tfc_);
pending_size_ = absl::nullopt; pending_size_ = absl::nullopt;
tfc_upd.UpdateAnnouncedWindowDelta(&announced_window_delta_, announce); tfc_upd.UpdateAnnouncedWindowDelta(&announced_window_delta_, announce);
GPR_ASSERT(DesiredAnnounceSize() == 0); CHECK_EQ(DesiredAnnounceSize(), 0u);
std::ignore = tfc_upd.MakeAction(); std::ignore = tfc_upd.MakeAction();
} }
@ -386,7 +387,7 @@ FlowControlAction StreamFlowControl::UpdateAction(FlowControlAction action) {
void StreamFlowControl::IncomingUpdateContext::SetPendingSize( void StreamFlowControl::IncomingUpdateContext::SetPendingSize(
int64_t pending_size) { int64_t pending_size) {
GPR_ASSERT(pending_size >= 0); CHECK_GE(pending_size, 0);
sfc_->pending_size_ = pending_size; sfc_->pending_size_ = pending_size;
} }

@ -27,6 +27,7 @@
#include <utility> #include <utility>
#include "absl/functional/function_ref.h" #include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -132,7 +133,7 @@ class GRPC_MUST_USE_RESULT FlowControlAction {
static const char* UrgencyString(Urgency u); static const char* UrgencyString(Urgency u);
std::string DebugString() const; std::string DebugString() const;
void AssertEmpty() { GPR_ASSERT(*this == FlowControlAction()); } void AssertEmpty() { CHECK(*this == FlowControlAction()); }
bool operator==(const FlowControlAction& other) const { bool operator==(const FlowControlAction& other) const {
return send_stream_update_ == other.send_stream_update_ && return send_stream_update_ == other.send_stream_update_ &&
@ -195,7 +196,7 @@ class TransportFlowControl final {
class IncomingUpdateContext { class IncomingUpdateContext {
public: public:
explicit IncomingUpdateContext(TransportFlowControl* tfc) : tfc_(tfc) {} explicit IncomingUpdateContext(TransportFlowControl* tfc) : tfc_(tfc) {}
~IncomingUpdateContext() { GPR_ASSERT(tfc_ == nullptr); } ~IncomingUpdateContext() { CHECK_EQ(tfc_, nullptr); }
IncomingUpdateContext(const IncomingUpdateContext&) = delete; IncomingUpdateContext(const IncomingUpdateContext&) = delete;
IncomingUpdateContext& operator=(const IncomingUpdateContext&) = delete; IncomingUpdateContext& operator=(const IncomingUpdateContext&) = delete;

@ -19,6 +19,7 @@
#include <cstdint> #include <cstdint>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -59,7 +60,7 @@ uint16_t Read2b(const uint8_t* input) {
} }
void Write3b(uint32_t x, uint8_t* output) { void Write3b(uint32_t x, uint8_t* output) {
GPR_ASSERT(x < 16777216); CHECK_LT(x, 16777216u);
output[0] = static_cast<uint8_t>(x >> 16); output[0] = static_cast<uint8_t>(x >> 16);
output[1] = static_cast<uint8_t>(x >> 8); output[1] = static_cast<uint8_t>(x >> 8);
output[2] = static_cast<uint8_t>(x); output[2] = static_cast<uint8_t>(x);
@ -475,7 +476,7 @@ void Serialize(absl::Span<Http2Frame> frames, SliceBuffer& out) {
absl::StatusOr<Http2Frame> ParseFramePayload(const Http2FrameHeader& hdr, absl::StatusOr<Http2Frame> ParseFramePayload(const Http2FrameHeader& hdr,
SliceBuffer payload) { SliceBuffer payload) {
GPR_ASSERT(payload.Length() == hdr.length); CHECK(payload.Length() == hdr.length);
switch (hdr.type) { switch (hdr.type) {
case kFrameTypeData: case kFrameTypeData:
return ParseDataFrame(hdr, payload); return ParseDataFrame(hdr, payload);

@ -20,6 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -62,7 +63,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
hdr = GRPC_SLICE_MALLOC(header_size); hdr = GRPC_SLICE_MALLOC(header_size);
p = GRPC_SLICE_START_PTR(hdr); p = GRPC_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24)); CHECK(write_bytes < (1 << 24));
*p++ = static_cast<uint8_t>(write_bytes >> 16); *p++ = static_cast<uint8_t>(write_bytes >> 16);
*p++ = static_cast<uint8_t>(write_bytes >> 8); *p++ = static_cast<uint8_t>(write_bytes >> 8);
*p++ = static_cast<uint8_t>(write_bytes); *p++ = static_cast<uint8_t>(write_bytes);

@ -21,6 +21,7 @@
#include <string.h> #include <string.h>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -136,7 +137,7 @@ grpc_error_handle grpc_chttp2_goaway_parser_parse(void* parser,
memcpy(p->debug_data + p->debug_pos, cur, memcpy(p->debug_data + p->debug_pos, cur,
static_cast<size_t>(end - cur)); static_cast<size_t>(end - cur));
} }
GPR_ASSERT((size_t)(end - cur) < UINT32_MAX - p->debug_pos); CHECK((size_t)(end - cur) < UINT32_MAX - p->debug_pos);
p->debug_pos += static_cast<uint32_t>(end - cur); p->debug_pos += static_cast<uint32_t>(end - cur);
p->state = GRPC_CHTTP2_GOAWAY_DEBUG; p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) { if (is_last) {
@ -157,7 +158,7 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice header = GRPC_SLICE_MALLOC(9 + 4 + 4); grpc_slice header = GRPC_SLICE_MALLOC(9 + 4 + 4);
uint8_t* p = GRPC_SLICE_START_PTR(header); uint8_t* p = GRPC_SLICE_START_PTR(header);
uint32_t frame_length; uint32_t frame_length;
GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4); CHECK(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
frame_length = 4 + 4 + static_cast<uint32_t> GRPC_SLICE_LENGTH(debug_data); frame_length = 4 + 4 + static_cast<uint32_t> GRPC_SLICE_LENGTH(debug_data);
// frame header: length // frame header: length
@ -183,7 +184,7 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
*p++ = static_cast<uint8_t>(error_code >> 16); *p++ = static_cast<uint8_t>(error_code >> 16);
*p++ = static_cast<uint8_t>(error_code >> 8); *p++ = static_cast<uint8_t>(error_code >> 8);
*p++ = static_cast<uint8_t>(error_code); *p++ = static_cast<uint8_t>(error_code);
GPR_ASSERT(p == GRPC_SLICE_END_PTR(header)); CHECK(p == GRPC_SLICE_END_PTR(header));
grpc_slice_buffer_add(slice_buffer, header); grpc_slice_buffer_add(slice_buffer, header);
grpc_slice_buffer_add(slice_buffer, debug_data); grpc_slice_buffer_add(slice_buffer, debug_data);
} }

@ -24,6 +24,7 @@
#include <algorithm> #include <algorithm>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -93,7 +94,7 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser,
} }
if (p->byte == 8) { if (p->byte == 8) {
GPR_ASSERT(is_last); CHECK(is_last);
if (p->is_ack) { if (p->is_ack) {
if (grpc_ping_trace.enabled()) { if (grpc_ping_trace.enabled()) {
gpr_log(GPR_INFO, "%s[%p]: received ping ack %" PRIx64, gpr_log(GPR_INFO, "%s[%p]: received ping ack %" PRIx64,

@ -20,6 +20,7 @@
#include <stddef.h> #include <stddef.h>
#include "absl/log/check.h"
#include "absl/random/distributions.h" #include "absl/random/distributions.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -105,7 +106,7 @@ grpc_error_handle grpc_chttp2_rst_stream_parser_parse(void* parser,
s->stats.incoming.framing_bytes += static_cast<uint64_t>(end - cur); s->stats.incoming.framing_bytes += static_cast<uint64_t>(end - cur);
if (p->byte == 4) { if (p->byte == 4) {
GPR_ASSERT(is_last); CHECK(is_last);
uint32_t reason = ((static_cast<uint32_t>(p->reason_bytes[0])) << 24) | uint32_t reason = ((static_cast<uint32_t>(p->reason_bytes[0])) << 24) |
((static_cast<uint32_t>(p->reason_bytes[1])) << 16) | ((static_cast<uint32_t>(p->reason_bytes[1])) << 16) |
((static_cast<uint32_t>(p->reason_bytes[2])) << 8) | ((static_cast<uint32_t>(p->reason_bytes[2])) << 8) |

@ -20,6 +20,7 @@
#include <stddef.h> #include <stddef.h>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -37,7 +38,7 @@ grpc_slice grpc_chttp2_window_update_create(
stats->framing_bytes += frame_size; stats->framing_bytes += frame_size;
uint8_t* p = GRPC_SLICE_START_PTR(slice); uint8_t* p = GRPC_SLICE_START_PTR(slice);
GPR_ASSERT(window_delta); CHECK(window_delta);
*p++ = 0; *p++ = 0;
*p++ = 0; *p++ = 0;
@ -93,7 +94,7 @@ grpc_error_handle grpc_chttp2_window_update_parser_parse(
return GRPC_ERROR_CREATE( return GRPC_ERROR_CREATE(
absl::StrCat("invalid window update bytes: ", p->amount)); absl::StrCat("invalid window update bytes: ", p->amount));
} }
GPR_ASSERT(is_last); CHECK(is_last);
if (t->incoming_stream_id != 0) { if (t->incoming_stream_id != 0) {
if (s != nullptr) { if (s != nullptr) {

@ -21,6 +21,8 @@
#include <algorithm> #include <algorithm>
#include <cstdint> #include <cstdint>
#include "absl/log/check.h"
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/slice_buffer.h> #include <grpc/slice_buffer.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -61,7 +63,7 @@ static void FillHeader(uint8_t* p, uint8_t type, uint32_t id, size_t len,
// max_frame_size is derived from GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, // max_frame_size is derived from GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
// which has a max allowable value of 16777215 (see chttp_transport.cc). // which has a max allowable value of 16777215 (see chttp_transport.cc).
// Thus, the following assert can be a debug assert. // Thus, the following assert can be a debug assert.
GPR_DEBUG_ASSERT(len <= 16777216); DCHECK_LE(len, 16777216u);
*p++ = static_cast<uint8_t>(len >> 16); *p++ = static_cast<uint8_t>(len >> 16);
*p++ = static_cast<uint8_t>(len >> 8); *p++ = static_cast<uint8_t>(len >> 8);
*p++ = static_cast<uint8_t>(len); *p++ = static_cast<uint8_t>(len);

@ -16,16 +16,18 @@
#include <algorithm> #include <algorithm>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
uint32_t HPackEncoderTable::AllocateIndex(size_t element_size) { uint32_t HPackEncoderTable::AllocateIndex(size_t element_size) {
GPR_DEBUG_ASSERT(element_size >= 32); DCHECK_GE(element_size, 32u);
uint32_t new_index = tail_remote_index_ + table_elems_ + 1; uint32_t new_index = tail_remote_index_ + table_elems_ + 1;
GPR_DEBUG_ASSERT(element_size <= MaxEntrySize()); DCHECK(element_size <= MaxEntrySize());
if (element_size > max_table_size_) { if (element_size > max_table_size_) {
while (table_size_ > 0) { while (table_size_ > 0) {
@ -40,7 +42,7 @@ uint32_t HPackEncoderTable::AllocateIndex(size_t element_size) {
while (table_size_ + element_size > max_table_size_) { while (table_size_ + element_size > max_table_size_) {
EvictOne(); EvictOne();
} }
GPR_ASSERT(table_elems_ < elem_size_.size()); CHECK(table_elems_ < elem_size_.size());
elem_size_[new_index % elem_size_.size()] = elem_size_[new_index % elem_size_.size()] =
static_cast<uint16_t>(element_size); static_cast<uint16_t>(element_size);
table_size_ += element_size; table_size_ += element_size;
@ -69,17 +71,17 @@ bool HPackEncoderTable::SetMaxSize(uint32_t max_table_size) {
void HPackEncoderTable::EvictOne() { void HPackEncoderTable::EvictOne() {
tail_remote_index_++; tail_remote_index_++;
GPR_ASSERT(tail_remote_index_ > 0); CHECK_GT(tail_remote_index_, 0u);
GPR_ASSERT(table_elems_ > 0); CHECK_GT(table_elems_, 0u);
auto removing_size = elem_size_[tail_remote_index_ % elem_size_.size()]; auto removing_size = elem_size_[tail_remote_index_ % elem_size_.size()];
GPR_ASSERT(table_size_ >= removing_size); CHECK(table_size_ >= removing_size);
table_size_ -= removing_size; table_size_ -= removing_size;
table_elems_--; table_elems_--;
} }
void HPackEncoderTable::Rebuild(uint32_t capacity) { void HPackEncoderTable::Rebuild(uint32_t capacity) {
decltype(elem_size_) new_elem_size(capacity); decltype(elem_size_) new_elem_size(capacity);
GPR_ASSERT(table_elems_ <= capacity); CHECK_LE(table_elems_, capacity);
for (uint32_t i = 0; i < table_elems_; i++) { for (uint32_t i = 0; i < table_elems_; i++) {
uint32_t ofs = tail_remote_index_ + i + 1; uint32_t ofs = tail_remote_index_ + i + 1;
new_elem_size[ofs % capacity] = elem_size_[ofs % elem_size_.size()]; new_elem_size[ofs % capacity] = elem_size_[ofs % elem_size_.size()];

@ -16,6 +16,7 @@
#include <stddef.h> #include <stddef.h>
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -53,7 +54,7 @@ class MetadataSizeLimitExceededEncoder {
}; };
absl::Status MakeStreamError(absl::Status error) { absl::Status MakeStreamError(absl::Status error) {
GPR_DEBUG_ASSERT(!error.ok()); DCHECK(!error.ok());
return grpc_error_set_int(std::move(error), StatusIntProperty::kStreamId, 0); return grpc_error_set_int(std::move(error), StatusIntProperty::kStreamId, 0);
} }
} // namespace } // namespace

@ -21,6 +21,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -193,7 +194,7 @@ class HpackParseResult {
static HpackParseResult InvalidMetadataError(ValidateMetadataResult result, static HpackParseResult InvalidMetadataError(ValidateMetadataResult result,
absl::string_view key) { absl::string_view key) {
GPR_DEBUG_ASSERT(result != ValidateMetadataResult::kOk); DCHECK(result != ValidateMetadataResult::kOk);
HpackParseResult p{HpackParseStatus::kInvalidMetadata}; HpackParseResult p{HpackParseStatus::kInvalidMetadata};
p.state_->key = std::string(key); p.state_->key = std::string(key);
p.state_->validate_metadata_result = result; p.state_->validate_metadata_result = result;

@ -27,6 +27,7 @@
#include <utility> #include <utility>
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -194,7 +195,7 @@ class HPackParser::Input {
absl::optional<StringPrefix> ParseStringPrefix() { absl::optional<StringPrefix> ParseStringPrefix() {
auto cur = Next(); auto cur = Next();
if (!cur.has_value()) { if (!cur.has_value()) {
GPR_DEBUG_ASSERT(eof_error()); DCHECK(eof_error());
return {}; return {};
} }
// Huffman if the top bit is 1 // Huffman if the top bit is 1
@ -205,7 +206,7 @@ class HPackParser::Input {
// all ones ==> varint string length // all ones ==> varint string length
auto v = ParseVarint(0x7f); auto v = ParseVarint(0x7f);
if (!v.has_value()) { if (!v.has_value()) {
GPR_DEBUG_ASSERT(eof_error()); DCHECK(eof_error());
return {}; return {};
} }
strlen = *v; strlen = *v;
@ -228,7 +229,7 @@ class HPackParser::Input {
// Intended for errors that are specific to a stream and recoverable. // Intended for errors that are specific to a stream and recoverable.
// Callers should ensure that any hpack table updates happen. // Callers should ensure that any hpack table updates happen.
void SetErrorAndContinueParsing(HpackParseResult error) { void SetErrorAndContinueParsing(HpackParseResult error) {
GPR_DEBUG_ASSERT(error.stream_error()); DCHECK(error.stream_error());
SetError(std::move(error)); SetError(std::move(error));
} }
@ -236,7 +237,7 @@ class HPackParser::Input {
// Intended for unrecoverable errors, with the expectation that they will // Intended for unrecoverable errors, with the expectation that they will
// close the connection on return to chttp2. // close the connection on return to chttp2.
void SetErrorAndStopParsing(HpackParseResult error) { void SetErrorAndStopParsing(HpackParseResult error) {
GPR_DEBUG_ASSERT(error.connection_error()); DCHECK(error.connection_error());
SetError(std::move(error)); SetError(std::move(error));
begin_ = end_; begin_ = end_;
} }
@ -245,20 +246,20 @@ class HPackParser::Input {
// min_progress_size: how many bytes beyond the current frontier do we need to // min_progress_size: how many bytes beyond the current frontier do we need to
// read prior to being able to get further in this parse. // read prior to being able to get further in this parse.
void UnexpectedEOF(size_t min_progress_size) { void UnexpectedEOF(size_t min_progress_size) {
GPR_ASSERT(min_progress_size > 0); CHECK_GT(min_progress_size, 0u);
if (min_progress_size_ != 0 || error_.connection_error()) { if (min_progress_size_ != 0 || error_.connection_error()) {
GPR_DEBUG_ASSERT(eof_error()); DCHECK(eof_error());
return; return;
} }
// Set min progress size, taking into account bytes parsed already but not // Set min progress size, taking into account bytes parsed already but not
// consumed. // consumed.
min_progress_size_ = min_progress_size + (begin_ - frontier_); min_progress_size_ = min_progress_size + (begin_ - frontier_);
GPR_DEBUG_ASSERT(eof_error()); DCHECK(eof_error());
} }
// Update the frontier - signifies we've successfully parsed another element // Update the frontier - signifies we've successfully parsed another element
void UpdateFrontier() { void UpdateFrontier() {
GPR_DEBUG_ASSERT(skip_bytes_ == 0); DCHECK_EQ(skip_bytes_, 0u);
frontier_ = begin_; frontier_ = begin_;
} }
@ -375,7 +376,7 @@ HPackParser::String::StringResult HPackParser::String::ParseUncompressed(
// Check there's enough bytes // Check there's enough bytes
if (input->remaining() < length) { if (input->remaining() < length) {
input->UnexpectedEOF(/*min_progress_size=*/length); input->UnexpectedEOF(/*min_progress_size=*/length);
GPR_DEBUG_ASSERT(input->eof_error()); DCHECK(input->eof_error());
return StringResult{HpackParseStatus::kEof, wire_size, String{}}; return StringResult{HpackParseStatus::kEof, wire_size, String{}};
} }
auto* refcount = input->slice_refcount(); auto* refcount = input->slice_refcount();
@ -595,7 +596,7 @@ class HPackParser::Parser {
private: private:
bool ParseTop() { bool ParseTop() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kTop); DCHECK(state_.parse_state == ParseState::kTop);
auto cur = *input_->Next(); auto cur = *input_->Next();
switch (cur >> 4) { switch (cur >> 4) {
// Literal header not indexed - First byte format: 0000xxxx // Literal header not indexed - First byte format: 0000xxxx
@ -765,7 +766,7 @@ class HPackParser::Parser {
// Parse an index encoded key and a string encoded value // Parse an index encoded key and a string encoded value
bool StartIdxKey(uint32_t index, bool add_to_table) { bool StartIdxKey(uint32_t index, bool add_to_table) {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kTop); DCHECK(state_.parse_state == ParseState::kTop);
input_->UpdateFrontier(); input_->UpdateFrontier();
const auto* elem = state_.hpack_table.Lookup(index); const auto* elem = state_.hpack_table.Lookup(index);
if (GPR_UNLIKELY(elem == nullptr)) { if (GPR_UNLIKELY(elem == nullptr)) {
@ -781,14 +782,14 @@ class HPackParser::Parser {
// Parse a varint index encoded key and a string encoded value // Parse a varint index encoded key and a string encoded value
bool StartVarIdxKey(uint32_t offset, bool add_to_table) { bool StartVarIdxKey(uint32_t offset, bool add_to_table) {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kTop); DCHECK(state_.parse_state == ParseState::kTop);
auto index = input_->ParseVarint(offset); auto index = input_->ParseVarint(offset);
if (GPR_UNLIKELY(!index.has_value())) return false; if (GPR_UNLIKELY(!index.has_value())) return false;
return StartIdxKey(*index, add_to_table); return StartIdxKey(*index, add_to_table);
} }
bool StartParseLiteralKey(bool add_to_table) { bool StartParseLiteralKey(bool add_to_table) {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kTop); DCHECK(state_.parse_state == ParseState::kTop);
state_.add_to_table = add_to_table; state_.add_to_table = add_to_table;
state_.parse_state = ParseState::kParsingKeyLength; state_.parse_state = ParseState::kParsingKeyLength;
input_->UpdateFrontier(); input_->UpdateFrontier();
@ -823,7 +824,7 @@ class HPackParser::Parser {
} }
bool ParseKeyLength() { bool ParseKeyLength() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kParsingKeyLength); DCHECK(state_.parse_state == ParseState::kParsingKeyLength);
auto pfx = input_->ParseStringPrefix(); auto pfx = input_->ParseStringPrefix();
if (!pfx.has_value()) return false; if (!pfx.has_value()) return false;
state_.is_string_huff_compressed = pfx->huff; state_.is_string_huff_compressed = pfx->huff;
@ -844,14 +845,14 @@ class HPackParser::Parser {
} }
bool ParseKeyBody() { bool ParseKeyBody() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kParsingKeyBody); DCHECK(state_.parse_state == ParseState::kParsingKeyBody);
auto key = String::Parse(input_, state_.is_string_huff_compressed, auto key = String::Parse(input_, state_.is_string_huff_compressed,
state_.string_length); state_.string_length);
switch (key.status) { switch (key.status) {
case HpackParseStatus::kOk: case HpackParseStatus::kOk:
break; break;
case HpackParseStatus::kEof: case HpackParseStatus::kEof:
GPR_DEBUG_ASSERT(input_->eof_error()); DCHECK(input_->eof_error());
return false; return false;
default: default:
input_->SetErrorAndStopParsing( input_->SetErrorAndStopParsing(
@ -891,7 +892,7 @@ class HPackParser::Parser {
} }
bool SkipKeyBody() { bool SkipKeyBody() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kSkippingKeyBody); DCHECK(state_.parse_state == ParseState::kSkippingKeyBody);
if (!SkipStringBody()) return false; if (!SkipStringBody()) return false;
input_->UpdateFrontier(); input_->UpdateFrontier();
state_.parse_state = ParseState::kSkippingValueLength; state_.parse_state = ParseState::kSkippingValueLength;
@ -899,7 +900,7 @@ class HPackParser::Parser {
} }
bool SkipValueLength() { bool SkipValueLength() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kSkippingValueLength); DCHECK(state_.parse_state == ParseState::kSkippingValueLength);
auto pfx = input_->ParseStringPrefix(); auto pfx = input_->ParseStringPrefix();
if (!pfx.has_value()) return false; if (!pfx.has_value()) return false;
state_.string_length = pfx->length; state_.string_length = pfx->length;
@ -909,7 +910,7 @@ class HPackParser::Parser {
} }
bool SkipValueBody() { bool SkipValueBody() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kSkippingValueBody); DCHECK(state_.parse_state == ParseState::kSkippingValueBody);
if (!SkipStringBody()) return false; if (!SkipStringBody()) return false;
input_->UpdateFrontier(); input_->UpdateFrontier();
state_.parse_state = ParseState::kTop; state_.parse_state = ParseState::kTop;
@ -920,7 +921,7 @@ class HPackParser::Parser {
} }
bool ParseValueLength() { bool ParseValueLength() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kParsingValueLength); DCHECK(state_.parse_state == ParseState::kParsingValueLength);
auto pfx = input_->ParseStringPrefix(); auto pfx = input_->ParseStringPrefix();
if (!pfx.has_value()) return false; if (!pfx.has_value()) return false;
state_.is_string_huff_compressed = pfx->huff; state_.is_string_huff_compressed = pfx->huff;
@ -944,7 +945,7 @@ class HPackParser::Parser {
} }
bool ParseValueBody() { bool ParseValueBody() {
GPR_DEBUG_ASSERT(state_.parse_state == ParseState::kParsingValueBody); DCHECK(state_.parse_state == ParseState::kParsingValueBody);
auto value = auto value =
state_.is_binary_header state_.is_binary_header
? String::ParseBinary(input_, state_.is_string_huff_compressed, ? String::ParseBinary(input_, state_.is_string_huff_compressed,
@ -973,7 +974,7 @@ class HPackParser::Parser {
case HpackParseStatus::kOk: case HpackParseStatus::kOk:
break; break;
case HpackParseStatus::kEof: case HpackParseStatus::kEof:
GPR_DEBUG_ASSERT(input_->eof_error()); DCHECK(input_->eof_error());
return false; return false;
default: { default: {
auto result = auto result =

@ -25,6 +25,7 @@
#include <cstring> #include <cstring>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -41,7 +42,7 @@
namespace grpc_core { namespace grpc_core {
void HPackTable::MementoRingBuffer::Put(Memento m) { void HPackTable::MementoRingBuffer::Put(Memento m) {
GPR_ASSERT(num_entries_ < max_entries_); CHECK_LT(num_entries_, max_entries_);
if (entries_.size() < max_entries_) { if (entries_.size() < max_entries_) {
++num_entries_; ++num_entries_;
return entries_.push_back(std::move(m)); return entries_.push_back(std::move(m));
@ -52,7 +53,7 @@ void HPackTable::MementoRingBuffer::Put(Memento m) {
} }
auto HPackTable::MementoRingBuffer::PopOne() -> Memento { auto HPackTable::MementoRingBuffer::PopOne() -> Memento {
GPR_ASSERT(num_entries_ > 0); CHECK_GT(num_entries_, 0u);
size_t index = first_entry_ % max_entries_; size_t index = first_entry_ % max_entries_;
++first_entry_; ++first_entry_;
--num_entries_; --num_entries_;
@ -90,7 +91,7 @@ void HPackTable::MementoRingBuffer::ForEach(
// Evict one element from the table // Evict one element from the table
void HPackTable::EvictOne() { void HPackTable::EvictOne() {
auto first_entry = entries_.PopOne(); auto first_entry = entries_.PopOne();
GPR_ASSERT(first_entry.md.transport_size() <= mem_used_); CHECK(first_entry.md.transport_size() <= mem_used_);
mem_used_ -= first_entry.md.transport_size(); mem_used_ -= first_entry.md.transport_size();
} }

@ -16,6 +16,8 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -31,7 +33,7 @@ void Chttp2MaxConcurrentStreamsPolicy::FlushedSettings() {
} }
void Chttp2MaxConcurrentStreamsPolicy::AckLastSend() { void Chttp2MaxConcurrentStreamsPolicy::AckLastSend() {
GPR_ASSERT(unacked_demerits_ >= sent_demerits_); CHECK(unacked_demerits_ >= sent_demerits_);
unacked_demerits_ -= std::exchange(sent_demerits_, 0); unacked_demerits_ -= std::exchange(sent_demerits_, 0);
} }

@ -28,6 +28,7 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h" #include "absl/random/bit_gen_ref.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -267,7 +268,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_0: case GRPC_DTS_FH_0:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_frame_size = (static_cast<uint32_t>(*cur)) << 16; t->incoming_frame_size = (static_cast<uint32_t>(*cur)) << 16;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_1; t->deframe_state = GRPC_DTS_FH_1;
@ -275,7 +276,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_1: case GRPC_DTS_FH_1:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_frame_size |= (static_cast<uint32_t>(*cur)) << 8; t->incoming_frame_size |= (static_cast<uint32_t>(*cur)) << 8;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_2; t->deframe_state = GRPC_DTS_FH_2;
@ -283,7 +284,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_2: case GRPC_DTS_FH_2:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_frame_size |= *cur; t->incoming_frame_size |= *cur;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_3; t->deframe_state = GRPC_DTS_FH_3;
@ -291,7 +292,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_3: case GRPC_DTS_FH_3:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_frame_type = *cur; t->incoming_frame_type = *cur;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_4; t->deframe_state = GRPC_DTS_FH_4;
@ -299,7 +300,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_4: case GRPC_DTS_FH_4:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_frame_flags = *cur; t->incoming_frame_flags = *cur;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_5; t->deframe_state = GRPC_DTS_FH_5;
@ -307,7 +308,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_5: case GRPC_DTS_FH_5:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_stream_id = ((static_cast<uint32_t>(*cur)) & 0x7f) << 24; t->incoming_stream_id = ((static_cast<uint32_t>(*cur)) & 0x7f) << 24;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_6; t->deframe_state = GRPC_DTS_FH_6;
@ -315,7 +316,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_6: case GRPC_DTS_FH_6:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 16; t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 16;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_7; t->deframe_state = GRPC_DTS_FH_7;
@ -323,7 +324,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_7: case GRPC_DTS_FH_7:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 8; t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 8;
if (++cur == end) { if (++cur == end) {
t->deframe_state = GRPC_DTS_FH_8; t->deframe_state = GRPC_DTS_FH_8;
@ -331,7 +332,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FH_8: case GRPC_DTS_FH_8:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)); t->incoming_stream_id |= (static_cast<uint32_t>(*cur));
if (grpc_http_trace.enabled()) { if (grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "INCOMING[%p]: %s len:%d id:0x%08x", t, gpr_log(GPR_INFO, "INCOMING[%p]: %s len:%d id:0x%08x", t,
@ -366,7 +367,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
} }
ABSL_FALLTHROUGH_INTENDED; ABSL_FALLTHROUGH_INTENDED;
case GRPC_DTS_FRAME: case GRPC_DTS_FRAME:
GPR_DEBUG_ASSERT(cur < end); DCHECK_LT(cur, end);
if (static_cast<uint32_t>(end - cur) == t->incoming_frame_size) { if (static_cast<uint32_t>(end - cur) == t->incoming_frame_size) {
err = parse_frame_slice( err = parse_frame_slice(
t, t,
@ -729,7 +730,7 @@ static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t,
} else { } else {
t->incoming_stream = s; t->incoming_stream = s;
} }
GPR_DEBUG_ASSERT(s != nullptr); DCHECK_NE(s, nullptr);
s->stats.incoming.framing_bytes += 9; s->stats.incoming.framing_bytes += 9;
if (GPR_UNLIKELY(s->read_closed)) { if (GPR_UNLIKELY(s->read_closed)) {
GRPC_CHTTP2_IF_TRACING(gpr_log( GRPC_CHTTP2_IF_TRACING(gpr_log(

@ -16,6 +16,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
#include "absl/random/distributions.h" #include "absl/random/distributions.h"
@ -95,7 +96,7 @@ absl::optional<uint64_t> Chttp2PingCallbacks::OnPingTimeout(
Duration ping_timeout, Duration ping_timeout,
grpc_event_engine::experimental::EventEngine* event_engine, grpc_event_engine::experimental::EventEngine* event_engine,
Callback callback) { Callback callback) {
GPR_ASSERT(started_new_ping_without_setting_timeout_); CHECK(started_new_ping_without_setting_timeout_);
started_new_ping_without_setting_timeout_ = false; started_new_ping_without_setting_timeout_ = false;
auto it = inflight_.find(most_recent_inflight_); auto it = inflight_.find(most_recent_inflight_);
if (it == inflight_.end()) return absl::nullopt; if (it == inflight_.end()) return absl::nullopt;

@ -16,6 +16,8 @@
// //
// //
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -57,7 +59,7 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
grpc_chttp2_stream* s = t->lists[id].head; grpc_chttp2_stream* s = t->lists[id].head;
if (s) { if (s) {
grpc_chttp2_stream* new_head = s->links[id].next; grpc_chttp2_stream* new_head = s->links[id].next;
GPR_ASSERT(s->included.is_set(id)); CHECK(s->included.is_set(id));
if (new_head) { if (new_head) {
t->lists[id].head = new_head; t->lists[id].head = new_head;
new_head->links[id].prev = nullptr; new_head->links[id].prev = nullptr;
@ -77,12 +79,12 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s, static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) { grpc_chttp2_stream_list_id id) {
GPR_ASSERT(s->included.is_set(id)); CHECK(s->included.is_set(id));
s->included.clear(id); s->included.clear(id);
if (s->links[id].prev) { if (s->links[id].prev) {
s->links[id].prev->links[id].next = s->links[id].next; s->links[id].prev->links[id].next = s->links[id].next;
} else { } else {
GPR_ASSERT(t->lists[id].head == s); CHECK(t->lists[id].head == s);
t->lists[id].head = s->links[id].next; t->lists[id].head = s->links[id].next;
} }
if (s->links[id].next) { if (s->links[id].next) {
@ -111,7 +113,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) { grpc_chttp2_stream_list_id id) {
grpc_chttp2_stream* old_tail; grpc_chttp2_stream* old_tail;
GPR_ASSERT(!s->included.is_set(id)); CHECK(!s->included.is_set(id));
old_tail = t->lists[id].tail; old_tail = t->lists[id].tail;
s->links[id].next = nullptr; s->links[id].next = nullptr;
s->links[id].prev = old_tail; s->links[id].prev = old_tail;
@ -141,7 +143,7 @@ static bool stream_list_add(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t, bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) { grpc_chttp2_stream* s) {
GPR_ASSERT(s->id != 0); CHECK_NE(s->id, 0u);
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE); return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE);
} }

@ -22,6 +22,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -49,7 +51,7 @@ class VarintWriter {
explicit VarintWriter(size_t value) explicit VarintWriter(size_t value)
: value_(value), : value_(value),
length_(value < kMaxInPrefix ? 1 : VarintLength(value - kMaxInPrefix)) { length_(value < kMaxInPrefix ? 1 : VarintLength(value - kMaxInPrefix)) {
GPR_ASSERT(value <= UINT32_MAX); CHECK(value <= UINT32_MAX);
} }
size_t value() const { return value_; } size_t value() const { return value_; }

@ -16,6 +16,8 @@
#include <algorithm> #include <algorithm>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -24,7 +26,7 @@ namespace grpc_core {
size_t Chttp2WriteSizePolicy::WriteTargetSize() { return current_target_; } size_t Chttp2WriteSizePolicy::WriteTargetSize() { return current_target_; }
void Chttp2WriteSizePolicy::BeginWrite(size_t size) { void Chttp2WriteSizePolicy::BeginWrite(size_t size) {
GPR_ASSERT(experiment_start_time_ == Timestamp::InfFuture()); CHECK(experiment_start_time_ == Timestamp::InfFuture());
if (size < current_target_ * 7 / 10) { if (size < current_target_ * 7 / 10) {
// If we were trending fast but stopped getting enough data to verify, then // If we were trending fast but stopped getting enough data to verify, then
// reset back to the default state. // reset back to the default state.

@ -26,6 +26,7 @@
#include <utility> #include <utility>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -268,7 +269,7 @@ class WriteContext {
grpc_core::Http2Frame frame(std::move(*update)); grpc_core::Http2Frame frame(std::move(*update));
Serialize(absl::Span<grpc_core::Http2Frame>(&frame, 1), t_->outbuf); Serialize(absl::Span<grpc_core::Http2Frame>(&frame, 1), t_->outbuf);
if (t_->keepalive_timeout != grpc_core::Duration::Infinity()) { if (t_->keepalive_timeout != grpc_core::Duration::Infinity()) {
GPR_ASSERT( CHECK(
t_->settings_ack_watchdog == t_->settings_ack_watchdog ==
grpc_event_engine::experimental::EventEngine::TaskHandle::kInvalid); grpc_event_engine::experimental::EventEngine::TaskHandle::kInvalid);
// We base settings timeout on keepalive timeout, but double it to allow // We base settings timeout on keepalive timeout, but double it to allow
@ -290,7 +291,7 @@ class WriteContext {
// simple writes are queued to qbuf, and flushed here // simple writes are queued to qbuf, and flushed here
grpc_slice_buffer_move_into(&t_->qbuf, t_->outbuf.c_slice_buffer()); grpc_slice_buffer_move_into(&t_->qbuf, t_->outbuf.c_slice_buffer());
t_->num_pending_induced_frames = 0; t_->num_pending_induced_frames = 0;
GPR_ASSERT(t_->qbuf.count == 0); CHECK_EQ(t_->qbuf.count, 0u);
} }
void FlushWindowUpdates() { void FlushWindowUpdates() {

@ -112,13 +112,6 @@ class EventEngineSupportsFdExtension {
int fd, const EndpointConfig& config, int fd, const EndpointConfig& config,
MemoryAllocator memory_allocator) = 0; MemoryAllocator memory_allocator) = 0;
/// Creates an EventEngine::Endpoint from an fd which is already assumed to be
/// connected to a remote peer. See \a CreatePosixEndpointFromFd for details.
/// This has the same behavior, but the \a memory_allocator is taken from the
/// EndpointConfig's resource quota.
virtual std::unique_ptr<EventEngine::Endpoint> CreateEndpointFromFd(
int fd, const EndpointConfig& config) = 0;
/// Called when the posix listener has accepted a new client connection. /// Called when the posix listener has accepted a new client connection.
/// \a listener_fd - The listening socket fd that accepted the new client /// \a listener_fd - The listening socket fd that accepted the new client
/// connection. /// connection.

@ -25,6 +25,7 @@
#include "absl/cleanup/cleanup.h" #include "absl/cleanup/cleanup.h"
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -142,7 +143,7 @@ void AsyncConnect::OnWritable(absl::Status status)
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep; absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep;
mu_.Lock(); mu_.Lock();
GPR_ASSERT(fd_ != nullptr); CHECK_NE(fd_, nullptr);
fd = std::exchange(fd_, nullptr); fd = std::exchange(fd_, nullptr);
bool connect_cancelled = connect_cancelled_; bool connect_cancelled = connect_cancelled_;
if (fd->IsHandleShutdown() && status.ok()) { if (fd->IsHandleShutdown() && status.ok()) {
@ -334,7 +335,7 @@ PosixEnginePollerManager::PosixEnginePollerManager(
poller_state_(PollerState::kExternal), poller_state_(PollerState::kExternal),
executor_(nullptr), executor_(nullptr),
trigger_shutdown_called_(false) { trigger_shutdown_called_(false) {
GPR_DEBUG_ASSERT(poller_ != nullptr); DCHECK_NE(poller_, nullptr);
} }
void PosixEnginePollerManager::Run( void PosixEnginePollerManager::Run(
@ -351,7 +352,7 @@ void PosixEnginePollerManager::Run(absl::AnyInvocable<void()> cb) {
} }
void PosixEnginePollerManager::TriggerShutdown() { void PosixEnginePollerManager::TriggerShutdown() {
GPR_DEBUG_ASSERT(trigger_shutdown_called_ == false); DCHECK(trigger_shutdown_called_ == false);
trigger_shutdown_called_ = true; trigger_shutdown_called_ = true;
// If the poller is external, dont try to shut it down. Otherwise // If the poller is external, dont try to shut it down. Otherwise
// set poller state to PollerState::kShuttingDown. // set poller state to PollerState::kShuttingDown.
@ -467,7 +468,7 @@ PosixEventEngine::~PosixEventEngine() {
this, HandleToString(handle).c_str()); this, HandleToString(handle).c_str());
} }
} }
GPR_ASSERT(GPR_LIKELY(known_handles_.empty())); CHECK(GPR_LIKELY(known_handles_.empty()));
} }
timer_manager_->Shutdown(); timer_manager_->Shutdown();
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
@ -592,7 +593,7 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
auto it = shard->pending_connections.find(connection_handle); auto it = shard->pending_connections.find(connection_handle);
if (it != shard->pending_connections.end()) { if (it != shard->pending_connections.end()) {
ac = it->second; ac = it->second;
GPR_ASSERT(ac != nullptr); CHECK_NE(ac, nullptr);
// Trying to acquire ac->mu here would could cause a deadlock because // Trying to acquire ac->mu here would could cause a deadlock because
// the OnWritable method tries to acquire the two mutexes used // the OnWritable method tries to acquire the two mutexes used
// here in the reverse order. But we dont need to acquire ac->mu before // here in the reverse order. But we dont need to acquire ac->mu before
@ -639,7 +640,7 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect(
const EndpointConfig& args, MemoryAllocator memory_allocator, const EndpointConfig& args, MemoryAllocator memory_allocator,
Duration timeout) { Duration timeout) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_ASSERT(poller_manager_ != nullptr); CHECK_NE(poller_manager_, nullptr);
PosixTcpOptions options = TcpOptionsFromEndpointConfig(args); PosixTcpOptions options = TcpOptionsFromEndpointConfig(args);
absl::StatusOr<PosixSocketWrapper::PosixSocketCreateResult> socket = absl::StatusOr<PosixSocketWrapper::PosixSocketCreateResult> socket =
PosixSocketWrapper::CreateAndPrepareTcpClientSocket(options, addr); PosixSocketWrapper::CreateAndPrepareTcpClientSocket(options, addr);
@ -661,9 +662,9 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
const EndpointConfig& config, const EndpointConfig& config,
MemoryAllocator memory_allocator) { MemoryAllocator memory_allocator) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_ASSERT(fd > 0); DCHECK_GT(fd, 0);
PosixEventPoller* poller = poller_manager_->Poller(); PosixEventPoller* poller = poller_manager_->Poller();
GPR_DEBUG_ASSERT(poller != nullptr); DCHECK_NE(poller, nullptr);
EventHandle* handle = EventHandle* handle =
poller->CreateHandle(fd, "tcp-client", poller->CanTrackErrors()); poller->CreateHandle(fd, "tcp-client", poller->CanTrackErrors());
return CreatePosixEndpoint(handle, nullptr, shared_from_this(), return CreatePosixEndpoint(handle, nullptr, shared_from_this(),
@ -676,22 +677,6 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
#endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
} }
std::unique_ptr<EventEngine::Endpoint> PosixEventEngine::CreateEndpointFromFd(
int fd, const EndpointConfig& config) {
auto options = TcpOptionsFromEndpointConfig(config);
MemoryAllocator allocator;
if (options.memory_allocator_factory != nullptr) {
return CreatePosixEndpointFromFd(
fd, config,
options.memory_allocator_factory->CreateMemoryAllocator(
absl::StrCat("allocator:", fd)));
}
return CreatePosixEndpointFromFd(
fd, config,
options.resource_quota->memory_quota()->CreateMemoryAllocator(
absl::StrCat("allocator:", fd)));
}
absl::StatusOr<std::unique_ptr<EventEngine::Listener>> absl::StatusOr<std::unique_ptr<EventEngine::Listener>>
PosixEventEngine::CreateListener( PosixEventEngine::CreateListener(
Listener::AcceptCallback on_accept, Listener::AcceptCallback on_accept,

@ -172,8 +172,6 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport,
std::unique_ptr<EventEngine::Endpoint> CreatePosixEndpointFromFd( std::unique_ptr<EventEngine::Endpoint> CreatePosixEndpointFromFd(
int fd, const EndpointConfig& config, int fd, const EndpointConfig& config,
MemoryAllocator memory_allocator) override; MemoryAllocator memory_allocator) override;
std::unique_ptr<EventEngine::Endpoint> CreateEndpointFromFd(
int fd, const EndpointConfig& config) override;
absl::StatusOr<std::unique_ptr<Listener>> CreateListener( absl::StatusOr<std::unique_ptr<Listener>> CreateListener(
Listener::AcceptCallback on_accept, Listener::AcceptCallback on_accept,

@ -23,7 +23,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "absl/log/globals.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -39,7 +38,6 @@
#define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR"
#endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING
static constexpr int g_absl_vlog_level_for_gpr_verbosity_debug = 2;
static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10; static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10;
static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11; static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11;
@ -85,9 +83,8 @@ void gpr_default_log(gpr_log_func_args* args) {
} }
switch (args->severity) { switch (args->severity) {
case GPR_LOG_SEVERITY_DEBUG: case GPR_LOG_SEVERITY_DEBUG:
VLOG(g_absl_vlog_level_for_gpr_verbosity_debug) // Log DEBUG messages as VLOG(2).
.AtLocation(args->file, args->line) VLOG(2).AtLocation(args->file, args->line) << args->message;
<< args->message;
return; return;
case GPR_LOG_SEVERITY_INFO: case GPR_LOG_SEVERITY_INFO:
LOG(INFO).AtLocation(args->file, args->line) << args->message; LOG(INFO).AtLocation(args->file, args->line) << args->message;
@ -148,12 +145,6 @@ void gpr_log_verbosity_init() {
parse_log_severity(verbosity, min_severity_to_print); parse_log_severity(verbosity, min_severity_to_print);
} }
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
if (grpc_core::ConfigVars::Get().AbslLogging() &&
min_severity_to_print == GPR_LOG_SEVERITY_DEBUG) {
// Matches full file paths that include a `*grpc*` folder, including
// grpcpp.
absl::SetVLogLevel("*grpc*/*", g_absl_vlog_level_for_gpr_verbosity_debug);
}
} }
// init stacktrace_minloglevel when it hasn't been set // init stacktrace_minloglevel when it hasn't been set
if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) == if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) ==

@ -40,7 +40,6 @@
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/passive_listener.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -76,9 +75,6 @@
"grpc.server.max_pending_requests_hard_limit" "grpc.server.max_pending_requests_hard_limit"
namespace grpc_core { namespace grpc_core {
namespace experimental {
class PassiveListenerImpl;
} // namespace experimental
extern TraceFlag grpc_server_channel_trace; extern TraceFlag grpc_server_channel_trace;
@ -117,7 +113,7 @@ class Server : public ServerInterface,
/// Interface for listeners. /// Interface for listeners.
/// Implementations must override the Orphan() method, which should stop /// Implementations must override the Orphan() method, which should stop
/// listening and initiate destruction of the listener. /// listening and initiate destruction of the listener.
class ListenerInterface : public InternallyRefCounted<ListenerInterface> { class ListenerInterface : public Orphanable {
public: public:
~ListenerInterface() override = default; ~ListenerInterface() override = default;
@ -221,14 +217,6 @@ class Server : public ServerInterface,
} }
private: private:
// note: the grpc_core::Server redundant namespace qualification is
// required for older gcc versions.
// TODO(yashykt): eliminate this friend statement as part of your upcoming
// server listener refactoring.
friend absl::Status(::grpc_server_add_passive_listener)(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
struct RequestedCall; struct RequestedCall;
class RequestMatcherInterface; class RequestMatcherInterface;

@ -20,6 +20,7 @@
#include <list> #include <list>
#include "absl/log/check.h"
#include "absl/strings/numbers.h" #include "absl/strings/numbers.h"
#include "upb/mem/arena.hpp" #include "upb/mem/arena.hpp"
@ -117,13 +118,13 @@ typedef struct alts_grpc_handshaker_client {
static void handshaker_client_send_buffer_destroy( static void handshaker_client_send_buffer_destroy(
alts_grpc_handshaker_client* client) { alts_grpc_handshaker_client* client) {
GPR_ASSERT(client != nullptr); CHECK_NE(client, nullptr);
grpc_byte_buffer_destroy(client->send_buffer); grpc_byte_buffer_destroy(client->send_buffer);
client->send_buffer = nullptr; client->send_buffer = nullptr;
} }
static bool is_handshake_finished_properly(grpc_gcp_HandshakerResp* resp) { static bool is_handshake_finished_properly(grpc_gcp_HandshakerResp* resp) {
GPR_ASSERT(resp != nullptr); CHECK_NE(resp, nullptr);
return grpc_gcp_HandshakerResp_result(resp) != nullptr; return grpc_gcp_HandshakerResp_result(resp) != nullptr;
} }
@ -156,7 +157,7 @@ static void maybe_complete_tsi_next(
grpc_core::MutexLock lock(&client->mu); grpc_core::MutexLock lock(&client->mu);
client->receive_status_finished |= receive_status_finished; client->receive_status_finished |= receive_status_finished;
if (pending_recv_message_result != nullptr) { if (pending_recv_message_result != nullptr) {
GPR_ASSERT(client->pending_recv_message_result == nullptr); CHECK_EQ(client->pending_recv_message_result, nullptr);
client->pending_recv_message_result = pending_recv_message_result; client->pending_recv_message_result = pending_recv_message_result;
} }
if (client->pending_recv_message_result == nullptr) { if (client->pending_recv_message_result == nullptr) {
@ -197,7 +198,7 @@ static void handle_response_done(alts_grpc_handshaker_client* client,
void alts_handshaker_client_handle_response(alts_handshaker_client* c, void alts_handshaker_client_handle_response(alts_handshaker_client* c,
bool is_ok) { bool is_ok) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
grpc_byte_buffer* recv_buffer = client->recv_buffer; grpc_byte_buffer* recv_buffer = client->recv_buffer;
@ -312,7 +313,7 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c,
static tsi_result continue_make_grpc_call(alts_grpc_handshaker_client* client, static tsi_result continue_make_grpc_call(alts_grpc_handshaker_client* client,
bool is_start) { bool is_start) {
GPR_ASSERT(client != nullptr); CHECK_NE(client, nullptr);
grpc_op ops[kHandshakerClientOpNum]; grpc_op ops[kHandshakerClientOpNum];
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
grpc_op* op = ops; grpc_op* op = ops;
@ -325,34 +326,34 @@ static tsi_result continue_make_grpc_call(alts_grpc_handshaker_client* client,
op->flags = 0; op->flags = 0;
op->reserved = nullptr; op->reserved = nullptr;
op++; op++;
GPR_ASSERT(op - ops <= kHandshakerClientOpNum); CHECK(op - ops <= kHandshakerClientOpNum);
gpr_ref(&client->refs); gpr_ref(&client->refs);
grpc_call_error call_error = grpc_call_error call_error =
client->grpc_caller(client->call, ops, static_cast<size_t>(op - ops), client->grpc_caller(client->call, ops, static_cast<size_t>(op - ops),
&client->on_status_received); &client->on_status_received);
// TODO(apolcyn): return the error here instead, as done for other ops? // TODO(apolcyn): return the error here instead, as done for other ops?
GPR_ASSERT(call_error == GRPC_CALL_OK); CHECK_EQ(call_error, GRPC_CALL_OK);
memset(ops, 0, sizeof(ops)); memset(ops, 0, sizeof(ops));
op = ops; op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA; op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0; op->data.send_initial_metadata.count = 0;
op++; op++;
GPR_ASSERT(op - ops <= kHandshakerClientOpNum); CHECK(op - ops <= kHandshakerClientOpNum);
op->op = GRPC_OP_RECV_INITIAL_METADATA; op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = op->data.recv_initial_metadata.recv_initial_metadata =
&client->recv_initial_metadata; &client->recv_initial_metadata;
op++; op++;
GPR_ASSERT(op - ops <= kHandshakerClientOpNum); CHECK(op - ops <= kHandshakerClientOpNum);
} }
op->op = GRPC_OP_SEND_MESSAGE; op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = client->send_buffer; op->data.send_message.send_message = client->send_buffer;
op++; op++;
GPR_ASSERT(op - ops <= kHandshakerClientOpNum); CHECK(op - ops <= kHandshakerClientOpNum);
op->op = GRPC_OP_RECV_MESSAGE; op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &client->recv_buffer; op->data.recv_message.recv_message = &client->recv_buffer;
op++; op++;
GPR_ASSERT(op - ops <= kHandshakerClientOpNum); CHECK(op - ops <= kHandshakerClientOpNum);
GPR_ASSERT(client->grpc_caller != nullptr); CHECK_NE(client->grpc_caller, nullptr);
if (client->grpc_caller(client->call, ops, static_cast<size_t>(op - ops), if (client->grpc_caller(client->call, ops, static_cast<size_t>(op - ops),
&client->on_handshaker_service_resp_recv) != &client->on_handshaker_service_resp_recv) !=
GRPC_CALL_OK) { GRPC_CALL_OK) {
@ -450,7 +451,7 @@ void HandshakeDone(bool is_client) {
/// make a grpc call. /// make a grpc call.
/// ///
static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) { static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
if (is_start) { if (is_start) {
@ -500,7 +501,7 @@ static grpc_byte_buffer* get_serialized_handshaker_req(
// Create and populate a client_start handshaker request, then serialize it. // Create and populate a client_start handshaker request, then serialize it.
static grpc_byte_buffer* get_serialized_start_client( static grpc_byte_buffer* get_serialized_start_client(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
upb::Arena arena; upb::Arena arena;
@ -565,8 +566,8 @@ static tsi_result handshaker_client_start_client(alts_handshaker_client* c) {
// Create and populate a start_server handshaker request, then serialize it. // Create and populate a start_server handshaker request, then serialize it.
static grpc_byte_buffer* get_serialized_start_server( static grpc_byte_buffer* get_serialized_start_server(
alts_handshaker_client* c, grpc_slice* bytes_received) { alts_handshaker_client* c, grpc_slice* bytes_received) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
GPR_ASSERT(bytes_received != nullptr); CHECK_NE(bytes_received, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
@ -623,7 +624,7 @@ static tsi_result handshaker_client_start_server(alts_handshaker_client* c,
// Create and populate a next handshaker request, then serialize it. // Create and populate a next handshaker request, then serialize it.
static grpc_byte_buffer* get_serialized_next(grpc_slice* bytes_received) { static grpc_byte_buffer* get_serialized_next(grpc_slice* bytes_received) {
GPR_ASSERT(bytes_received != nullptr); CHECK_NE(bytes_received, nullptr);
upb::Arena arena; upb::Arena arena;
grpc_gcp_HandshakerReq* req = grpc_gcp_HandshakerReq_new(arena.ptr()); grpc_gcp_HandshakerReq* req = grpc_gcp_HandshakerReq_new(arena.ptr());
grpc_gcp_NextHandshakeMessageReq* next = grpc_gcp_NextHandshakeMessageReq* next =
@ -661,7 +662,7 @@ static tsi_result handshaker_client_next(alts_handshaker_client* c,
} }
static void handshaker_client_shutdown(alts_handshaker_client* c) { static void handshaker_client_shutdown(alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
if (client->call != nullptr) { if (client->call != nullptr) {
@ -759,7 +760,8 @@ namespace internal {
void alts_handshaker_client_set_grpc_caller_for_testing( void alts_handshaker_client_set_grpc_caller_for_testing(
alts_handshaker_client* c, alts_grpc_caller caller) { alts_handshaker_client* c, alts_grpc_caller caller) {
GPR_ASSERT(c != nullptr && caller != nullptr); CHECK(c != nullptr);
CHECK_NE(caller, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
client->grpc_caller = caller; client->grpc_caller = caller;
@ -767,7 +769,7 @@ void alts_handshaker_client_set_grpc_caller_for_testing(
grpc_byte_buffer* alts_handshaker_client_get_send_buffer_for_testing( grpc_byte_buffer* alts_handshaker_client_get_send_buffer_for_testing(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
return client->send_buffer; return client->send_buffer;
@ -775,7 +777,7 @@ grpc_byte_buffer* alts_handshaker_client_get_send_buffer_for_testing(
grpc_byte_buffer** alts_handshaker_client_get_recv_buffer_addr_for_testing( grpc_byte_buffer** alts_handshaker_client_get_recv_buffer_addr_for_testing(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
return &client->recv_buffer; return &client->recv_buffer;
@ -783,7 +785,7 @@ grpc_byte_buffer** alts_handshaker_client_get_recv_buffer_addr_for_testing(
grpc_metadata_array* alts_handshaker_client_get_initial_metadata_for_testing( grpc_metadata_array* alts_handshaker_client_get_initial_metadata_for_testing(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
return &client->recv_initial_metadata; return &client->recv_initial_metadata;
@ -791,7 +793,7 @@ grpc_metadata_array* alts_handshaker_client_get_initial_metadata_for_testing(
void alts_handshaker_client_set_recv_bytes_for_testing( void alts_handshaker_client_set_recv_bytes_for_testing(
alts_handshaker_client* c, grpc_slice* recv_bytes) { alts_handshaker_client* c, grpc_slice* recv_bytes) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
client->recv_bytes = CSliceRef(*recv_bytes); client->recv_bytes = CSliceRef(*recv_bytes);
@ -801,7 +803,7 @@ void alts_handshaker_client_set_fields_for_testing(
alts_handshaker_client* c, alts_tsi_handshaker* handshaker, alts_handshaker_client* c, alts_tsi_handshaker* handshaker,
tsi_handshaker_on_next_done_cb cb, void* user_data, tsi_handshaker_on_next_done_cb cb, void* user_data,
grpc_byte_buffer* recv_buffer, bool inject_read_failure) { grpc_byte_buffer* recv_buffer, bool inject_read_failure) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
client->handshaker = handshaker; client->handshaker = handshaker;
@ -814,22 +816,22 @@ void alts_handshaker_client_set_fields_for_testing(
void alts_handshaker_client_check_fields_for_testing( void alts_handshaker_client_check_fields_for_testing(
alts_handshaker_client* c, tsi_handshaker_on_next_done_cb cb, alts_handshaker_client* c, tsi_handshaker_on_next_done_cb cb,
void* user_data, bool has_sent_start_message, grpc_slice* recv_bytes) { void* user_data, bool has_sent_start_message, grpc_slice* recv_bytes) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
GPR_ASSERT(client->cb == cb); CHECK(client->cb == cb);
GPR_ASSERT(client->user_data == user_data); CHECK(client->user_data == user_data);
if (recv_bytes != nullptr) { if (recv_bytes != nullptr) {
GPR_ASSERT(grpc_slice_cmp(client->recv_bytes, *recv_bytes) == 0); CHECK_EQ(grpc_slice_cmp(client->recv_bytes, *recv_bytes), 0);
} }
GPR_ASSERT(alts_tsi_handshaker_get_has_sent_start_message_for_testing( CHECK(alts_tsi_handshaker_get_has_sent_start_message_for_testing(
client->handshaker) == has_sent_start_message); client->handshaker) == has_sent_start_message);
} }
void alts_handshaker_client_set_vtable_for_testing( void alts_handshaker_client_set_vtable_for_testing(
alts_handshaker_client* c, alts_handshaker_client_vtable* vtable) { alts_handshaker_client* c, alts_handshaker_client_vtable* vtable) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
GPR_ASSERT(vtable != nullptr); CHECK_NE(vtable, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
client->base.vtable = vtable; client->base.vtable = vtable;
@ -837,7 +839,7 @@ void alts_handshaker_client_set_vtable_for_testing(
alts_tsi_handshaker* alts_handshaker_client_get_handshaker_for_testing( alts_tsi_handshaker* alts_handshaker_client_get_handshaker_for_testing(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
return client->handshaker; return client->handshaker;
@ -845,7 +847,7 @@ alts_tsi_handshaker* alts_handshaker_client_get_handshaker_for_testing(
void alts_handshaker_client_set_cb_for_testing( void alts_handshaker_client_set_cb_for_testing(
alts_handshaker_client* c, tsi_handshaker_on_next_done_cb cb) { alts_handshaker_client* c, tsi_handshaker_on_next_done_cb cb) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
client->cb = cb; client->cb = cb;
@ -853,7 +855,7 @@ void alts_handshaker_client_set_cb_for_testing(
grpc_closure* alts_handshaker_client_get_closure_for_testing( grpc_closure* alts_handshaker_client_get_closure_for_testing(
alts_handshaker_client* c) { alts_handshaker_client* c) {
GPR_ASSERT(c != nullptr); CHECK_NE(c, nullptr);
alts_grpc_handshaker_client* client = alts_grpc_handshaker_client* client =
reinterpret_cast<alts_grpc_handshaker_client*>(c); reinterpret_cast<alts_grpc_handshaker_client*>(c);
return &client->on_handshaker_service_resp_recv; return &client->on_handshaker_service_resp_recv;

@ -18,6 +18,8 @@
#include "src/core/tsi/alts/handshaker/alts_shared_resource.h" #include "src/core/tsi/alts/handshaker/alts_shared_resource.h"
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -36,11 +38,11 @@ static void thread_worker(void* /*arg*/) {
grpc_event event = grpc_event event =
grpc_completion_queue_next(g_alts_resource_dedicated.cq, grpc_completion_queue_next(g_alts_resource_dedicated.cq,
gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(event.type != GRPC_QUEUE_TIMEOUT); CHECK(event.type != GRPC_QUEUE_TIMEOUT);
if (event.type == GRPC_QUEUE_SHUTDOWN) { if (event.type == GRPC_QUEUE_SHUTDOWN) {
break; break;
} }
GPR_ASSERT(event.type == GRPC_OP_COMPLETE); CHECK(event.type == GRPC_OP_COMPLETE);
alts_handshaker_client* client = alts_handshaker_client* client =
static_cast<alts_handshaker_client*>(event.tag); static_cast<alts_handshaker_client*>(event.tag);
alts_handshaker_client_handle_response(client, event.success); alts_handshaker_client_handle_response(client, event.success);

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include "upb/mem/arena.hpp" #include "upb/mem/arena.hpp"
#include <grpc/credentials.h> #include <grpc/credentials.h>
@ -92,14 +93,14 @@ static tsi_result handshaker_result_extract_peer(
alts_tsi_handshaker_result* result = alts_tsi_handshaker_result* result =
reinterpret_cast<alts_tsi_handshaker_result*>( reinterpret_cast<alts_tsi_handshaker_result*>(
const_cast<tsi_handshaker_result*>(self)); const_cast<tsi_handshaker_result*>(self));
GPR_ASSERT(kTsiAltsNumOfPeerProperties == 5); CHECK_EQ(kTsiAltsNumOfPeerProperties, 5u);
tsi_result ok = tsi_construct_peer(kTsiAltsNumOfPeerProperties, peer); tsi_result ok = tsi_construct_peer(kTsiAltsNumOfPeerProperties, peer);
int index = 0; int index = 0;
if (ok != TSI_OK) { if (ok != TSI_OK) {
gpr_log(GPR_ERROR, "Failed to construct tsi peer"); gpr_log(GPR_ERROR, "Failed to construct tsi peer");
return ok; return ok;
} }
GPR_ASSERT(&peer->properties[index] != nullptr); CHECK_NE(&peer->properties[index], nullptr);
ok = tsi_construct_string_peer_property_from_cstring( ok = tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_ALTS_CERTIFICATE_TYPE, TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_ALTS_CERTIFICATE_TYPE,
&peer->properties[index]); &peer->properties[index]);
@ -109,7 +110,7 @@ static tsi_result handshaker_result_extract_peer(
return ok; return ok;
} }
index++; index++;
GPR_ASSERT(&peer->properties[index] != nullptr); CHECK_NE(&peer->properties[index], nullptr);
ok = tsi_construct_string_peer_property_from_cstring( ok = tsi_construct_string_peer_property_from_cstring(
TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY, result->peer_identity, TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY, result->peer_identity,
&peer->properties[index]); &peer->properties[index]);
@ -118,7 +119,7 @@ static tsi_result handshaker_result_extract_peer(
gpr_log(GPR_ERROR, "Failed to set tsi peer property"); gpr_log(GPR_ERROR, "Failed to set tsi peer property");
} }
index++; index++;
GPR_ASSERT(&peer->properties[index] != nullptr); CHECK_NE(&peer->properties[index], nullptr);
ok = tsi_construct_string_peer_property( ok = tsi_construct_string_peer_property(
TSI_ALTS_RPC_VERSIONS, TSI_ALTS_RPC_VERSIONS,
reinterpret_cast<char*>(GRPC_SLICE_START_PTR(result->rpc_versions)), reinterpret_cast<char*>(GRPC_SLICE_START_PTR(result->rpc_versions)),
@ -128,7 +129,7 @@ static tsi_result handshaker_result_extract_peer(
gpr_log(GPR_ERROR, "Failed to set tsi peer property"); gpr_log(GPR_ERROR, "Failed to set tsi peer property");
} }
index++; index++;
GPR_ASSERT(&peer->properties[index] != nullptr); CHECK_NE(&peer->properties[index], nullptr);
ok = tsi_construct_string_peer_property( ok = tsi_construct_string_peer_property(
TSI_ALTS_CONTEXT, TSI_ALTS_CONTEXT,
reinterpret_cast<char*>(GRPC_SLICE_START_PTR(result->serialized_context)), reinterpret_cast<char*>(GRPC_SLICE_START_PTR(result->serialized_context)),
@ -138,7 +139,7 @@ static tsi_result handshaker_result_extract_peer(
gpr_log(GPR_ERROR, "Failed to set tsi peer property"); gpr_log(GPR_ERROR, "Failed to set tsi peer property");
} }
index++; index++;
GPR_ASSERT(&peer->properties[index] != nullptr); CHECK_NE(&peer->properties[index], nullptr);
ok = tsi_construct_string_peer_property_from_cstring( ok = tsi_construct_string_peer_property_from_cstring(
TSI_SECURITY_LEVEL_PEER_PROPERTY, TSI_SECURITY_LEVEL_PEER_PROPERTY,
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY),
@ -147,7 +148,7 @@ static tsi_result handshaker_result_extract_peer(
tsi_peer_destruct(peer); tsi_peer_destruct(peer);
gpr_log(GPR_ERROR, "Failed to set tsi peer property"); gpr_log(GPR_ERROR, "Failed to set tsi peer property");
} }
GPR_ASSERT(++index == kTsiAltsNumOfPeerProperties); CHECK(++index == kTsiAltsNumOfPeerProperties);
return ok; return ok;
} }
@ -423,7 +424,7 @@ static tsi_result alts_tsi_handshaker_continue_handshaker_next(
handshaker->handshaker_service_url); handshaker->handshaker_service_url);
handshaker->interested_parties = handshaker->interested_parties =
grpc_alts_get_shared_resource_dedicated()->interested_parties; grpc_alts_get_shared_resource_dedicated()->interested_parties;
GPR_ASSERT(handshaker->interested_parties != nullptr); CHECK_NE(handshaker->interested_parties, nullptr);
} }
grpc_iomgr_cb_func grpc_cb = handshaker->channel == nullptr grpc_iomgr_cb_func grpc_cb = handshaker->channel == nullptr
? on_handshaker_service_resp_recv_dedicated ? on_handshaker_service_resp_recv_dedicated
@ -445,7 +446,7 @@ static tsi_result alts_tsi_handshaker_continue_handshaker_next(
} }
{ {
grpc_core::MutexLock lock(&handshaker->mu); grpc_core::MutexLock lock(&handshaker->mu);
GPR_ASSERT(handshaker->client == nullptr); CHECK_EQ(handshaker->client, nullptr);
handshaker->client = client; handshaker->client = client;
if (handshaker->shutdown) { if (handshaker->shutdown) {
gpr_log(GPR_INFO, "TSI handshake shutdown"); gpr_log(GPR_INFO, "TSI handshake shutdown");
@ -457,7 +458,7 @@ static tsi_result alts_tsi_handshaker_continue_handshaker_next(
} }
if (handshaker->channel == nullptr && if (handshaker->channel == nullptr &&
handshaker->client_vtable_for_testing == nullptr) { handshaker->client_vtable_for_testing == nullptr) {
GPR_ASSERT(grpc_cq_begin_op(grpc_alts_get_shared_resource_dedicated()->cq, CHECK(grpc_cq_begin_op(grpc_alts_get_shared_resource_dedicated()->cq,
handshaker->client)); handshaker->client));
} }
grpc_slice slice = (received_bytes == nullptr || received_bytes_size == 0) grpc_slice slice = (received_bytes == nullptr || received_bytes_size == 0)
@ -500,7 +501,7 @@ static void alts_tsi_handshaker_create_channel(
alts_tsi_handshaker_continue_handshaker_next_args* next_args = alts_tsi_handshaker_continue_handshaker_next_args* next_args =
static_cast<alts_tsi_handshaker_continue_handshaker_next_args*>(arg); static_cast<alts_tsi_handshaker_continue_handshaker_next_args*>(arg);
alts_tsi_handshaker* handshaker = next_args->handshaker; alts_tsi_handshaker* handshaker = next_args->handshaker;
GPR_ASSERT(handshaker->channel == nullptr); CHECK_EQ(handshaker->channel, nullptr);
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); grpc_channel_credentials* creds = grpc_insecure_credentials_create();
// Disable retries so that we quickly get a signal when the // Disable retries so that we quickly get a signal when the
// handshake server is not reachable. // handshake server is not reachable.
@ -592,7 +593,7 @@ static tsi_result handshaker_next_dedicated(
} }
static void handshaker_shutdown(tsi_handshaker* self) { static void handshaker_shutdown(tsi_handshaker* self) {
GPR_ASSERT(self != nullptr); CHECK_NE(self, nullptr);
alts_tsi_handshaker* handshaker = alts_tsi_handshaker* handshaker =
reinterpret_cast<alts_tsi_handshaker*>(self); reinterpret_cast<alts_tsi_handshaker*>(self);
grpc_core::MutexLock lock(&handshaker->mu); grpc_core::MutexLock lock(&handshaker->mu);
@ -638,7 +639,7 @@ static const tsi_handshaker_vtable handshaker_vtable_dedicated = {
handshaker_shutdown}; handshaker_shutdown};
bool alts_tsi_handshaker_has_shutdown(alts_tsi_handshaker* handshaker) { bool alts_tsi_handshaker_has_shutdown(alts_tsi_handshaker* handshaker) {
GPR_ASSERT(handshaker != nullptr); CHECK_NE(handshaker, nullptr);
grpc_core::MutexLock lock(&handshaker->mu); grpc_core::MutexLock lock(&handshaker->mu);
return handshaker->shutdown; return handshaker->shutdown;
} }
@ -676,7 +677,8 @@ tsi_result alts_tsi_handshaker_create(
void alts_tsi_handshaker_result_set_unused_bytes(tsi_handshaker_result* result, void alts_tsi_handshaker_result_set_unused_bytes(tsi_handshaker_result* result,
grpc_slice* recv_bytes, grpc_slice* recv_bytes,
size_t bytes_consumed) { size_t bytes_consumed) {
GPR_ASSERT(recv_bytes != nullptr && result != nullptr); CHECK(recv_bytes != nullptr);
CHECK_NE(result, nullptr);
if (GRPC_SLICE_LENGTH(*recv_bytes) == bytes_consumed) { if (GRPC_SLICE_LENGTH(*recv_bytes) == bytes_consumed) {
return; return;
} }
@ -695,19 +697,19 @@ namespace internal {
bool alts_tsi_handshaker_get_has_sent_start_message_for_testing( bool alts_tsi_handshaker_get_has_sent_start_message_for_testing(
alts_tsi_handshaker* handshaker) { alts_tsi_handshaker* handshaker) {
GPR_ASSERT(handshaker != nullptr); CHECK_NE(handshaker, nullptr);
return handshaker->has_sent_start_message; return handshaker->has_sent_start_message;
} }
void alts_tsi_handshaker_set_client_vtable_for_testing( void alts_tsi_handshaker_set_client_vtable_for_testing(
alts_tsi_handshaker* handshaker, alts_handshaker_client_vtable* vtable) { alts_tsi_handshaker* handshaker, alts_handshaker_client_vtable* vtable) {
GPR_ASSERT(handshaker != nullptr); CHECK_NE(handshaker, nullptr);
handshaker->client_vtable_for_testing = vtable; handshaker->client_vtable_for_testing = vtable;
} }
bool alts_tsi_handshaker_get_is_client_for_testing( bool alts_tsi_handshaker_get_is_client_for_testing(
alts_tsi_handshaker* handshaker) { alts_tsi_handshaker* handshaker) {
GPR_ASSERT(handshaker != nullptr); CHECK_NE(handshaker, nullptr);
return handshaker->is_client; return handshaker->is_client;
} }

@ -18,6 +18,8 @@
#include "src/core/tsi/alts/handshaker/alts_tsi_utils.h" #include "src/core/tsi/alts/handshaker/alts_tsi_utils.h"
#include "absl/log/check.h"
#include <grpc/byte_buffer_reader.h> #include <grpc/byte_buffer_reader.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -43,8 +45,8 @@ tsi_result alts_tsi_utils_convert_to_tsi_result(grpc_status_code code) {
grpc_gcp_HandshakerResp* alts_tsi_utils_deserialize_response( grpc_gcp_HandshakerResp* alts_tsi_utils_deserialize_response(
grpc_byte_buffer* resp_buffer, upb_Arena* arena) { grpc_byte_buffer* resp_buffer, upb_Arena* arena) {
GPR_ASSERT(resp_buffer != nullptr); CHECK_NE(resp_buffer, nullptr);
GPR_ASSERT(arena != nullptr); CHECK_NE(arena, nullptr);
grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader bbr;
grpc_byte_buffer_reader_init(&bbr, resp_buffer); grpc_byte_buffer_reader_init(&bbr, resp_buffer);
grpc_slice slice = grpc_byte_buffer_reader_readall(&bbr); grpc_slice slice = grpc_byte_buffer_reader_readall(&bbr);

@ -20,6 +20,8 @@
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -142,14 +144,14 @@ static tsi_result alts_grpc_integrity_only_unprotect(
grpc_slice_buffer_reset_and_unref(&rp->header_sb); grpc_slice_buffer_reset_and_unref(&rp->header_sb);
grpc_slice_buffer_move_first(protected_slices, rp->header_length, grpc_slice_buffer_move_first(protected_slices, rp->header_length,
&rp->header_sb); &rp->header_sb);
GPR_ASSERT(rp->header_sb.length == rp->header_length); CHECK(rp->header_sb.length == rp->header_length);
iovec_t header_iovec = alts_grpc_record_protocol_get_header_iovec(rp); iovec_t header_iovec = alts_grpc_record_protocol_get_header_iovec(rp);
// Moves protected slices data to data_sb and leaves the remaining tag. // Moves protected slices data to data_sb and leaves the remaining tag.
grpc_slice_buffer_reset_and_unref(&integrity_only_record_protocol->data_sb); grpc_slice_buffer_reset_and_unref(&integrity_only_record_protocol->data_sb);
grpc_slice_buffer_move_first(protected_slices, grpc_slice_buffer_move_first(protected_slices,
protected_slices->length - rp->tag_length, protected_slices->length - rp->tag_length,
&integrity_only_record_protocol->data_sb); &integrity_only_record_protocol->data_sb);
GPR_ASSERT(protected_slices->length == rp->tag_length); CHECK(protected_slices->length == rp->tag_length);
iovec_t tag_iovec = {nullptr, rp->tag_length}; iovec_t tag_iovec = {nullptr, rp->tag_length};
if (protected_slices->count == 1) { if (protected_slices->count == 1) {
tag_iovec.iov_base = GRPC_SLICE_START_PTR(protected_slices->slices[0]); tag_iovec.iov_base = GRPC_SLICE_START_PTR(protected_slices->slices[0]);

@ -20,6 +20,8 @@
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -34,7 +36,8 @@ const size_t kInitialIovecBufferSize = 8;
// Makes sure iovec_buf in alts_grpc_record_protocol is large enough. // Makes sure iovec_buf in alts_grpc_record_protocol is large enough.
static void ensure_iovec_buf_size(alts_grpc_record_protocol* rp, static void ensure_iovec_buf_size(alts_grpc_record_protocol* rp,
const grpc_slice_buffer* sb) { const grpc_slice_buffer* sb) {
GPR_ASSERT(rp != nullptr && sb != nullptr); CHECK(rp != nullptr);
CHECK_NE(sb, nullptr);
if (sb->count <= rp->iovec_buf_length) { if (sb->count <= rp->iovec_buf_length) {
return; return;
} }
@ -49,7 +52,8 @@ static void ensure_iovec_buf_size(alts_grpc_record_protocol* rp,
void alts_grpc_record_protocol_convert_slice_buffer_to_iovec( void alts_grpc_record_protocol_convert_slice_buffer_to_iovec(
alts_grpc_record_protocol* rp, const grpc_slice_buffer* sb) { alts_grpc_record_protocol* rp, const grpc_slice_buffer* sb) {
GPR_ASSERT(rp != nullptr && sb != nullptr); CHECK(rp != nullptr);
CHECK_NE(sb, nullptr);
ensure_iovec_buf_size(rp, sb); ensure_iovec_buf_size(rp, sb);
for (size_t i = 0; i < sb->count; i++) { for (size_t i = 0; i < sb->count; i++) {
rp->iovec_buf[i].iov_base = GRPC_SLICE_START_PTR(sb->slices[i]); rp->iovec_buf[i].iov_base = GRPC_SLICE_START_PTR(sb->slices[i]);
@ -59,7 +63,8 @@ void alts_grpc_record_protocol_convert_slice_buffer_to_iovec(
void alts_grpc_record_protocol_copy_slice_buffer(const grpc_slice_buffer* src, void alts_grpc_record_protocol_copy_slice_buffer(const grpc_slice_buffer* src,
unsigned char* dst) { unsigned char* dst) {
GPR_ASSERT(src != nullptr && dst != nullptr); CHECK(src != nullptr);
CHECK_NE(dst, nullptr);
for (size_t i = 0; i < src->count; i++) { for (size_t i = 0; i < src->count; i++) {
size_t slice_length = GRPC_SLICE_LENGTH(src->slices[i]); size_t slice_length = GRPC_SLICE_LENGTH(src->slices[i]);
memcpy(dst, GRPC_SLICE_START_PTR(src->slices[i]), slice_length); memcpy(dst, GRPC_SLICE_START_PTR(src->slices[i]), slice_length);

@ -23,6 +23,8 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -84,7 +86,7 @@ static bool read_frame_size(const grpc_slice_buffer* sb,
remaining -= slice_length; remaining -= slice_length;
} }
} }
GPR_ASSERT(remaining == 0); CHECK_EQ(remaining, 0u);
// Gets little-endian frame size. // Gets little-endian frame size.
uint32_t frame_size = (static_cast<uint32_t>(frame_size_buffer[3]) << 24) | uint32_t frame_size = (static_cast<uint32_t>(frame_size_buffer[3]) << 24) |
(static_cast<uint32_t>(frame_size_buffer[2]) << 16) | (static_cast<uint32_t>(frame_size_buffer[2]) << 16) |
@ -294,7 +296,7 @@ tsi_result alts_zero_copy_grpc_protector_create(
impl->max_unprotected_data_size = impl->max_unprotected_data_size =
alts_grpc_record_protocol_max_unprotected_data_size( alts_grpc_record_protocol_max_unprotected_data_size(
impl->record_protocol, max_protected_frame_size_to_set); impl->record_protocol, max_protected_frame_size_to_set);
GPR_ASSERT(impl->max_unprotected_data_size > 0); CHECK_GT(impl->max_unprotected_data_size, 0u);
// Allocates internal slice buffers. // Allocates internal slice buffers.
grpc_slice_buffer_init(&impl->unprotected_staging_sb); grpc_slice_buffer_init(&impl->unprotected_staging_sb);
grpc_slice_buffer_init(&impl->protected_sb); grpc_slice_buffer_init(&impl->protected_sb);

@ -21,6 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -124,7 +126,8 @@ static void store32_little_endian(uint32_t value, unsigned char* buf) {
} }
static uint32_t read_frame_size(const grpc_slice_buffer* sb) { static uint32_t read_frame_size(const grpc_slice_buffer* sb) {
GPR_ASSERT(sb != nullptr && sb->length >= TSI_FAKE_FRAME_HEADER_SIZE); CHECK(sb != nullptr);
CHECK(sb->length >= TSI_FAKE_FRAME_HEADER_SIZE);
uint8_t frame_size_buffer[TSI_FAKE_FRAME_HEADER_SIZE]; uint8_t frame_size_buffer[TSI_FAKE_FRAME_HEADER_SIZE];
uint8_t* buf = frame_size_buffer; uint8_t* buf = frame_size_buffer;
// Copies the first 4 bytes to a temporary buffer. // Copies the first 4 bytes to a temporary buffer.
@ -141,7 +144,7 @@ static uint32_t read_frame_size(const grpc_slice_buffer* sb) {
remaining -= slice_length; remaining -= slice_length;
} }
} }
GPR_ASSERT(remaining == 0); CHECK_EQ(remaining, 0u);
return load32_little_endian(frame_size_buffer); return load32_little_endian(frame_size_buffer);
} }

@ -16,6 +16,8 @@
#include <map> #include <map>
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -47,8 +49,8 @@ TlsSessionKeyLoggerCache::TlsSessionKeyLogger::TlsSessionKeyLogger(
grpc_core::RefCountedPtr<TlsSessionKeyLoggerCache> cache) grpc_core::RefCountedPtr<TlsSessionKeyLoggerCache> cache)
: tls_session_key_log_file_path_(std::move(tls_session_key_log_file_path)), : tls_session_key_log_file_path_(std::move(tls_session_key_log_file_path)),
cache_(std::move(cache)) { cache_(std::move(cache)) {
GPR_ASSERT(!tls_session_key_log_file_path_.empty()); CHECK(!tls_session_key_log_file_path_.empty());
GPR_ASSERT(cache_ != nullptr); CHECK(cache_ != nullptr);
fd_ = fopen(tls_session_key_log_file_path_.c_str(), "a"); fd_ = fopen(tls_session_key_log_file_path_.c_str(), "a");
if (fd_ == nullptr) { if (fd_ == nullptr) {
grpc_error_handle error = GRPC_OS_ERROR(errno, "fopen"); grpc_error_handle error = GRPC_OS_ERROR(errno, "fopen");
@ -109,7 +111,7 @@ TlsSessionKeyLoggerCache::~TlsSessionKeyLoggerCache() {
grpc_core::RefCountedPtr<TlsSessionKeyLogger> TlsSessionKeyLoggerCache::Get( grpc_core::RefCountedPtr<TlsSessionKeyLogger> TlsSessionKeyLoggerCache::Get(
std::string tls_session_key_log_file_path) { std::string tls_session_key_log_file_path) {
gpr_once_init(&g_cache_mutex_init, do_cache_mutex_init); gpr_once_init(&g_cache_mutex_init, do_cache_mutex_init);
GPR_DEBUG_ASSERT(g_tls_session_key_log_cache_mu != nullptr); DCHECK_NE(g_tls_session_key_log_cache_mu, nullptr);
if (tls_session_key_log_file_path.empty()) { if (tls_session_key_log_file_path.empty()) {
return nullptr; return nullptr;
} }

@ -18,6 +18,8 @@
#include "src/core/tsi/ssl/session_cache/ssl_session_cache.h" #include "src/core/tsi/ssl/session_cache/ssl_session_cache.h"
#include "absl/log/check.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -112,7 +114,7 @@ void SslSessionLRUCache::Put(const char* key, SslSessionPtr session) {
entry_by_key_.emplace(key, node); entry_by_key_.emplace(key, node);
AssertInvariants(); AssertInvariants();
if (use_order_list_size_ > capacity_) { if (use_order_list_size_ > capacity_) {
GPR_ASSERT(use_order_list_tail_); CHECK(use_order_list_tail_);
node = use_order_list_tail_; node = use_order_list_tail_;
Remove(node); Remove(node);
// Order matters, key is destroyed after deleting node. // Order matters, key is destroyed after deleting node.
@ -143,7 +145,7 @@ void SslSessionLRUCache::Remove(SslSessionLRUCache::Node* node) {
} else { } else {
node->next_->prev_ = node->prev_; node->next_->prev_ = node->prev_;
} }
GPR_ASSERT(use_order_list_size_ >= 1); CHECK_GE(use_order_list_size_, 1u);
use_order_list_size_--; use_order_list_size_--;
} }
@ -169,16 +171,16 @@ void SslSessionLRUCache::AssertInvariants() {
Node* current = use_order_list_head_; Node* current = use_order_list_head_;
while (current != nullptr) { while (current != nullptr) {
size++; size++;
GPR_ASSERT(current->prev_ == prev); CHECK(current->prev_ == prev);
auto it = entry_by_key_.find(current->key()); auto it = entry_by_key_.find(current->key());
GPR_ASSERT(it != entry_by_key_.end()); CHECK(it != entry_by_key_.end());
GPR_ASSERT(it->second == current); CHECK(it->second == current);
prev = current; prev = current;
current = current->next_; current = current->next_;
} }
GPR_ASSERT(prev == use_order_list_tail_); CHECK(prev == use_order_list_tail_);
GPR_ASSERT(size == use_order_list_size_); CHECK(size == use_order_list_size_);
GPR_ASSERT(entry_by_key_.size() == use_order_list_size_); CHECK(entry_by_key_.size() == use_order_list_size_);
} }
#else #else
void SslSessionLRUCache::AssertInvariants() {} void SslSessionLRUCache::AssertInvariants() {}

@ -15,8 +15,8 @@
// limitations under the License. // limitations under the License.
// //
// //
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
@ -43,11 +43,11 @@ class OpenSslCachedSession : public SslCachedSession {
public: public:
OpenSslCachedSession(SslSessionPtr session) { OpenSslCachedSession(SslSessionPtr session) {
int size = i2d_SSL_SESSION(session.get(), nullptr); int size = i2d_SSL_SESSION(session.get(), nullptr);
GPR_ASSERT(size > 0); CHECK_GT(size, 0);
grpc_slice slice = grpc_slice_malloc(size_t(size)); grpc_slice slice = grpc_slice_malloc(size_t(size));
unsigned char* start = GRPC_SLICE_START_PTR(slice); unsigned char* start = GRPC_SLICE_START_PTR(slice);
int second_size = i2d_SSL_SESSION(session.get(), &start); int second_size = i2d_SSL_SESSION(session.get(), &start);
GPR_ASSERT(size == second_size); CHECK(size == second_size);
serialized_session_ = slice; serialized_session_ = slice;
} }

@ -45,6 +45,7 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "absl/log/check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -194,7 +195,7 @@ static void init_openssl(void) {
#if OPENSSL_VERSION_NUMBER < 0x10100000 #if OPENSSL_VERSION_NUMBER < 0x10100000
if (!CRYPTO_get_locking_callback()) { if (!CRYPTO_get_locking_callback()) {
int num_locks = CRYPTO_num_locks(); int num_locks = CRYPTO_num_locks();
GPR_ASSERT(num_locks > 0); CHECK_GT(num_locks, 0);
g_openssl_mutexes = static_cast<gpr_mu*>( g_openssl_mutexes = static_cast<gpr_mu*>(
gpr_malloc(static_cast<size_t>(num_locks) * sizeof(gpr_mu))); gpr_malloc(static_cast<size_t>(num_locks) * sizeof(gpr_mu)));
for (int i = 0; i < num_locks; i++) { for (int i = 0; i < num_locks; i++) {
@ -208,15 +209,15 @@ static void init_openssl(void) {
#endif #endif
g_ssl_ctx_ex_factory_index = g_ssl_ctx_ex_factory_index =
SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
GPR_ASSERT(g_ssl_ctx_ex_factory_index != -1); CHECK_NE(g_ssl_ctx_ex_factory_index, -1);
g_ssl_ctx_ex_crl_provider_index = g_ssl_ctx_ex_crl_provider_index =
SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
GPR_ASSERT(g_ssl_ctx_ex_crl_provider_index != -1); CHECK_NE(g_ssl_ctx_ex_crl_provider_index, -1);
g_ssl_ex_verified_root_cert_index = SSL_get_ex_new_index( g_ssl_ex_verified_root_cert_index = SSL_get_ex_new_index(
0, nullptr, nullptr, nullptr, verified_root_cert_free); 0, nullptr, nullptr, nullptr, verified_root_cert_free);
GPR_ASSERT(g_ssl_ex_verified_root_cert_index != -1); CHECK_NE(g_ssl_ex_verified_root_cert_index, -1);
} }
// --- Ssl utils. --- // --- Ssl utils. ---
@ -475,7 +476,7 @@ static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
: 0; : 0;
size_t property_count; size_t property_count;
tsi_result result; tsi_result result;
GPR_ASSERT(subject_alt_name_count >= 0); CHECK_GE(subject_alt_name_count, 0);
property_count = (include_certificate_type ? size_t{1} : 0) + property_count = (include_certificate_type ? size_t{1} : 0) +
3 /* subject, common name, certificate */ + 3 /* subject, common name, certificate */ +
static_cast<size_t>(subject_alt_name_count); static_cast<size_t>(subject_alt_name_count);
@ -530,7 +531,7 @@ static tsi_result peer_from_x509(X509* cert, int include_certificate_type,
} }
if (result != TSI_OK) tsi_peer_destruct(peer); if (result != TSI_OK) tsi_peer_destruct(peer);
GPR_ASSERT((int)peer->property_count == current_insert_index); CHECK((int)peer->property_count == current_insert_index);
return result; return result;
} }
@ -541,7 +542,7 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
X509* certificate = nullptr; X509* certificate = nullptr;
BIO* pem; BIO* pem;
GPR_ASSERT(pem_cert_chain_size <= INT_MAX); CHECK_LE(pem_cert_chain_size, static_cast<size_t>(INT_MAX));
pem = BIO_new_mem_buf(pem_cert_chain, static_cast<int>(pem_cert_chain_size)); pem = BIO_new_mem_buf(pem_cert_chain, static_cast<int>(pem_cert_chain_size));
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
@ -661,7 +662,7 @@ static tsi_result ssl_ctx_use_pem_private_key(SSL_CTX* context,
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
EVP_PKEY* private_key = nullptr; EVP_PKEY* private_key = nullptr;
BIO* pem; BIO* pem;
GPR_ASSERT(pem_key_size <= INT_MAX); CHECK_LE(pem_key_size, static_cast<size_t>(INT_MAX));
pem = BIO_new_mem_buf(pem_key, static_cast<int>(pem_key_size)); pem = BIO_new_mem_buf(pem_key, static_cast<int>(pem_key_size));
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
do { do {
@ -706,7 +707,7 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store,
X509* root = nullptr; X509* root = nullptr;
X509_NAME* root_name = nullptr; X509_NAME* root_name = nullptr;
BIO* pem; BIO* pem;
GPR_ASSERT(pem_roots_size <= INT_MAX); CHECK_LE(pem_roots_size, static_cast<size_t>(INT_MAX));
pem = BIO_new_mem_buf(pem_roots, static_cast<int>(pem_roots_size)); pem = BIO_new_mem_buf(pem_roots, static_cast<int>(pem_roots_size));
if (cert_store == nullptr) return TSI_INVALID_ARGUMENT; if (cert_store == nullptr) return TSI_INVALID_ARGUMENT;
if (pem == nullptr) return TSI_OUT_OF_RESOURCES; if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
@ -1372,7 +1373,7 @@ static tsi_ssl_handshaker_factory_vtable handshaker_factory_vtable = {nullptr};
// allocating memory for the factory. // allocating memory for the factory.
static void tsi_ssl_handshaker_factory_init( static void tsi_ssl_handshaker_factory_init(
tsi_ssl_handshaker_factory* factory) { tsi_ssl_handshaker_factory* factory) {
GPR_ASSERT(factory != nullptr); CHECK_NE(factory, nullptr);
factory->vtable = &handshaker_factory_vtable; factory->vtable = &handshaker_factory_vtable;
gpr_ref_init(&factory->refcount, 1); gpr_ref_init(&factory->refcount, 1);
@ -1600,7 +1601,7 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(
if (error != nullptr) *error = "invalid argument"; if (error != nullptr) *error = "invalid argument";
return TSI_INVALID_ARGUMENT; return TSI_INVALID_ARGUMENT;
} }
GPR_ASSERT(*bytes_size <= INT_MAX); CHECK_LE(*bytes_size, static_cast<size_t>(INT_MAX));
bytes_read_from_ssl = bytes_read_from_ssl =
BIO_read(impl->network_io, bytes, static_cast<int>(*bytes_size)); BIO_read(impl->network_io, bytes, static_cast<int>(*bytes_size));
if (bytes_read_from_ssl < 0) { if (bytes_read_from_ssl < 0) {
@ -1671,7 +1672,7 @@ static tsi_result ssl_handshaker_process_bytes_from_peer(
if (error != nullptr) *error = "invalid argument"; if (error != nullptr) *error = "invalid argument";
return TSI_INVALID_ARGUMENT; return TSI_INVALID_ARGUMENT;
} }
GPR_ASSERT(*bytes_size <= INT_MAX); CHECK_LE(*bytes_size, static_cast<size_t>(INT_MAX));
bytes_written_into_ssl_size = bytes_written_into_ssl_size =
BIO_write(impl->network_io, bytes, static_cast<int>(*bytes_size)); BIO_write(impl->network_io, bytes, static_cast<int>(*bytes_size));
if (bytes_written_into_ssl_size < 0) { if (bytes_written_into_ssl_size < 0) {
@ -2135,7 +2136,7 @@ static int server_handshaker_factory_npn_advertised_callback(
tsi_ssl_server_handshaker_factory* factory = tsi_ssl_server_handshaker_factory* factory =
static_cast<tsi_ssl_server_handshaker_factory*>(arg); static_cast<tsi_ssl_server_handshaker_factory*>(arg);
*out = factory->alpn_protocol_list; *out = factory->alpn_protocol_list;
GPR_ASSERT(factory->alpn_protocol_list_length <= UINT_MAX); CHECK(factory->alpn_protocol_list_length <= UINT_MAX);
*outlen = static_cast<unsigned int>(factory->alpn_protocol_list_length); *outlen = static_cast<unsigned int>(factory->alpn_protocol_list_length);
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
@ -2169,7 +2170,7 @@ static int server_handshaker_factory_new_session_callback(
template <typename T> template <typename T>
static void ssl_keylogging_callback(const SSL* ssl, const char* info) { static void ssl_keylogging_callback(const SSL* ssl, const char* info) {
SSL_CTX* ssl_context = SSL_get_SSL_CTX(ssl); SSL_CTX* ssl_context = SSL_get_SSL_CTX(ssl);
GPR_ASSERT(ssl_context != nullptr); CHECK_NE(ssl_context, nullptr);
void* arg = SSL_CTX_get_ex_data(ssl_context, g_ssl_ctx_ex_factory_index); void* arg = SSL_CTX_get_ex_data(ssl_context, g_ssl_ctx_ex_factory_index);
T* factory = static_cast<T*>(arg); T* factory = static_cast<T*>(arg);
factory->key_logger->LogSessionKeys(ssl_context, info); factory->key_logger->LogSessionKeys(ssl_context, info);
@ -2303,7 +2304,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options(
break; break;
} }
#if TSI_OPENSSL_ALPN_SUPPORT #if TSI_OPENSSL_ALPN_SUPPORT
GPR_ASSERT(impl->alpn_protocol_list_length < UINT_MAX); CHECK(impl->alpn_protocol_list_length < UINT_MAX);
if (SSL_CTX_set_alpn_protos( if (SSL_CTX_set_alpn_protos(
ssl_context, impl->alpn_protocol_list, ssl_context, impl->alpn_protocol_list,
static_cast<unsigned int>(impl->alpn_protocol_list_length))) { static_cast<unsigned int>(impl->alpn_protocol_list_length))) {
@ -2631,8 +2632,8 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, absl::string_view name) {
const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable( const tsi_ssl_handshaker_factory_vtable* tsi_ssl_handshaker_factory_swap_vtable(
tsi_ssl_handshaker_factory* factory, tsi_ssl_handshaker_factory* factory,
tsi_ssl_handshaker_factory_vtable* new_vtable) { tsi_ssl_handshaker_factory_vtable* new_vtable) {
GPR_ASSERT(factory != nullptr); CHECK_NE(factory, nullptr);
GPR_ASSERT(factory->vtable != nullptr); CHECK_NE(factory->vtable, nullptr);
const tsi_ssl_handshaker_factory_vtable* orig_vtable = factory->vtable; const tsi_ssl_handshaker_factory_vtable* orig_vtable = factory->vtable;
factory->vtable = new_vtable; factory->vtable = new_vtable;

@ -23,6 +23,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "absl/log/check.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -68,7 +69,7 @@ void LogSslErrorStack(void) {
tsi_result DoSslWrite(SSL* ssl, unsigned char* unprotected_bytes, tsi_result DoSslWrite(SSL* ssl, unsigned char* unprotected_bytes,
size_t unprotected_bytes_size) { size_t unprotected_bytes_size) {
GPR_ASSERT(unprotected_bytes_size <= INT_MAX); CHECK_LE(unprotected_bytes_size, static_cast<size_t>(INT_MAX));
ERR_clear_error(); ERR_clear_error();
int ssl_write_result = SSL_write(ssl, unprotected_bytes, int ssl_write_result = SSL_write(ssl, unprotected_bytes,
static_cast<int>(unprotected_bytes_size)); static_cast<int>(unprotected_bytes_size));
@ -89,7 +90,7 @@ tsi_result DoSslWrite(SSL* ssl, unsigned char* unprotected_bytes,
tsi_result DoSslRead(SSL* ssl, unsigned char* unprotected_bytes, tsi_result DoSslRead(SSL* ssl, unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size) { size_t* unprotected_bytes_size) {
GPR_ASSERT(*unprotected_bytes_size <= INT_MAX); CHECK_LE(*unprotected_bytes_size, static_cast<size_t>(INT_MAX));
ERR_clear_error(); ERR_clear_error();
int read_from_ssl = SSL_read(ssl, unprotected_bytes, int read_from_ssl = SSL_read(ssl, unprotected_bytes,
static_cast<int>(*unprotected_bytes_size)); static_cast<int>(*unprotected_bytes_size));
@ -134,7 +135,7 @@ tsi_result SslProtectorProtect(const unsigned char* unprotected_bytes,
int pending_in_ssl = static_cast<int>(BIO_pending(network_io)); int pending_in_ssl = static_cast<int>(BIO_pending(network_io));
if (pending_in_ssl > 0) { if (pending_in_ssl > 0) {
*unprotected_bytes_size = 0; *unprotected_bytes_size = 0;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX); CHECK_LE(*protected_output_frames_size, static_cast<size_t>(INT_MAX));
read_from_ssl = BIO_read(network_io, protected_output_frames, read_from_ssl = BIO_read(network_io, protected_output_frames,
static_cast<int>(*protected_output_frames_size)); static_cast<int>(*protected_output_frames_size));
if (read_from_ssl < 0) { if (read_from_ssl < 0) {
@ -161,7 +162,7 @@ tsi_result SslProtectorProtect(const unsigned char* unprotected_bytes,
result = DoSslWrite(ssl, buffer, buffer_size); result = DoSslWrite(ssl, buffer, buffer_size);
if (result != TSI_OK) return result; if (result != TSI_OK) return result;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX); CHECK_LE(*protected_output_frames_size, static_cast<size_t>(INT_MAX));
read_from_ssl = BIO_read(network_io, protected_output_frames, read_from_ssl = BIO_read(network_io, protected_output_frames,
static_cast<int>(*protected_output_frames_size)); static_cast<int>(*protected_output_frames_size));
if (read_from_ssl < 0) { if (read_from_ssl < 0) {
@ -191,11 +192,11 @@ tsi_result SslProtectorProtectFlush(size_t& buffer_offset,
} }
pending = static_cast<int>(BIO_pending(network_io)); pending = static_cast<int>(BIO_pending(network_io));
GPR_ASSERT(pending >= 0); CHECK_GE(pending, 0);
*still_pending_size = static_cast<size_t>(pending); *still_pending_size = static_cast<size_t>(pending);
if (*still_pending_size == 0) return TSI_OK; if (*still_pending_size == 0) return TSI_OK;
GPR_ASSERT(*protected_output_frames_size <= INT_MAX); CHECK_LE(*protected_output_frames_size, static_cast<size_t>(INT_MAX));
read_from_ssl = BIO_read(network_io, protected_output_frames, read_from_ssl = BIO_read(network_io, protected_output_frames,
static_cast<int>(*protected_output_frames_size)); static_cast<int>(*protected_output_frames_size));
if (read_from_ssl <= 0) { if (read_from_ssl <= 0) {
@ -204,7 +205,7 @@ tsi_result SslProtectorProtectFlush(size_t& buffer_offset,
} }
*protected_output_frames_size = static_cast<size_t>(read_from_ssl); *protected_output_frames_size = static_cast<size_t>(read_from_ssl);
pending = static_cast<int>(BIO_pending(network_io)); pending = static_cast<int>(BIO_pending(network_io));
GPR_ASSERT(pending >= 0); CHECK_GE(pending, 0);
*still_pending_size = static_cast<size_t>(pending); *still_pending_size = static_cast<size_t>(pending);
return TSI_OK; return TSI_OK;
} }
@ -232,7 +233,7 @@ tsi_result SslProtectorUnprotect(const unsigned char* protected_frames_bytes,
*unprotected_bytes_size = output_bytes_size - output_bytes_offset; *unprotected_bytes_size = output_bytes_size - output_bytes_offset;
// Then, try to write some data to ssl. // Then, try to write some data to ssl.
GPR_ASSERT(*protected_frames_bytes_size <= INT_MAX); CHECK_LE(*protected_frames_bytes_size, static_cast<size_t>(INT_MAX));
written_into_ssl = BIO_write(network_io, protected_frames_bytes, written_into_ssl = BIO_write(network_io, protected_frames_bytes,
static_cast<int>(*protected_frames_bytes_size)); static_cast<int>(*protected_frames_bytes_size));
if (written_into_ssl < 0) { if (written_into_ssl < 0) {

@ -31,7 +31,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h> #include <grpc/impl/compression_types.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/workaround_list.h> #include <grpc/support/workaround_list.h>
#include <grpcpp/completion_queue.h> #include <grpcpp/completion_queue.h>
@ -48,38 +47,11 @@
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/server_interceptor.h> #include <grpcpp/support/server_interceptor.h>
#include "src/core/ext/transport/chttp2/server/chttp2_server.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h" #include "src/core/lib/gpr/useful.h"
#include "src/core/server/server.h"
#include "src/cpp/server/external_connection_acceptor_impl.h" #include "src/cpp/server/external_connection_acceptor_impl.h"
namespace grpc { namespace grpc {
namespace {
// A PIMPL wrapper class that owns the only ref to the passive listener
// implementation. This is returned to the application.
class PassiveListenerOwner final
: public grpc_core::experimental::PassiveListener {
public:
explicit PassiveListenerOwner(std::shared_ptr<PassiveListener> listener)
: listener_(std::move(listener)) {}
absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) override {
return listener_->AcceptConnectedEndpoint(std::move(endpoint));
}
absl::Status AcceptConnectedFd(int fd) override {
return listener_->AcceptConnectedFd(fd);
}
private:
std::shared_ptr<PassiveListener> listener_;
};
} // namespace
static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>* static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>*
g_plugin_factory_list; g_plugin_factory_list;
@ -253,18 +225,6 @@ ServerBuilder& ServerBuilder::SetResourceQuota(
return *this; return *this;
} }
ServerBuilder& ServerBuilder::experimental_type::AddPassiveListener(
std::shared_ptr<grpc::ServerCredentials> creds,
std::unique_ptr<experimental::PassiveListener>& passive_listener) {
auto core_passive_listener =
std::make_shared<grpc_core::experimental::PassiveListenerImpl>();
builder_->unstarted_passive_listeners_.emplace_back(core_passive_listener,
std::move(creds));
passive_listener =
std::make_unique<PassiveListenerOwner>(std::move(core_passive_listener));
return *builder_;
}
ServerBuilder& ServerBuilder::AddListeningPort( ServerBuilder& ServerBuilder::AddListeningPort(
const std::string& addr_uri, std::shared_ptr<ServerCredentials> creds, const std::string& addr_uri, std::shared_ptr<ServerCredentials> creds,
int* selected_port) { int* selected_port) {
@ -438,26 +398,6 @@ std::unique_ptr<grpc::Server> ServerBuilder::BuildAndStart() {
cq->RegisterServer(server.get()); cq->RegisterServer(server.get());
} }
for (auto& unstarted_listener : unstarted_passive_listeners_) {
has_frequently_polled_cqs = true;
auto passive_listener = unstarted_listener.passive_listener.lock();
auto* core_server = grpc_core::Server::FromC(server->c_server());
if (passive_listener != nullptr) {
auto* creds = unstarted_listener.credentials->c_creds();
if (creds == nullptr) {
gpr_log(GPR_ERROR, "Credentials missing for PassiveListener");
return nullptr;
}
auto success = grpc_server_add_passive_listener(
core_server, creds, std::move(passive_listener));
if (!success.ok()) {
gpr_log(GPR_ERROR, "Failed to create a passive listener: %s",
success.ToString().c_str());
return nullptr;
}
}
}
if (!has_frequently_polled_cqs) { if (!has_frequently_polled_cqs) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"At least one of the completion queues must be frequently polled"); "At least one of the completion queues must be frequently polled");

@ -19,7 +19,6 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <string> #include <string>
#include <thread>
#include <tuple> #include <tuple>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -160,70 +159,6 @@ class NotifyOnDelete {
grpc_core::Notification* signal_; grpc_core::Notification* signal_;
}; };
// An endpoint implementation that supports Read and Write via std::threads.
// Passing a grpc_core::Notification will allow owners to know when all
// in-flight callbacks have been run, and all endpoint state has been destroyed.
class ThreadedNoopEndpoint : public EventEngine::Endpoint {
public:
explicit ThreadedNoopEndpoint(grpc_core::Notification* destroyed)
: state_(std::make_shared<EndpointState>(destroyed)) {}
~ThreadedNoopEndpoint() override {
std::thread deleter([state = state_]() {
CleanupThread(state->read);
CleanupThread(state->write);
});
deleter.detach();
}
bool Read(absl::AnyInvocable<void(absl::Status)> on_read, SliceBuffer* buffer,
const ReadArgs* /* args */) override {
buffer->Clear();
CleanupThread(state_->read);
state_->read = new std::thread([cb = std::move(on_read)]() mutable {
cb(absl::UnknownError("test"));
});
return false;
}
bool Write(absl::AnyInvocable<void(absl::Status)> on_writable,
SliceBuffer* data, const WriteArgs* /* args */) override {
data->Clear();
CleanupThread(state_->write);
state_->write = new std::thread([cb = std::move(on_writable)]() mutable {
cb(absl::UnknownError("test"));
});
return false;
}
const EventEngine::ResolvedAddress& GetPeerAddress() const override {
return peer_;
}
const EventEngine::ResolvedAddress& GetLocalAddress() const override {
return local_;
}
private:
struct EndpointState {
explicit EndpointState(grpc_core::Notification* deleter)
: delete_notifier_(deleter) {}
std::thread* read = nullptr;
std::thread* write = nullptr;
NotifyOnDelete delete_notifier_;
};
static void CleanupThread(std::thread* thd) {
if (thd != nullptr) {
thd->join();
delete thd;
}
}
std::shared_ptr<EndpointState> state_;
EventEngine::ResolvedAddress peer_;
EventEngine::ResolvedAddress local_;
};
} // namespace experimental } // namespace experimental
} // namespace grpc_event_engine } // namespace grpc_event_engine

@ -28,7 +28,6 @@ grpc_cc_test(
deps = [ deps = [
"//:grpc++_unsecure", "//:grpc++_unsecure",
"//src/proto/grpc/testing:echo_proto", "//src/proto/grpc/testing:echo_proto",
"//test/core/event_engine:event_engine_test_utils",
"//test/core/test_util:grpc_test_util_base", "//test/core/test_util:grpc_test_util_base",
"//test/core/test_util:grpc_test_util_unsecure", "//test/core/test_util:grpc_test_util_unsecure",
], ],

@ -16,19 +16,14 @@
// //
// //
#include <sys/socket.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <grpc/event_engine/slice_buffer.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpcpp/server.h> #include <grpcpp/server.h>
#include <grpcpp/server_builder.h> #include <grpcpp/server_builder.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
#include "src/core/lib/gprpp/notification.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/event_engine/event_engine_test_utils.h"
#include "test/core/test_util/port.h" #include "test/core/test_util/port.h"
#include "test/core/test_util/test_config.h" #include "test/core/test_util/test_config.h"
@ -88,56 +83,6 @@ TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) {
nullptr); nullptr);
} }
TEST_F(ServerBuilderTest, AddPassiveListener) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
auto server =
ServerBuilder()
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
server->Shutdown();
}
TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedFd) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
ServerBuilder builder;
auto cq = builder.AddCompletionQueue();
// TODO(hork): why is the service necessary? Queue isn't drained otherwise.
auto server =
builder.RegisterService(&g_service)
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
ASSERT_NE(server.get(), nullptr);
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
int fd = socket(AF_INET, SOCK_STREAM, 0);
auto accept_status = passive_listener->AcceptConnectedFd(fd);
ASSERT_TRUE(accept_status.ok()) << accept_status;
#else
int fd = -1;
auto accept_status = passive_listener->AcceptConnectedFd(fd);
ASSERT_FALSE(accept_status.ok()) << accept_status;
#endif
server->Shutdown();
}
TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
auto server =
ServerBuilder()
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
grpc_core::Notification endpoint_destroyed;
auto success = passive_listener->AcceptConnectedEndpoint(
std::make_unique<grpc_event_engine::experimental::ThreadedNoopEndpoint>(
&endpoint_destroyed));
ASSERT_TRUE(success.ok())
<< "AcceptConnectedEndpoint failure: " << success.ToString();
endpoint_destroyed.WaitForNotification();
server->Shutdown();
}
} // namespace } // namespace
} // namespace grpc } // namespace grpc

@ -45,6 +45,7 @@ grpc_cc_library(
hdrs = [ hdrs = [
"proto_reflection_descriptor_database.h", "proto_reflection_descriptor_database.h",
], ],
external_deps = ["absl/log:log"],
deps = [ deps = [
"//:grpc++", "//:grpc++",
"//:grpc++_config_proto", "//:grpc++_config_proto",
@ -78,6 +79,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/log:check", "absl/log:check",
"absl/log:log",
"protobuf", "protobuf",
], ],
deps = [ deps = [
@ -141,6 +143,7 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/log:check", "absl/log:check",
"absl/log:log",
"protobuf", "protobuf",
"protobuf_clib", "protobuf_clib",
], ],
@ -175,6 +178,7 @@ grpc_cc_library(
hdrs = [ hdrs = [
"metrics_server.h", "metrics_server.h",
], ],
external_deps = ["absl/log:log"],
deps = [ deps = [
"//:grpc++", "//:grpc++",
"//src/proto/grpc/testing:metrics_proto", "//src/proto/grpc/testing:metrics_proto",
@ -338,6 +342,7 @@ grpc_cc_binary(
external_deps = [ external_deps = [
"absl/flags:flag", "absl/flags:flag",
"absl/log:check", "absl/log:check",
"absl/log:log",
"absl/strings", "absl/strings",
], ],
language = "c++", language = "c++",
@ -364,6 +369,7 @@ grpc_cc_test(
], ],
external_deps = [ external_deps = [
"absl/log:check", "absl/log:check",
"absl/log:log",
"gtest", "gtest",
], ],
flaky = True, flaky = True,

@ -28,6 +28,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "google/protobuf/text_format.h" #include "google/protobuf/text_format.h"
@ -133,8 +134,8 @@ class ChannelzSampler final {
Status status = channelz_stub_->GetChannel( Status status = channelz_stub_->GetChannel(
&get_channel_context, get_channel_request, &get_channel_response); &get_channel_context, get_channel_request, &get_channel_response);
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "GetChannelRPC failed: %s", LOG(ERROR) << "GetChannelRPC failed: "
get_channel_context.debug_error_string().c_str()); << get_channel_context.debug_error_string();
CHECK(0); CHECK(0);
} }
return get_channel_response.channel(); return get_channel_response.channel();
@ -152,8 +153,8 @@ class ChannelzSampler final {
get_subchannel_request, get_subchannel_request,
&get_subchannel_response); &get_subchannel_response);
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "GetSubchannelRPC failed: %s", LOG(ERROR) << "GetSubchannelRPC failed: "
get_subchannel_context.debug_error_string().c_str()); << get_subchannel_context.debug_error_string();
CHECK(0); CHECK(0);
} }
return get_subchannel_response.subchannel(); return get_subchannel_response.subchannel();
@ -170,8 +171,8 @@ class ChannelzSampler final {
Status status = channelz_stub_->GetSocket( Status status = channelz_stub_->GetSocket(
&get_socket_context, get_socket_request, &get_socket_response); &get_socket_context, get_socket_request, &get_socket_response);
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "GetSocketRPC failed: %s", LOG(ERROR) << "GetSocketRPC failed: "
get_socket_context.debug_error_string().c_str()); << get_socket_context.debug_error_string();
CHECK(0); CHECK(0);
} }
return get_socket_response.socket(); return get_socket_response.socket();
@ -297,10 +298,9 @@ class ChannelzSampler final {
grpc::testing::GetCredentialsProvider()->GetChannelCredentials( grpc::testing::GetCredentialsProvider()->GetChannelCredentials(
custom_credentials_type, &channel_args); custom_credentials_type, &channel_args);
if (!channel_creds) { if (!channel_creds) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Wrong user credential type: " << custom_credentials_type
"Wrong user credential type: %s. Allowed credential types: " << ". Allowed credential types: INSECURE_CREDENTIALS, ssl, "
"INSECURE_CREDENTIALS, ssl, alts, google_default_credentials.", "alts, google_default_credentials.";
custom_credentials_type.c_str());
CHECK(0); CHECK(0);
} }
std::shared_ptr<grpc::Channel> channel = std::shared_ptr<grpc::Channel> channel =
@ -324,15 +324,14 @@ class ChannelzSampler final {
&get_servers_context, get_servers_request, &get_servers_response); &get_servers_context, get_servers_request, &get_servers_response);
if (!status.ok()) { if (!status.ok()) {
if (status.error_code() == StatusCode::UNIMPLEMENTED) { if (status.error_code() == StatusCode::UNIMPLEMENTED) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Error status UNIMPLEMENTED. Please check and make "
"Error status UNIMPLEMENTED. Please check and make sure " "sure channelz has been registered on the server being "
"channelz has been registered on the server being queried."); "queried.";
} else { } else {
gpr_log(GPR_ERROR, LOG(ERROR) << "GetServers RPC with "
"GetServers RPC with GetServersRequest.server_start_id=%d, " "GetServersRequest.server_start_id="
"failed: %s", << server_start_id << ", failed: "
static_cast<int>(server_start_id), << get_servers_context.debug_error_string();
get_servers_context.debug_error_string().c_str());
} }
CHECK(0); CHECK(0);
} }
@ -384,11 +383,10 @@ class ChannelzSampler final {
&get_top_channels_context, get_top_channels_request, &get_top_channels_context, get_top_channels_request,
&get_top_channels_response); &get_top_channels_response);
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "GetTopChannels RPC with "
"GetTopChannels RPC with " "GetTopChannelsRequest.channel_start_id="
"GetTopChannelsRequest.channel_start_id=%d failed: %s", << channel_start_id << " failed: "
static_cast<int>(channel_start_id), << get_top_channels_context.debug_error_string();
get_top_channels_context.debug_error_string().c_str());
CHECK(0); CHECK(0);
} }
for (const auto& _topchannel : get_top_channels_response.channel()) { for (const auto& _topchannel : get_top_channels_response.channel()) {

@ -25,6 +25,7 @@
#include <thread> #include <thread>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -85,7 +86,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) {
std::unique_ptr<grpc::testing::TestService::Stub> stub = std::unique_ptr<grpc::testing::TestService::Stub> stub =
grpc::testing::TestService::NewStub( grpc::testing::TestService::NewStub(
grpc::CreateChannel(server_address, channel_creds)); grpc::CreateChannel(server_address, channel_creds));
gpr_log(GPR_INFO, "Client %s is echoing!", client_id.c_str()); LOG(INFO) << "Client " << client_id << " is echoing!";
while (true) { while (true) {
if (gpr_event_wait(done_ev, grpc_timeout_seconds_to_deadline(1)) != if (gpr_event_wait(done_ev, grpc_timeout_seconds_to_deadline(1)) !=
nullptr) { nullptr) {
@ -96,7 +97,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) {
ClientContext context; ClientContext context;
Status status = stub->EmptyCall(&context, request, &response); Status status = stub->EmptyCall(&context, request, &response);
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "Client echo failed."); LOG(ERROR) << "Client echo failed.";
CHECK(0); CHECK(0);
} }
} }
@ -125,7 +126,7 @@ TEST(ChannelzSamplerTest, SimpleTest) {
builder.AddListeningPort(server_address, server_creds); builder.AddListeningPort(server_address, server_creds);
builder.RegisterService(&service); builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart()); std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.c_str()); LOG(INFO) << "Server listening on " << server_address;
const int kWaitForServerSeconds = 10; const int kWaitForServerSeconds = 10;
ASSERT_TRUE(WaitForConnection(kWaitForServerSeconds)); ASSERT_TRUE(WaitForConnection(kWaitForServerSeconds));
// client threads // client threads
@ -144,19 +145,17 @@ TEST(ChannelzSamplerTest, SimpleTest) {
int status = test_driver->Join(); int status = test_driver->Join();
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
if (WEXITSTATUS(status)) { if (WEXITSTATUS(status)) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Channelz sampler test test-runner exited with code "
"Channelz sampler test test-runner exited with code %d", << WEXITSTATUS(status);
WEXITSTATUS(status));
CHECK(0); // log the line number of the assertion failure CHECK(0); // log the line number of the assertion failure
} }
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
gpr_log(GPR_ERROR, "Channelz sampler test test-runner ended from signal %d", LOG(ERROR) << "Channelz sampler test test-runner ended from signal "
WTERMSIG(status)); << WTERMSIG(status);
CHECK(0); CHECK(0);
} else { } else {
gpr_log(GPR_ERROR, LOG(ERROR) << "Channelz sampler test test-runner ended with unknown status "
"Channelz sampler test test-runner ended with unknown status %d", << status;
status);
CHECK(0); CHECK(0);
} }
delete test_driver; delete test_driver;

@ -19,6 +19,7 @@
#include "test/cpp/util/cli_credentials.h" #include "test/cpp/util/cli_credentials.h"
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/log/log.h"
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -97,9 +98,9 @@ CliCredentials::GetChannelCredentials() const {
auto cert = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_cert), auto cert = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_cert),
/*add_null_terminator=*/false); /*add_null_terminator=*/false);
if (!cert.ok()) { if (!cert.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s", LOG(ERROR) << "error loading file "
absl::GetFlag(FLAGS_ssl_client_cert).c_str(), << absl::GetFlag(FLAGS_ssl_client_cert) << ": "
cert.status().ToString().c_str()); << cert.status();
} else { } else {
ssl_creds_options.pem_cert_chain = std::string(cert->as_string_view()); ssl_creds_options.pem_cert_chain = std::string(cert->as_string_view());
} }
@ -108,9 +109,9 @@ CliCredentials::GetChannelCredentials() const {
auto key = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_key), auto key = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_key),
/*add_null_terminator=*/false); /*add_null_terminator=*/false);
if (!key.ok()) { if (!key.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s", LOG(ERROR) << "error loading file "
absl::GetFlag(FLAGS_ssl_client_key).c_str(), << absl::GetFlag(FLAGS_ssl_client_key) << ": "
key.status().ToString().c_str()); << key.status();
} else { } else {
ssl_creds_options.pem_private_key = std::string(key->as_string_view()); ssl_creds_options.pem_private_key = std::string(key->as_string_view());
} }

@ -18,6 +18,8 @@
#include "test/cpp/util/metrics_server.h" #include "test/cpp/util/metrics_server.h"
#include "absl/log/log.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/server.h> #include <grpcpp/server.h>
#include <grpcpp/server_builder.h> #include <grpcpp/server_builder.h>
@ -54,7 +56,7 @@ long QpsGauge::Get() {
grpc::Status MetricsServiceImpl::GetAllGauges( grpc::Status MetricsServiceImpl::GetAllGauges(
ServerContext* /*context*/, const EmptyMessage* /*request*/, ServerContext* /*context*/, const EmptyMessage* /*request*/,
ServerWriter<GaugeResponse>* writer) { ServerWriter<GaugeResponse>* writer) {
gpr_log(GPR_DEBUG, "GetAllGauges called"); VLOG(2) << "GetAllGauges called";
std::lock_guard<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
for (auto it = qps_gauges_.begin(); it != qps_gauges_.end(); it++) { for (auto it = qps_gauges_.begin(); it != qps_gauges_.end(); it++) {
@ -99,7 +101,7 @@ std::shared_ptr<QpsGauge> MetricsServiceImpl::CreateQpsGauge(
// Starts the metrics server and returns the grpc::Server instance. Call Wait() // Starts the metrics server and returns the grpc::Server instance. Call Wait()
// on the returned server instance. // on the returned server instance.
std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) { std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
gpr_log(GPR_INFO, "Building metrics server.."); LOG(INFO) << "Building metrics server..";
const std::string address = "0.0.0.0:" + std::to_string(port); const std::string address = "0.0.0.0:" + std::to_string(port);
@ -108,8 +110,8 @@ std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
builder.RegisterService(this); builder.RegisterService(this);
std::unique_ptr<grpc::Server> server(builder.BuildAndStart()); std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Metrics server %s started. Ready to receive requests..", LOG(INFO) << "Metrics server " << address
address.c_str()); << " started. Ready to receive requests..";
return server; return server;
} }

@ -20,7 +20,7 @@
#include <vector> #include <vector>
#include <grpc/support/log.h> #include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
@ -86,23 +86,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
ServerReflectionResponse::MessageResponseCase::kErrorResponse) { ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response(); const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) { if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)", LOG(INFO) << "NOT_FOUND from server for FindFileByName(" << filename
filename.c_str()); << ")";
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "Error on FindFileByName(" << filename
"Error on FindFileByName(%s)\n\tError code: %d\n" << ")\n\tError code: " << error.error_code()
"\tError Message: %s", << "\n\tError Message: " << error.error_message();
filename.c_str(), error.error_code(),
error.error_message().c_str());
} }
} else { } else {
gpr_log( LOG(INFO) << "Error on FindFileByName(" << filename
GPR_INFO, << ") response type\n\tExpecting: "
"Error on FindFileByName(%s) response type\n" << ServerReflectionResponse::MessageResponseCase::
"\tExpecting: %d\n\tReceived: %d", kFileDescriptorResponse
filename.c_str(), << "\n\tReceived: " << response.message_response_case();
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
} }
return cached_db_.FindFileByName(filename, output); return cached_db_.FindFileByName(filename, output);
@ -134,24 +130,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
const ErrorResponse& error = response.error_response(); const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) { if (error.error_code() == StatusCode::NOT_FOUND) {
missing_symbols_.insert(symbol_name); missing_symbols_.insert(symbol_name);
gpr_log(GPR_INFO, LOG(INFO) << "NOT_FOUND from server for FindFileContainingSymbol("
"NOT_FOUND from server for FindFileContainingSymbol(%s)", << symbol_name << ")";
symbol_name.c_str());
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name
"Error on FindFileContainingSymbol(%s)\n" << ")\n\tError code: " << error.error_code()
"\tError code: %d\n\tError Message: %s", << "\n\tError Message: " << error.error_message();
symbol_name.c_str(), error.error_code(),
error.error_message().c_str());
} }
} else { } else {
gpr_log( LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name
GPR_INFO, << ") response type\n\tExpecting: "
"Error on FindFileContainingSymbol(%s) response type\n" << ServerReflectionResponse::MessageResponseCase::
"\tExpecting: %d\n\tReceived: %d", kFileDescriptorResponse
symbol_name.c_str(), << "\n\tReceived: " << response.message_response_case();
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
} }
return cached_db_.FindFileContainingSymbol(symbol_name, output); return cached_db_.FindFileContainingSymbol(symbol_name, output);
} }
@ -167,7 +158,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
if (missing_extensions_.find(containing_type) != missing_extensions_.end() && if (missing_extensions_.find(containing_type) != missing_extensions_.end() &&
missing_extensions_[containing_type].find(field_number) != missing_extensions_[containing_type].find(field_number) !=
missing_extensions_[containing_type].end()) { missing_extensions_[containing_type].end()) {
gpr_log(GPR_INFO, "nested map."); LOG(INFO) << "nested map.";
return false; return false;
} }
@ -194,24 +185,20 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
missing_extensions_[containing_type] = {}; missing_extensions_[containing_type] = {};
} }
missing_extensions_[containing_type].insert(field_number); missing_extensions_[containing_type].insert(field_number);
gpr_log(GPR_INFO, LOG(INFO) << "NOT_FOUND from server for FindFileContainingExtension("
"NOT_FOUND from server for FindFileContainingExtension(%s, %d)", << containing_type << ", " << field_number << ")";
containing_type.c_str(), field_number);
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type
"Error on FindFileContainingExtension(%s, %d)\n" << ", " << field_number
"\tError code: %d\n\tError Message: %s", << ")\n\tError code: " << error.error_code()
containing_type.c_str(), field_number, error.error_code(), << "\n\tError Message: " << error.error_message();
error.error_message().c_str());
} }
} else { } else {
gpr_log( LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type
GPR_INFO, << ", " << field_number << ") response type\n\tExpecting: "
"Error on FindFileContainingExtension(%s, %d) response type\n" << ServerReflectionResponse::MessageResponseCase::
"\tExpecting: %d\n\tReceived: %d", kFileDescriptorResponse
containing_type.c_str(), field_number, << "\n\tReceived: " << response.message_response_case();
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
} }
return cached_db_.FindFileContainingExtension(containing_type, field_number, return cached_db_.FindFileContainingExtension(containing_type, field_number,
@ -245,14 +232,12 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
ServerReflectionResponse::MessageResponseCase::kErrorResponse) { ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response(); const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) { if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)", LOG(INFO) << "NOT_FOUND from server for FindAllExtensionNumbers("
extendee_type.c_str()); << extendee_type << ")";
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "Error on FindAllExtensionNumbersExtension(" << extendee_type
"Error on FindAllExtensionNumbersExtension(%s)\n" << ")\n\tError code: " << error.error_code()
"\tError code: %d\n\tError Message: %s", << "\n\tError Message: " << error.error_message();
extendee_type.c_str(), error.error_code(),
error.error_message().c_str());
} }
} }
return false; return false;
@ -278,16 +263,13 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
} else if (response.message_response_case() == } else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) { ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response(); const ErrorResponse& error = response.error_response();
gpr_log(GPR_INFO, LOG(INFO) << "Error on GetServices()\n\tError code: " << error.error_code()
"Error on GetServices()\n\tError code: %d\n" << "\n\tError Message: " << error.error_message();
"\tError Message: %s",
error.error_code(), error.error_message().c_str());
} else { } else {
gpr_log( LOG(INFO)
GPR_INFO, << "Error on GetServices() response type\n\tExpecting: "
"Error on GetServices() response type\n\tExpecting: %d\n\tReceived: %d", << ServerReflectionResponse::MessageResponseCase::kListServicesResponse
ServerReflectionResponse::MessageResponseCase::kListServicesResponse, << "\n\tReceived: " << response.message_response_case();
response.message_response_case());
} }
return false; return false;
} }

@ -27,6 +27,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
@ -104,7 +105,7 @@ class DefaultCredentialsProvider : public CredentialsProvider {
auto it(std::find(added_secure_type_names_.begin(), auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type)); added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) { if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); LOG(ERROR) << "Unsupported credentials type " << type;
return nullptr; return nullptr;
} }
return added_secure_type_providers_[it - added_secure_type_names_.begin()] return added_secure_type_providers_[it - added_secure_type_names_.begin()]
@ -137,7 +138,7 @@ class DefaultCredentialsProvider : public CredentialsProvider {
auto it(std::find(added_secure_type_names_.begin(), auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type)); added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) { if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); LOG(ERROR) << "Unsupported credentials type " << type;
return nullptr; return nullptr;
} }
return added_secure_type_providers_[it - added_secure_type_names_.begin()] return added_secure_type_providers_[it - added_secure_type_names_.begin()]

@ -77,10 +77,6 @@ IGNORED_FILES = [
"src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_env.h",
"src/core/lib/profiling/timers.h", "src/core/lib/profiling/timers.h",
"src/core/lib/gprpp/crash.h", "src/core/lib/gprpp/crash.h",
# The grpc_core::Server redundant namespace qualification is required for
# older gcc versions.
"src/core/ext/transport/chttp2/server/chttp2_server.h",
"src/core/server/server.h",
] ]
# find our home # find our home

@ -21,13 +21,6 @@ import os
import re import re
import sys import sys
IGNORED_FILES = [
# note: the grpc_core::Server redundant namespace qualification is required
# for older gcc versions.
"src/core/ext/transport/chttp2/server/chttp2_server.h",
"src/core/server/server.h",
]
def find_closing_mustache(contents, initial_depth): def find_closing_mustache(contents, initial_depth):
"""Find the closing mustache for a given number of open mustaches.""" """Find the closing mustache for a given number of open mustaches."""
@ -173,8 +166,6 @@ for config in _CONFIGURATION:
for file in files: for file in files:
if file.endswith(".cc") or file.endswith(".h"): if file.endswith(".cc") or file.endswith(".h"):
path = os.path.join(root, file) path = os.path.join(root, file)
if path in IGNORED_FILES:
continue
try: try:
with open(path) as f: with open(path) as f:
contents = f.read() contents = f.read()

@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \ include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \ include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \ include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \ include/grpc/slice.h \
include/grpc/slice_buffer.h \ include/grpc/slice_buffer.h \
include/grpc/status.h \ include/grpc/status.h \
@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \ include/grpcpp/impl/service_type.h \
include/grpcpp/impl/status.h \ include/grpcpp/impl/status.h \
include/grpcpp/impl/sync.h \ include/grpcpp/impl/sync.h \
include/grpcpp/passive_listener.h \
include/grpcpp/resource_quota.h \ include/grpcpp/resource_quota.h \
include/grpcpp/security/audit_logging.h \ include/grpcpp/security/audit_logging.h \
include/grpcpp/security/auth_context.h \ include/grpcpp/security/auth_context.h \

@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \ include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \ include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \ include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \ include/grpc/slice.h \
include/grpc/slice_buffer.h \ include/grpc/slice_buffer.h \
include/grpc/status.h \ include/grpc/status.h \
@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \ include/grpcpp/impl/service_type.h \
include/grpcpp/impl/status.h \ include/grpcpp/impl/status.h \
include/grpcpp/impl/sync.h \ include/grpcpp/impl/sync.h \
include/grpcpp/passive_listener.h \
include/grpcpp/resource_quota.h \ include/grpcpp/resource_quota.h \
include/grpcpp/security/audit_logging.h \ include/grpcpp/security/audit_logging.h \
include/grpcpp/security/auth_context.h \ include/grpcpp/security/auth_context.h \

@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \ include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \ include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \ include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \ include/grpc/slice.h \
include/grpc/slice_buffer.h \ include/grpc/slice_buffer.h \
include/grpc/status.h \ include/grpc/status.h \

@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \ include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \ include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \ include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \ include/grpc/slice.h \
include/grpc/slice_buffer.h \ include/grpc/slice_buffer.h \
include/grpc/status.h \ include/grpc/status.h \

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format) # Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository. # Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_xds_k8s_lb.sh" build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh"
timeout_mins: 240 timeout_mins: 240
action { action {
define_artifacts { define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts" strip_prefix: "artifacts"
} }
} }
env_vars {
key: "PSM_TEST_SUITE"
value: "lb"
}

@ -1,193 +0,0 @@
#!/usr/bin/env bash
# Copyright 2021 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building C++ xDS interop test app Docker images"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping C++ test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
${@:2} \
|& tee "${out_dir}/sponge_log.log"
}
run_alpha_test() {
local test_name=$1
run_test ${test_name} \
--compute_api_version="v1alpha"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test captured from the master branch.
echo "Sourcing test driver install captured from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_LB
activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
run_alpha_test subsetting_test || (( ++failed_tests ))
test_suites=(
"app_net_test"
"affinity_test"
"api_listener_test"
"change_backend_service_test"
"custom_lb_test"
"failover_test"
"outlier_detection_test"
"remove_neg_test"
"round_robin_test"
)
if [[ "${TESTING_VERSION}" =~ "master" ]]; then
test_suites+=('bootstrap_generator_test')
fi
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

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

Loading…
Cancel
Save