Merge master

pull/36398/head
tanvi-jagtap 7 months ago
commit 56cad2c009
  1. 24
      BUILD
  2. 23
      CMakeLists.txt
  3. 2
      Makefile
  4. 2
      Package.swift
  5. 1
      bazel/experiments.bzl
  6. 2
      bazel/grpc_build_system.bzl
  7. 24
      build_autogenerated.yaml
  8. 1
      examples/cpp/csm/BUILD
  9. 3
      examples/cpp/csm/csm_greeter_server.cc
  10. 1
      examples/cpp/helloworld/BUILD
  11. 1
      examples/cpp/helloworld/CMakeLists.txt
  12. 8
      examples/cpp/helloworld/xds_greeter_server.cc
  13. 2
      examples/cpp/keepalive/CMakeLists.txt
  14. 1
      examples/cpp/xds/BUILD
  15. 8
      examples/cpp/xds/xds_greeter_server.cc
  16. 1
      gRPC-C++.podspec
  17. 2
      gRPC-Core.podspec
  18. 130
      grpc.def
  19. 2
      grpc.gemspec
  20. 1222
      include/grpc/credentials.h
  21. 7
      include/grpc/grpc.h
  22. 1
      include/grpc/grpc_crl_provider.h
  23. 1171
      include/grpc/grpc_security.h
  24. 2
      include/grpc/module.modulemap
  25. 62
      include/grpc/passive_listener.h
  26. 2
      include/grpc/support/log.h
  27. 27
      include/grpcpp/passive_listener.h
  28. 1
      include/grpcpp/security/server_credentials.h
  29. 1
      include/grpcpp/security/tls_certificate_provider.h
  30. 29
      include/grpcpp/server_builder.h
  31. 2
      include/grpcpp/support/callback_common.h
  32. 2
      package.xml
  33. 1220
      src/compiler/cpp_generator.cc
  34. 4
      src/compiler/cpp_generator.h
  35. 20
      src/compiler/cpp_plugin.h
  36. 20
      src/core/BUILD
  37. 2
      src/core/client_channel/client_channel_filter.cc
  38. 7
      src/core/ext/filters/backend_metrics/backend_metric_filter.cc
  39. 4
      src/core/ext/filters/backend_metrics/backend_metric_filter.h
  40. 18
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc
  41. 21
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h
  42. 5
      src/core/ext/filters/deadline/deadline_filter.cc
  43. 13
      src/core/ext/filters/fault_injection/fault_injection_filter.cc
  44. 8
      src/core/ext/filters/fault_injection/fault_injection_filter.h
  45. 9
      src/core/ext/filters/http/client/http_client_filter.cc
  46. 10
      src/core/ext/filters/http/client/http_client_filter.h
  47. 7
      src/core/ext/filters/http/client_authority_filter.cc
  48. 9
      src/core/ext/filters/http/client_authority_filter.h
  49. 12
      src/core/ext/filters/http/message_compress/compression_filter.cc
  50. 16
      src/core/ext/filters/http/message_compress/compression_filter.h
  51. 4
      src/core/ext/filters/http/server/http_server_filter.cc
  52. 10
      src/core/ext/filters/http/server/http_server_filter.h
  53. 9
      src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
  54. 2
      src/core/ext/filters/load_reporting/server_load_reporting_filter.h
  55. 19
      src/core/ext/filters/logging/logging_filter.cc
  56. 11
      src/core/ext/filters/logging/logging_filter.h
  57. 16
      src/core/ext/filters/message_size/message_size_filter.cc
  58. 14
      src/core/ext/filters/message_size/message_size_filter.h
  59. 15
      src/core/ext/filters/rbac/rbac_filter.cc
  60. 10
      src/core/ext/filters/rbac/rbac_filter.h
  61. 63
      src/core/ext/filters/server_config_selector/server_config_selector_filter.cc
  62. 7
      src/core/ext/filters/stateful_session/stateful_session_filter.cc
  63. 5
      src/core/ext/filters/stateful_session/stateful_session_filter.h
  64. 1
      src/core/ext/gcp/metadata_query.cc
  65. 7
      src/core/ext/transport/binder/server/binder_server.cc
  66. 20
      src/core/ext/transport/chaotic_good/client_transport.cc
  67. 7
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc
  68. 4
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.h
  69. 54
      src/core/ext/transport/chaotic_good/server_transport.cc
  70. 287
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  71. 33
      src/core/ext/transport/chttp2/server/chttp2_server.h
  72. 8
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  73. 3
      src/core/ext/transport/chttp2/transport/frame_data.cc
  74. 10
      src/core/ext/transport/inproc/inproc_transport.cc
  75. 1
      src/core/ext/xds/xds_server_config_fetcher.cc
  76. 16
      src/core/lib/channel/channel_stack_builder_impl.cc
  77. 59
      src/core/lib/channel/connected_channel.cc
  78. 10
      src/core/lib/channel/promise_based_filter.cc
  79. 191
      src/core/lib/channel/promise_based_filter.h
  80. 11
      src/core/lib/channel/server_call_tracer_filter.cc
  81. 7
      src/core/lib/event_engine/extensions/supports_fd.h
  82. 18
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  83. 2
      src/core/lib/event_engine/posix_engine/posix_engine.h
  84. 42
      src/core/lib/experiments/experiments.cc
  85. 50
      src/core/lib/experiments/experiments.h
  86. 12
      src/core/lib/experiments/experiments.yaml
  87. 4
      src/core/lib/experiments/rollouts.yaml
  88. 1
      src/core/lib/http/httpcli_security_connector.cc
  89. 84
      src/core/lib/promise/for_each.h
  90. 2
      src/core/lib/promise/pipe.h
  91. 6
      src/core/lib/security/authorization/grpc_server_authz_filter.cc
  92. 12
      src/core/lib/security/authorization/grpc_server_authz_filter.h
  93. 1
      src/core/lib/security/certificate_provider/certificate_provider_factory.h
  94. 1
      src/core/lib/security/context/security_context.cc
  95. 1
      src/core/lib/security/context/security_context.h
  96. 1
      src/core/lib/security/credentials/alts/alts_credentials.h
  97. 1
      src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h
  98. 1
      src/core/lib/security/credentials/call_creds_util.h
  99. 1
      src/core/lib/security/credentials/channel_creds_registry_init.cc
  100. 1
      src/core/lib/security/credentials/composite/composite_credentials.h
  101. Some files were not shown because too many files have changed in this diff Show More

24
BUILD

@ -291,6 +291,7 @@ GRPC_PUBLIC_HDRS = [
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security.h",
"include/grpc/grpc_security_constants.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
@ -452,6 +453,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/service_type.h",
"include/grpcpp/impl/status.h",
"include/grpcpp/impl/sync.h",
"include/grpcpp/passive_listener.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/security/audit_logging.h",
"include/grpcpp/security/tls_crl_provider.h",
@ -876,7 +878,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_public_hdrs",
hdrs = GRPC_PUBLIC_HDRS,
hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS,
external_deps = [
"absl/status:statusor",
"absl/strings",
@ -1243,6 +1245,7 @@ grpc_cc_library(
"gpr",
"grpc++_base_unsecure",
"grpc++_codegen_proto",
"grpc_core_credentials_header",
"grpc_public_hdrs",
"grpc_security_base",
"grpc_unsecure",
@ -2267,6 +2270,7 @@ grpc_cc_library(
"exec_ctx",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_public_hdrs",
"grpc_trace",
"handshaker",
@ -2328,6 +2332,14 @@ grpc_cc_library(
],
)
# TODO(hork): split credentials types into their own source files and targets.
grpc_cc_library(
name = "grpc_core_credentials_header",
hdrs = ["include/grpc/credentials.h"],
language = "c++",
visibility = ["@grpc:core_credentials"],
)
grpc_cc_library(
name = "alts_util",
srcs = [
@ -2355,6 +2367,7 @@ grpc_cc_library(
deps = [
"alts_upb",
"gpr",
"grpc_core_credentials_header",
"grpc_public_hdrs",
],
)
@ -2428,6 +2441,7 @@ grpc_cc_library(
"grpc",
"grpc++_codegen_proto",
"grpc_base",
"grpc_core_credentials_header",
"grpc_credentials_util",
"grpc_health_upb",
"grpc_public_hdrs",
@ -2458,6 +2472,7 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider",
"//src/core:grpc_crl_provider",
"//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc",
"//src/core:json",
"//src/core:json_reader",
@ -2509,11 +2524,13 @@ grpc_cc_library(
"exec_ctx",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_health_upb",
"grpc_public_hdrs",
"grpc_security_base",
"grpc_service_config_impl",
"grpc_trace",
"grpc_transport_chttp2",
"grpc_unsecure",
"grpcpp_backend_metric_recorder",
"grpcpp_call_metric_recorder",
@ -2535,6 +2552,7 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider",
"//src/core:grpc_insecure_credentials",
"//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc",
"//src/core:ref_counted",
"//src/core:resource_quota",
@ -3860,6 +3878,7 @@ grpc_cc_library(
"exec_ctx",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_public_hdrs",
"grpc_security_base",
"handshaker",
@ -3929,6 +3948,7 @@ grpc_cc_library(
"exec_ctx",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_credentials_util",
"grpc_security_base",
"grpc_trace",
@ -4017,6 +4037,7 @@ grpc_cc_library(
"exec_ctx",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_security_base",
"tsi_alts_frame_protector",
"tsi_base",
@ -4134,6 +4155,7 @@ grpc_cc_library(
"config_vars",
"gpr",
"grpc_base",
"grpc_core_credentials_header",
"grpc_credentials_util",
"grpc_public_hdrs",
"grpc_security_base",

@ -2694,6 +2694,7 @@ foreach(_hdr
include/grpc/byte_buffer_reader.h
include/grpc/census.h
include/grpc/compression.h
include/grpc/credentials.h
include/grpc/event_engine/endpoint_config.h
include/grpc/event_engine/event_engine.h
include/grpc/event_engine/extensible.h
@ -2741,6 +2742,7 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -3395,6 +3397,7 @@ foreach(_hdr
include/grpc/byte_buffer_reader.h
include/grpc/census.h
include/grpc/compression.h
include/grpc/credentials.h
include/grpc/event_engine/endpoint_config.h
include/grpc/event_engine/event_engine.h
include/grpc/event_engine/extensible.h
@ -3442,6 +3445,7 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -4311,6 +4315,7 @@ foreach(_hdr
include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h
@ -5051,6 +5056,7 @@ foreach(_hdr
include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h
@ -5452,6 +5458,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
include/grpc/credentials.h
include/grpc/event_engine/endpoint_config.h
include/grpc/event_engine/event_engine.h
include/grpc/event_engine/extensible.h
@ -5499,6 +5506,7 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -7760,6 +7768,7 @@ target_include_directories(bad_streaming_id_bad_client_test
target_link_libraries(bad_streaming_id_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -7804,6 +7813,7 @@ target_include_directories(badreq_bad_client_test
target_link_libraries(badreq_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -11391,6 +11401,7 @@ target_include_directories(connection_prefix_bad_client_test
target_link_libraries(connection_prefix_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -12448,6 +12459,7 @@ target_include_directories(duplicate_header_bad_client_test
target_link_libraries(duplicate_header_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -16516,6 +16528,7 @@ target_include_directories(head_of_line_blocking_bad_client_test
target_link_libraries(head_of_line_blocking_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -16560,6 +16573,7 @@ target_include_directories(headers_bad_client_test
target_link_libraries(headers_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -17557,6 +17571,7 @@ target_include_directories(initial_settings_frame_bad_client_test
target_link_libraries(initial_settings_frame_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -20785,6 +20800,7 @@ target_include_directories(out_of_bounds_bad_client_test
target_link_libraries(out_of_bounds_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -26659,6 +26675,7 @@ 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.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/util/cmdline.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc
@ -26703,6 +26720,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
target_link_libraries(server_builder_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc++_unsecure
grpc_test_util_unsecure
)
@ -27174,6 +27192,7 @@ target_include_directories(server_registered_method_bad_client_test
target_link_libraries(server_registered_method_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -27919,6 +27938,7 @@ target_include_directories(simple_request_bad_client_test
target_link_libraries(simple_request_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -29981,6 +30001,7 @@ target_include_directories(test_core_security_credentials_test
target_link_libraries(test_core_security_credentials_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -31823,6 +31844,7 @@ target_include_directories(unknown_frame_bad_client_test
target_link_libraries(unknown_frame_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)
@ -32297,6 +32319,7 @@ target_include_directories(window_overflow_bad_client_test
target_link_libraries(window_overflow_bad_client_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc_test_util
)

@ -1728,6 +1728,7 @@ PUBLIC_HEADERS_C += \
include/grpc/byte_buffer_reader.h \
include/grpc/census.h \
include/grpc/compression.h \
include/grpc/credentials.h \
include/grpc/event_engine/endpoint_config.h \
include/grpc/event_engine/event_engine.h \
include/grpc/event_engine/extensible.h \
@ -1775,6 +1776,7 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \

@ -45,6 +45,7 @@ let package = Package(
"include/grpc/byte_buffer_reader.h",
"include/grpc/census.h",
"include/grpc/compression.h",
"include/grpc/credentials.h",
"include/grpc/event_engine/endpoint_config.h",
"include/grpc/event_engine/event_engine.h",
"include/grpc/event_engine/extensible.h",
@ -92,6 +93,7 @@ let package = Package(
"include/grpc/impl/propagation_bits.h",
"include/grpc/impl/slice_type.h",
"include/grpc/load_reporting.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",

@ -25,6 +25,7 @@ EXPERIMENT_ENABLES = {
"event_engine_dns": "event_engine_dns",
"event_engine_listener": "event_engine_listener",
"free_large_allocator": "free_large_allocator",
"http2_stats_fix": "http2_stats_fix",
"keepalive_fix": "keepalive_fix",
"keepalive_server_fix": "keepalive_server_fix",
"monitoring_experiment": "monitoring_experiment",

@ -102,6 +102,7 @@ def _update_visibility(visibility):
"chaotic_good": PRIVATE,
"client_channel": PRIVATE,
"cli": PRIVATE,
"core_credentials": PRIVATE,
"debug_location": PRIVATE,
"endpoint_tests": PRIVATE,
"exec_ctx": PRIVATE,
@ -116,6 +117,7 @@ def _update_visibility(visibility):
"iomgr_internal_errqueue": PRIVATE,
"iomgr_buffer_list": PRIVATE,
"json_reader_legacy": PRIVATE,
"otel_plugin": PRIVATE,
"public": PUBLIC,
"ref_counted_ptr": PRIVATE,
"tcp_tracer": PRIVATE,

@ -149,6 +149,7 @@ libs:
- include/grpc/byte_buffer_reader.h
- include/grpc/census.h
- include/grpc/compression.h
- include/grpc/credentials.h
- include/grpc/event_engine/endpoint_config.h
- include/grpc/event_engine/event_engine.h
- include/grpc/event_engine/extensible.h
@ -196,6 +197,7 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -2136,6 +2138,7 @@ libs:
- include/grpc/byte_buffer_reader.h
- include/grpc/census.h
- include/grpc/compression.h
- include/grpc/credentials.h
- include/grpc/event_engine/endpoint_config.h
- include/grpc/event_engine/event_engine.h
- include/grpc/event_engine/extensible.h
@ -2183,6 +2186,7 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -3793,6 +3797,7 @@ libs:
- include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h
@ -4221,6 +4226,7 @@ libs:
- include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h
@ -4321,6 +4327,7 @@ libs:
- include/grpc/byte_buffer.h
- include/grpc/byte_buffer_reader.h
- include/grpc/compression.h
- include/grpc/credentials.h
- include/grpc/event_engine/endpoint_config.h
- include/grpc/event_engine/event_engine.h
- include/grpc/event_engine/extensible.h
@ -4368,6 +4375,7 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -5973,6 +5981,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: badreq_bad_client_test
gtest: true
@ -5987,6 +5996,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: basic_work_queue_test
gtest: true
@ -8270,6 +8280,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: connection_refused_test
gtest: true
@ -8723,6 +8734,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: empty_batch_test
gtest: true
@ -10999,6 +11011,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: headers_bad_client_test
gtest: true
@ -11013,6 +11026,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: health_service_end2end_test
gtest: true
@ -11517,6 +11531,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: inproc_test
gtest: true
@ -13363,6 +13378,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: outlier_detection_lb_config_parser_test
gtest: true
@ -17380,6 +17396,7 @@ targets:
build: test
language: c++
headers:
- test/core/event_engine/event_engine_test_utils.h
- test/core/util/cmdline.h
- test/core/util/evaluate_args_test_util.h
- test/core/util/fuzzer_util.h
@ -17396,6 +17413,7 @@ targets:
- src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/simple_messages.proto
- src/proto/grpc/testing/xds/v3/orca_load_report.proto
- test/core/event_engine/event_engine_test_utils.cc
- test/core/util/cmdline.cc
- test/core/util/fuzzer_util.cc
- test/core/util/grpc_profiler.cc
@ -17408,6 +17426,7 @@ targets:
- test/cpp/server/server_builder_test.cc
deps:
- gtest
- absl/log:check
- grpc++_unsecure
- grpc_test_util_unsecure
platforms:
@ -17605,6 +17624,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: server_request_call_test
gtest: true
@ -18079,6 +18099,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: simple_request_test
gtest: true
@ -19024,6 +19045,7 @@ targets:
- test/core/util/tracer_util.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: test_core_security_ssl_credentials_test
gtest: true
@ -19856,6 +19878,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: uri_parser_test
gtest: true
@ -20021,6 +20044,7 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- gtest
- absl/log:check
- grpc_test_util
- name: windows_endpoint_test
gtest: true

@ -41,6 +41,7 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@io_opentelemetry_cpp//exporters/prometheus:prometheus_exporter",
"@io_opentelemetry_cpp//sdk/src/metrics",
],

@ -22,6 +22,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "opentelemetry/exporters/prometheus/exporter_factory.h"
#include "opentelemetry/exporters/prometheus/exporter_options.h"
@ -91,7 +92,7 @@ void RunServer(const char* hostname) {
xds_builder.AddListeningPort(absl::StrCat("0.0.0.0:", port),
grpc::InsecureServerCredentials());
xds_enabled_server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port);
LOG(INFO) << "Server starting on 0.0.0.0:" << port;
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.

@ -129,5 +129,6 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
],
)

@ -68,6 +68,7 @@ foreach(_target
absl::check
absl::flags
absl::flags_parse
absl::log
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})

@ -22,6 +22,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include <grpcpp/ext/admin_services.h>
@ -79,21 +80,20 @@ void RunServer() {
absl::StrCat("0.0.0.0:", port),
grpc::XdsServerCredentials(grpc::InsecureServerCredentials()));
xds_enabled_server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port);
LOG(INFO) << "Server starting on 0.0.0.0:" << port;
grpc::AddAdminServices(&builder);
// For the maintenance server, do not use any authentication mechanism.
builder.AddListeningPort(absl::StrCat("0.0.0.0:", maintenance_port),
grpc::InsecureServerCredentials());
server = builder.BuildAndStart();
gpr_log(GPR_INFO, "Maintenance server listening on 0.0.0.0:%d",
maintenance_port);
LOG(INFO) << "Maintenance server listening on 0.0.0.0:" << maintenance_port;
} else {
grpc::AddAdminServices(&xds_builder);
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(absl::StrCat("0.0.0.0:", port),
grpc::InsecureServerCredentials());
server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server listening on 0.0.0.0:%d", port);
LOG(INFO) << "Server listening on 0.0.0.0:" << port;
}
// Wait for the server to shutdown. Note that some other thread must be

@ -58,7 +58,7 @@ target_link_libraries(hw_grpc_proto
# Targets greeter_[async_](client|server)
foreach(_target
greeter_callback_client greeter_callback_server
greeter_callback_client greeter_callback_server)
add_executable(${_target} "${_target}.cc")
target_link_libraries(${_target}
hw_grpc_proto

@ -37,5 +37,6 @@ cc_binary(
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
],
)

@ -22,6 +22,7 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include <grpcpp/ext/admin_services.h>
@ -84,21 +85,20 @@ void RunServer() {
absl::StrCat("0.0.0.0:", port),
grpc::XdsServerCredentials(grpc::InsecureServerCredentials()));
xds_enabled_server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port);
LOG(INFO) << "Server starting on 0.0.0.0:" << port;
grpc::AddAdminServices(&builder);
// For the maintenance server, do not use any authentication mechanism.
builder.AddListeningPort(absl::StrCat("0.0.0.0:", maintenance_port),
grpc::InsecureServerCredentials());
server = builder.BuildAndStart();
gpr_log(GPR_INFO, "Maintenance server listening on 0.0.0.0:%d",
maintenance_port);
LOG(INFO) << "Maintenance server listening on 0.0.0.0:" << maintenance_port;
} else {
grpc::AddAdminServices(&xds_builder);
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(absl::StrCat("0.0.0.0:", port),
grpc::InsecureServerCredentials());
server = xds_builder.BuildAndStart();
gpr_log(GPR_INFO, "Server listening on 0.0.0.0:%d", port);
LOG(INFO) << "Server listening on 0.0.0.0:" << port;
}
// Wait for the server to shutdown. Note that some other thread must be

@ -175,6 +175,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/service_type.h',
'include/grpcpp/impl/status.h',
'include/grpcpp/impl/sync.h',
'include/grpcpp/passive_listener.h',
'include/grpcpp/resource_quota.h',
'include/grpcpp/security/audit_logging.h',
'include/grpcpp/security/auth_context.h',

@ -119,6 +119,7 @@ Pod::Spec.new do |s|
'include/grpc/byte_buffer_reader.h',
'include/grpc/census.h',
'include/grpc/compression.h',
'include/grpc/credentials.h',
'include/grpc/event_engine/endpoint_config.h',
'include/grpc/event_engine/event_engine.h',
'include/grpc/event_engine/extensible.h',
@ -166,6 +167,7 @@ Pod::Spec.new do |s|
'include/grpc/impl/propagation_bits.h',
'include/grpc/impl/slice_type.h',
'include/grpc/load_reporting.h',
'include/grpc/passive_listener.h',
'include/grpc/slice.h',
'include/grpc/slice_buffer.h',
'include/grpc/status.h',

@ -19,6 +19,70 @@ EXPORTS
grpc_compression_options_enable_algorithm
grpc_compression_options_disable_algorithm
grpc_compression_options_is_algorithm_enabled
grpc_service_account_jwt_access_credentials_create
grpc_external_account_credentials_create
grpc_google_refresh_token_credentials_create
grpc_access_token_credentials_create
grpc_google_iam_credentials_create
grpc_sts_credentials_create
grpc_auth_metadata_context_copy
grpc_auth_metadata_context_reset
grpc_metadata_credentials_create_from_plugin
grpc_call_credentials_release
grpc_google_default_credentials_create
grpc_ssl_server_certificate_config_create
grpc_ssl_server_certificate_config_destroy
grpc_ssl_credentials_create
grpc_ssl_credentials_create_ex
grpc_ssl_server_credentials_create
grpc_ssl_server_credentials_create_ex
grpc_ssl_server_credentials_create_options_using_config
grpc_ssl_server_credentials_create_options_using_config_fetcher
grpc_ssl_server_credentials_options_destroy
grpc_ssl_server_credentials_create_with_options
grpc_server_credentials_set_auth_metadata_processor
grpc_composite_call_credentials_create
grpc_google_compute_engine_credentials_create
grpc_composite_channel_credentials_create
grpc_alts_credentials_client_options_create
grpc_alts_credentials_server_options_create
grpc_alts_credentials_client_options_add_target_service_account
grpc_alts_credentials_options_destroy
grpc_alts_credentials_create
grpc_alts_server_credentials_create
grpc_tls_identity_pairs_create
grpc_tls_identity_pairs_add_pair
grpc_tls_identity_pairs_destroy
grpc_tls_certificate_provider_static_data_create
grpc_tls_certificate_provider_file_watcher_create
grpc_tls_certificate_provider_release
grpc_tls_credentials_options_create
grpc_tls_credentials_options_set_min_tls_version
grpc_tls_credentials_options_set_max_tls_version
grpc_tls_credentials_options_copy
grpc_tls_credentials_options_destroy
grpc_tls_credentials_options_set_certificate_provider
grpc_tls_credentials_options_watch_root_certs
grpc_tls_credentials_options_set_root_cert_name
grpc_tls_credentials_options_watch_identity_key_cert_pairs
grpc_tls_credentials_options_set_identity_cert_name
grpc_tls_credentials_options_set_cert_request_type
grpc_tls_credentials_options_set_crl_directory
grpc_tls_credentials_options_set_verify_server_cert
grpc_tls_credentials_options_set_send_client_ca_list
grpc_ssl_session_cache_create_lru
grpc_ssl_session_cache_destroy
grpc_ssl_session_cache_create_channel_arg
grpc_set_ssl_roots_override_callback
grpc_max_auth_token_lifetime
grpc_insecure_credentials_create
grpc_insecure_server_credentials_create
grpc_xds_credentials_create
grpc_xds_server_credentials_create
grpc_local_credentials_create
grpc_local_server_credentials_create
grpc_tls_credentials_options_set_check_call_host
grpc_tls_credentials_options_set_tls_session_key_log_file_path
grpc_metadata_array_init
grpc_metadata_array_destroy
grpc_call_details_init
@ -64,6 +128,7 @@ EXPORTS
grpc_call_failed_before_recv_message
grpc_call_ref
grpc_call_unref
grpc_call_set_credentials
grpc_server_request_call
grpc_server_register_method
grpc_server_request_registered_call
@ -110,74 +175,9 @@ EXPORTS
grpc_auth_context_add_property
grpc_auth_context_add_cstring_property
grpc_auth_context_set_peer_identity_property_name
grpc_ssl_session_cache_create_lru
grpc_ssl_session_cache_destroy
grpc_ssl_session_cache_create_channel_arg
grpc_call_credentials_release
grpc_google_default_credentials_create
grpc_set_ssl_roots_override_callback
grpc_ssl_credentials_create
grpc_ssl_credentials_create_ex
grpc_composite_channel_credentials_create
grpc_composite_call_credentials_create
grpc_google_compute_engine_credentials_create
grpc_max_auth_token_lifetime
grpc_service_account_jwt_access_credentials_create
grpc_external_account_credentials_create
grpc_google_refresh_token_credentials_create
grpc_access_token_credentials_create
grpc_google_iam_credentials_create
grpc_sts_credentials_create
grpc_auth_metadata_context_copy
grpc_auth_metadata_context_reset
grpc_metadata_credentials_create_from_plugin
grpc_ssl_server_certificate_config_create
grpc_ssl_server_certificate_config_destroy
grpc_ssl_server_credentials_create
grpc_ssl_server_credentials_create_ex
grpc_ssl_server_credentials_create_options_using_config
grpc_ssl_server_credentials_create_options_using_config_fetcher
grpc_ssl_server_credentials_options_destroy
grpc_ssl_server_credentials_create_with_options
grpc_call_set_credentials
grpc_server_credentials_set_auth_metadata_processor
grpc_alts_credentials_client_options_create
grpc_alts_credentials_server_options_create
grpc_alts_credentials_client_options_add_target_service_account
grpc_alts_credentials_options_destroy
grpc_alts_credentials_create
grpc_alts_server_credentials_create
grpc_local_credentials_create
grpc_local_server_credentials_create
grpc_tls_identity_pairs_create
grpc_tls_identity_pairs_add_pair
grpc_tls_identity_pairs_destroy
grpc_tls_certificate_provider_static_data_create
grpc_tls_certificate_provider_file_watcher_create
grpc_tls_certificate_provider_release
grpc_tls_credentials_options_create
grpc_tls_credentials_options_set_min_tls_version
grpc_tls_credentials_options_set_max_tls_version
grpc_tls_credentials_options_copy
grpc_tls_credentials_options_destroy
grpc_tls_credentials_options_set_certificate_provider
grpc_tls_credentials_options_watch_root_certs
grpc_tls_credentials_options_set_root_cert_name
grpc_tls_credentials_options_watch_identity_key_cert_pairs
grpc_tls_credentials_options_set_identity_cert_name
grpc_tls_credentials_options_set_cert_request_type
grpc_tls_credentials_options_set_crl_directory
grpc_tls_credentials_options_set_verify_server_cert
grpc_tls_credentials_options_set_send_client_ca_list
grpc_tls_credentials_options_set_check_call_host
grpc_insecure_credentials_create
grpc_insecure_server_credentials_create
grpc_xds_credentials_create
grpc_xds_server_credentials_create
grpc_authorization_policy_provider_static_data_create
grpc_authorization_policy_provider_file_watcher_create
grpc_authorization_policy_provider_release
grpc_tls_credentials_options_set_tls_session_key_log_file_path
grpc_slice_ref
grpc_slice_unref
grpc_slice_copy

@ -51,6 +51,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/byte_buffer_reader.h )
s.files += %w( include/grpc/census.h )
s.files += %w( include/grpc/compression.h )
s.files += %w( include/grpc/credentials.h )
s.files += %w( include/grpc/event_engine/endpoint_config.h )
s.files += %w( include/grpc/event_engine/event_engine.h )
s.files += %w( include/grpc/event_engine/extensible.h )
@ -98,6 +99,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/propagation_bits.h )
s.files += %w( include/grpc/impl/slice_type.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_buffer.h )
s.files += %w( include/grpc/status.h )

File diff suppressed because it is too large Load Diff

@ -361,6 +361,13 @@ GRPCAPI void grpc_call_ref(grpc_call* call);
THREAD SAFETY: grpc_call_unref is thread-compatible */
GRPCAPI void grpc_call_unref(grpc_call* call);
typedef struct grpc_call_credentials grpc_call_credentials;
/** Sets a credentials to a call. Can only be called on the client side before
grpc_call_start_batch. */
GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_credentials* creds);
/** Request notification of a new call.
Once a call is received, a notification tagged with \a tag_new is added to
\a cq_for_notification. \a call, \a details and \a request_metadata are

@ -25,6 +25,7 @@
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>

File diff suppressed because it is too large Load Diff

@ -6,6 +6,7 @@ header "byte_buffer.h"
header "byte_buffer_reader.h"
header "census.h"
header "compression.h"
header "credentials.h"
header "fork.h"
header "grpc.h"
header "grpc_audit_logging.h"
@ -37,6 +38,7 @@ header "byte_buffer.h"
header "impl/propagation_bits.h"
header "impl/slice_type.h"
header "load_reporting.h"
header "passive_listener.h"
header "slice.h"
header "slice_buffer.h"
header "status.h"

@ -0,0 +1,62 @@
// 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 */

@ -102,7 +102,7 @@ GPRAPI void gpr_assertion_failed(const char* filename, int line,
#ifndef NDEBUG
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x)
#else
#define GPR_DEBUG_ASSERT(x)
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(true || (x))
#endif
#ifdef __cplusplus

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

@ -20,6 +20,7 @@
#include <memory>
#include <vector>
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/grpc_security_constants.h>
#include <grpc/status.h>

@ -25,13 +25,17 @@
#include <vector>
#include <grpc/compression.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/passive_listener.h>
#include <grpc/support/cpu.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/workaround_list.h>
#include <grpcpp/impl/channel_argument_option.h>
#include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/passive_listener.h>
#include <grpcpp/security/authorization_policy_provider.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/server_interceptor.h>
@ -58,6 +62,7 @@ class ExternalConnectionAcceptorImpl;
class CallbackGenericService;
namespace experimental {
// EXPERIMENTAL API:
// Interface for a grpc server to build transports with connections created out
// of band.
@ -291,6 +296,18 @@ class ServerBuilder {
void EnableCallMetricRecording(
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:
ServerBuilder* builder_;
};
@ -364,6 +381,17 @@ class ServerBuilder {
private:
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 {
SyncServerSettings()
: num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
@ -388,6 +416,7 @@ class ServerBuilder {
std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
std::vector<std::unique_ptr<NamedService>> services_;
std::vector<Port> ports_;
std::vector<UnstartedPassiveListener> unstarted_passive_listeners_;
SyncServerSettings sync_server_settings_;

@ -207,7 +207,9 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
auto* ops = ops_;
#endif
bool do_callback = ops_->FinalizeResult(&ignored, &ok);
#ifndef NDEBUG
GPR_DEBUG_ASSERT(ignored == ops);
#endif
if (do_callback) {
CatchingCallback(func_, ok);

@ -33,6 +33,7 @@
<file baseinstalldir="/" name="include/grpc/byte_buffer_reader.h" role="src" />
<file baseinstalldir="/" name="include/grpc/census.h" role="src" />
<file baseinstalldir="/" name="include/grpc/compression.h" role="src" />
<file baseinstalldir="/" name="include/grpc/credentials.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/endpoint_config.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/event_engine.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/extensible.h" role="src" />
@ -80,6 +81,7 @@
<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/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_buffer.h" role="src" />
<file baseinstalldir="/" name="include/grpc/status.h" role="src" />

File diff suppressed because it is too large Load Diff

@ -64,6 +64,10 @@ struct Parameters {
std::string message_header_extension;
// Whether to include headers corresponding to imports in source file.
bool include_import_headers;
// Whether to expose synchronous server API.
bool allow_sync_server_api;
// Whether to generate completion queue API.
bool allow_cq_api;
};
// Return the prologue of the generated header file.

@ -65,6 +65,8 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
generator_parameters.use_system_headers = true;
generator_parameters.generate_mock_code = false;
generator_parameters.include_import_headers = false;
generator_parameters.allow_sync_server_api = true;
generator_parameters.allow_cq_api = true;
ProtoBufFile pbfile(file);
@ -95,6 +97,24 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
*error = std::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else if (param[0] == "allow_sync_server_api") {
if (param[1] == "true") {
generator_parameters.allow_sync_server_api = true;
} else if (param[1] == "false") {
generator_parameters.allow_sync_server_api = false;
} else {
*error = std::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else if (param[0] == "allow_cq_api") {
if (param[1] == "true") {
generator_parameters.allow_cq_api = true;
} else if (param[1] == "false") {
generator_parameters.allow_cq_api = false;
} else {
*error = std::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else if (param[0] == "gmock_search_path") {
generator_parameters.gmock_search_path = param[1];
} else if (param[0] == "additional_header_includes") {

@ -3655,6 +3655,7 @@ grpc_cc_library(
"validation_errors",
"//:alts_util",
"//:gpr",
"//:grpc_core_credentials_header",
"//:ref_counted_ptr",
],
)
@ -3808,6 +3809,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:handshaker",
"//:iomgr",
@ -3846,6 +3848,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:handshaker",
"//:iomgr",
@ -3905,6 +3908,7 @@ grpc_cc_library(
"//:gpr",
"//:grpc_base",
"//:grpc_client_channel",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:handshaker",
"//:iomgr",
@ -3948,6 +3952,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:grpc_trace",
"//:handshaker",
@ -4004,6 +4009,7 @@ grpc_cc_library(
"//:gpr",
"//:grpc_alts_credentials",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_jwt_credentials",
"//:grpc_public_hdrs",
"//:grpc_security_base",
@ -4078,6 +4084,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_credentials_util",
"//:grpc_public_hdrs",
"//:grpc_security_base",
@ -4117,6 +4124,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:grpc_trace",
"//:promise",
@ -4164,6 +4172,7 @@ grpc_cc_library(
"//:api_trace",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_credentials_util",
"//:grpc_security_base",
"//:grpc_trace",
@ -4219,6 +4228,7 @@ grpc_cc_library(
"time",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_credentials_util",
"//:grpc_security_base",
"//:httpcli",
@ -4255,6 +4265,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:handshaker",
"//:iomgr",
@ -5143,6 +5154,7 @@ grpc_cc_library(
"//:gpr",
"//:grpc_base",
"//:grpc_client_channel",
"//:grpc_core_credentials_header",
"//:grpc_credentials_util",
"//:grpc_public_hdrs",
"//:grpc_security_base",
@ -5222,6 +5234,7 @@ grpc_cc_library(
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_public_hdrs",
"//:grpc_security_base",
"//:grpc_service_config_impl",
@ -5256,6 +5269,7 @@ grpc_cc_library(
"//:config",
"//:gpr",
"//:gpr_platform",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:ref_counted_ptr",
],
@ -6451,7 +6465,6 @@ grpc_cc_library(
"//:endpoint_addresses",
"//:gpr",
"//:grpc_base",
"//:grpc_client_channel",
"//:grpc_public_hdrs",
"//:grpc_resolver",
"//:grpc_service_config_impl",
@ -6787,6 +6800,8 @@ grpc_cc_library(
"connection_quota",
"error",
"error_utils",
"event_engine_extensions",
"event_engine_query_extensions",
"grpc_insecure_credentials",
"handshaker_registry",
"iomgr_fwd",
@ -6967,6 +6982,7 @@ grpc_cc_library(
"//:gpr",
"//:gpr_platform",
"//:grpc_base",
"//:grpc_core_credentials_header",
"//:grpc_security_base",
"//:grpc_trace",
"//:httpcli",
@ -7341,7 +7357,6 @@ grpc_cc_library(
],
deps = [
"1999",
"call_final_info",
"for_each",
"if",
"latch",
@ -7353,6 +7368,7 @@ grpc_cc_library(
"status_flag",
"try_seq",
"//:gpr",
"//:promise",
],
)

@ -644,7 +644,9 @@ class ClientChannelFilter::SubchannelWrapper final
chand, this, subchannel_.get());
}
GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper");
#ifndef NDEBUG
GPR_DEBUG_ASSERT(chand_->work_serializer_->RunningInWorkSerializer());
#endif
if (chand_->channelz_node_ != nullptr) {
auto* subchannel_node = subchannel_->channelz_node();
if (subchannel_node != nullptr) {

@ -34,6 +34,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/context.h"
#include "src/core/lib/channel/promise_based_filter.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/experiments/experiments.h"
@ -121,9 +122,9 @@ const grpc_channel_filter BackendMetricFilter::kFilter =
MakePromiseBasedFilter<BackendMetricFilter, FilterEndpoint::kServer>(
"backend_metric");
absl::StatusOr<BackendMetricFilter> BackendMetricFilter::Create(
const ChannelArgs&, ChannelFilter::Args) {
return BackendMetricFilter();
absl::StatusOr<std::unique_ptr<BackendMetricFilter>>
BackendMetricFilter::Create(const ChannelArgs&, ChannelFilter::Args) {
return std::make_unique<BackendMetricFilter>();
}
void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {

@ -35,8 +35,8 @@ class BackendMetricFilter : public ImplementChannelFilter<BackendMetricFilter> {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<BackendMetricFilter> Create(const ChannelArgs& args,
ChannelFilter::Args);
static absl::StatusOr<std::unique_ptr<BackendMetricFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args);
class Call {
public:

@ -25,6 +25,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/meta/type_traits.h"
#include "absl/random/random.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
#include <grpc/impl/channel_arg_names.h>
@ -133,18 +134,17 @@ struct LegacyMaxAgeFilter::Config {
// will be removed at that time also, so just disable the deprecation warning
// for now.
ABSL_INTERNAL_DISABLE_DEPRECATED_DECLARATION_WARNING
absl::StatusOr<LegacyClientIdleFilter> LegacyClientIdleFilter::Create(
const ChannelArgs& args, ChannelFilter::Args filter_args) {
LegacyClientIdleFilter filter(filter_args.channel_stack(),
GetClientIdleTimeout(args));
return absl::StatusOr<LegacyClientIdleFilter>(std::move(filter));
absl::StatusOr<std::unique_ptr<LegacyClientIdleFilter>>
LegacyClientIdleFilter::Create(const ChannelArgs& args,
ChannelFilter::Args filter_args) {
return std::make_unique<LegacyClientIdleFilter>(filter_args.channel_stack(),
GetClientIdleTimeout(args));
}
absl::StatusOr<LegacyMaxAgeFilter> LegacyMaxAgeFilter::Create(
absl::StatusOr<std::unique_ptr<LegacyMaxAgeFilter>> LegacyMaxAgeFilter::Create(
const ChannelArgs& args, ChannelFilter::Args filter_args) {
LegacyMaxAgeFilter filter(filter_args.channel_stack(),
Config::FromChannelArgs(args));
return absl::StatusOr<LegacyMaxAgeFilter>(std::move(filter));
return std::make_unique<LegacyMaxAgeFilter>(filter_args.channel_stack(),
Config::FromChannelArgs(args));
}
ABSL_INTERNAL_RESTORE_DEPRECATED_DECLARATION_WARNING

@ -42,6 +42,11 @@ namespace grpc_core {
class LegacyChannelIdleFilter : public ChannelFilter {
public:
LegacyChannelIdleFilter(grpc_channel_stack* channel_stack,
Duration client_idle_timeout)
: channel_stack_(channel_stack),
client_idle_timeout_(client_idle_timeout) {}
~LegacyChannelIdleFilter() override = default;
LegacyChannelIdleFilter(const LegacyChannelIdleFilter&) = delete;
@ -59,11 +64,6 @@ class LegacyChannelIdleFilter : public ChannelFilter {
using SingleSetActivityPtr =
SingleSetPtr<Activity, typename ActivityPtr::deleter_type>;
LegacyChannelIdleFilter(grpc_channel_stack* channel_stack,
Duration client_idle_timeout)
: channel_stack_(channel_stack),
client_idle_timeout_(client_idle_timeout) {}
grpc_channel_stack* channel_stack() { return channel_stack_; };
virtual void Shutdown();
@ -94,10 +94,9 @@ class LegacyClientIdleFilter final : public LegacyChannelIdleFilter {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<LegacyClientIdleFilter> Create(
static absl::StatusOr<std::unique_ptr<LegacyClientIdleFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
private:
using LegacyChannelIdleFilter::LegacyChannelIdleFilter;
};
@ -106,9 +105,12 @@ class LegacyMaxAgeFilter final : public LegacyChannelIdleFilter {
static const grpc_channel_filter kFilter;
struct Config;
static absl::StatusOr<LegacyMaxAgeFilter> Create(
static absl::StatusOr<std::unique_ptr<LegacyMaxAgeFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
LegacyMaxAgeFilter(grpc_channel_stack* channel_stack,
const Config& max_age_config);
void PostInit() override;
private:
@ -128,9 +130,6 @@ class LegacyMaxAgeFilter final : public LegacyChannelIdleFilter {
LegacyMaxAgeFilter* filter_;
};
LegacyMaxAgeFilter(grpc_channel_stack* channel_stack,
const Config& max_age_config);
void Shutdown() override;
SingleSetActivityPtr max_age_activity_;

@ -370,8 +370,9 @@ const grpc_channel_filter grpc_server_deadline_filter = {
return next_promise_factory(std::move(call_args));
},
[](grpc_channel_element*, grpc_core::CallSpineInterface* spine) {
spine->client_initial_metadata().receiver.InterceptAndMap(
[](grpc_core::ClientMetadataHandle md) {
grpc_core::DownCast<grpc_core::PipeBasedCallSpine*>(spine)
->client_initial_metadata()
.receiver.InterceptAndMap([](grpc_core::ClientMetadataHandle md) {
auto deadline = md->get(grpc_core::GrpcTimeoutMetadata());
if (deadline.has_value()) {
grpc_core::GetContext<grpc_core::CallContext>()->UpdateDeadline(

@ -29,6 +29,7 @@
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
@ -135,16 +136,16 @@ class FaultInjectionFilter::InjectionDecision {
FaultHandle active_fault_{false};
};
absl::StatusOr<FaultInjectionFilter> FaultInjectionFilter::Create(
const ChannelArgs&, ChannelFilter::Args filter_args) {
return FaultInjectionFilter(filter_args);
absl::StatusOr<std::unique_ptr<FaultInjectionFilter>>
FaultInjectionFilter::Create(const ChannelArgs&,
ChannelFilter::Args filter_args) {
return std::make_unique<FaultInjectionFilter>(filter_args);
}
FaultInjectionFilter::FaultInjectionFilter(ChannelFilter::Args filter_args)
: index_(filter_args.instance_id()),
service_config_parser_index_(
FaultInjectionServiceConfigParser::ParserIndex()),
mu_(new Mutex) {}
FaultInjectionServiceConfigParser::ParserIndex()) {}
// Construct a promise for one call.
ArenaPromise<absl::Status> FaultInjectionFilter::Call::OnClientInitialMetadata(
@ -226,7 +227,7 @@ FaultInjectionFilter::MakeInjectionDecision(
bool delay_request = delay != Duration::Zero();
bool abort_request = abort_code != GRPC_STATUS_OK;
if (delay_request || abort_request) {
MutexLock lock(mu_.get());
MutexLock lock(&mu_);
if (delay_request) {
delay_request =
UnderFraction(&delay_rand_generator_, delay_percentage_numerator,

@ -45,9 +45,11 @@ class FaultInjectionFilter
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<FaultInjectionFilter> Create(
static absl::StatusOr<std::unique_ptr<FaultInjectionFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit FaultInjectionFilter(ChannelFilter::Args filter_args);
// Construct a promise for one call.
class Call {
public:
@ -61,8 +63,6 @@ class FaultInjectionFilter
};
private:
explicit FaultInjectionFilter(ChannelFilter::Args filter_args);
class InjectionDecision;
InjectionDecision MakeInjectionDecision(
const ClientMetadata& initial_metadata);
@ -70,7 +70,7 @@ class FaultInjectionFilter
// The relative index of instances of the same filter.
size_t index_;
const size_t service_config_parser_index_;
std::unique_ptr<Mutex> mu_;
Mutex mu_;
absl::InsecureBitGen abort_rand_generator_ ABSL_GUARDED_BY(mu_);
absl::InsecureBitGen delay_rand_generator_ ABSL_GUARDED_BY(mu_);
};

@ -27,6 +27,7 @@
#include <vector>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
@ -136,16 +137,16 @@ HttpClientFilter::HttpClientFilter(HttpSchemeMetadata::ValueType scheme,
Slice user_agent,
bool test_only_use_put_requests)
: scheme_(scheme),
user_agent_(std::move(user_agent)),
test_only_use_put_requests_(test_only_use_put_requests) {}
test_only_use_put_requests_(test_only_use_put_requests),
user_agent_(std::move(user_agent)) {}
absl::StatusOr<HttpClientFilter> HttpClientFilter::Create(
absl::StatusOr<std::unique_ptr<HttpClientFilter>> HttpClientFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
auto* transport = args.GetObject<Transport>();
if (transport == nullptr) {
return absl::InvalidArgumentError("HttpClientFilter needs a transport");
}
return HttpClientFilter(
return std::make_unique<HttpClientFilter>(
SchemeFromArgs(args),
UserAgentFromArgs(args, transport->GetTransportName()),
args.GetInt(GRPC_ARG_TEST_ONLY_USE_PUT_REQUESTS).value_or(false));

@ -35,9 +35,12 @@ class HttpClientFilter : public ImplementChannelFilter<HttpClientFilter> {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<HttpClientFilter> Create(
static absl::StatusOr<std::unique_ptr<HttpClientFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
HttpClientFilter(HttpSchemeMetadata::ValueType scheme, Slice user_agent,
bool test_only_use_put_requests);
class Call {
public:
void OnClientInitialMetadata(ClientMetadata& md, HttpClientFilter* filter);
@ -49,12 +52,9 @@ class HttpClientFilter : public ImplementChannelFilter<HttpClientFilter> {
};
private:
HttpClientFilter(HttpSchemeMetadata::ValueType scheme, Slice user_agent,
bool test_only_use_put_requests);
HttpSchemeMetadata::ValueType scheme_;
Slice user_agent_;
bool test_only_use_put_requests_;
Slice user_agent_;
};
// A test-only channel arg to allow testing gRPC Core server behavior on PUT

@ -43,8 +43,8 @@ const NoInterceptor ClientAuthorityFilter::Call::OnClientToServerMessage;
const NoInterceptor ClientAuthorityFilter::Call::OnServerToClientMessage;
const NoInterceptor ClientAuthorityFilter::Call::OnFinalize;
absl::StatusOr<ClientAuthorityFilter> ClientAuthorityFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
absl::StatusOr<std::unique_ptr<ClientAuthorityFilter>>
ClientAuthorityFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
absl::optional<absl::string_view> default_authority =
args.GetString(GRPC_ARG_DEFAULT_AUTHORITY);
if (!default_authority.has_value()) {
@ -52,7 +52,8 @@ absl::StatusOr<ClientAuthorityFilter> ClientAuthorityFilter::Create(
"GRPC_ARG_DEFAULT_AUTHORITY string channel arg. not found. Note that "
"direct channels must explicitly specify a value for this argument.");
}
return ClientAuthorityFilter(Slice::FromCopiedString(*default_authority));
return std::make_unique<ClientAuthorityFilter>(
Slice::FromCopiedString(*default_authority));
}
void ClientAuthorityFilter::Call::OnClientInitialMetadata(

@ -39,8 +39,11 @@ class ClientAuthorityFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ClientAuthorityFilter> Create(const ChannelArgs& args,
ChannelFilter::Args);
static absl::StatusOr<std::unique_ptr<ClientAuthorityFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args);
explicit ClientAuthorityFilter(Slice default_authority)
: default_authority_(std::move(default_authority)) {}
class Call {
public:
@ -54,8 +57,6 @@ class ClientAuthorityFilter final
};
private:
explicit ClientAuthorityFilter(Slice default_authority)
: default_authority_(std::move(default_authority)) {}
Slice default_authority_;
};

@ -72,14 +72,14 @@ const grpc_channel_filter ServerCompressionFilter::kFilter =
kFilterExaminesInboundMessages |
kFilterExaminesOutboundMessages>("compression");
absl::StatusOr<ClientCompressionFilter> ClientCompressionFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
return ClientCompressionFilter(args);
absl::StatusOr<std::unique_ptr<ClientCompressionFilter>>
ClientCompressionFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
return std::make_unique<ClientCompressionFilter>(args);
}
absl::StatusOr<ServerCompressionFilter> ServerCompressionFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
return ServerCompressionFilter(args);
absl::StatusOr<std::unique_ptr<ServerCompressionFilter>>
ServerCompressionFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
return std::make_unique<ServerCompressionFilter>(args);
}
ChannelCompression::ChannelCompression(const ChannelArgs& args)

@ -110,9 +110,12 @@ class ClientCompressionFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ClientCompressionFilter> Create(
static absl::StatusOr<std::unique_ptr<ClientCompressionFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit ClientCompressionFilter(const ChannelArgs& args)
: compression_engine_(args) {}
// Construct a promise for one call.
class Call {
public:
@ -135,9 +138,6 @@ class ClientCompressionFilter final
};
private:
explicit ClientCompressionFilter(const ChannelArgs& args)
: compression_engine_(args) {}
ChannelCompression compression_engine_;
};
@ -146,9 +146,12 @@ class ServerCompressionFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ServerCompressionFilter> Create(
static absl::StatusOr<std::unique_ptr<ServerCompressionFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit ServerCompressionFilter(const ChannelArgs& args)
: compression_engine_(args) {}
// Construct a promise for one call.
class Call {
public:
@ -171,9 +174,6 @@ class ServerCompressionFilter final
};
private:
explicit ServerCompressionFilter(const ChannelArgs& args)
: compression_engine_(args) {}
ChannelCompression compression_engine_;
};

@ -152,9 +152,9 @@ void HttpServerFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {
FilterOutgoingMetadata(&md);
}
absl::StatusOr<HttpServerFilter> HttpServerFilter::Create(
absl::StatusOr<std::unique_ptr<HttpServerFilter>> HttpServerFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
return HttpServerFilter(
return std::make_unique<HttpServerFilter>(
args.GetBool(GRPC_ARG_SURFACE_USER_AGENT).value_or(true),
args.GetBool(
GRPC_ARG_DO_NOT_USE_UNLESS_YOU_HAVE_PERMISSION_FROM_GRPC_TEAM_ALLOW_BROKEN_PUT_REQUESTS)

@ -36,9 +36,13 @@ class HttpServerFilter : public ImplementChannelFilter<HttpServerFilter> {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<HttpServerFilter> Create(
static absl::StatusOr<std::unique_ptr<HttpServerFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
HttpServerFilter(bool surface_user_agent, bool allow_put_requests)
: surface_user_agent_(surface_user_agent),
allow_put_requests_(allow_put_requests) {}
class Call {
public:
ServerMetadataHandle OnClientInitialMetadata(ClientMetadata& md,
@ -51,10 +55,6 @@ class HttpServerFilter : public ImplementChannelFilter<HttpServerFilter> {
};
private:
HttpServerFilter(bool surface_user_agent, bool allow_put_requests)
: surface_user_agent_(surface_user_agent),
allow_put_requests_(allow_put_requests) {}
bool surface_user_agent_;
bool allow_put_requests_;
};

@ -76,10 +76,11 @@ const NoInterceptor ServerLoadReportingFilter::Call::OnServerInitialMetadata;
const NoInterceptor ServerLoadReportingFilter::Call::OnClientToServerMessage;
const NoInterceptor ServerLoadReportingFilter::Call::OnServerToClientMessage;
absl::StatusOr<ServerLoadReportingFilter> ServerLoadReportingFilter::Create(
const ChannelArgs& channel_args, ChannelFilter::Args) {
absl::StatusOr<std::unique_ptr<ServerLoadReportingFilter>>
ServerLoadReportingFilter::Create(const ChannelArgs& channel_args,
ChannelFilter::Args) {
// Find and record the peer_identity.
ServerLoadReportingFilter filter;
auto filter = std::make_unique<ServerLoadReportingFilter>();
const auto* auth_context = channel_args.GetObject<grpc_auth_context>();
if (auth_context != nullptr &&
grpc_auth_context_peer_is_authenticated(auth_context)) {
@ -88,7 +89,7 @@ absl::StatusOr<ServerLoadReportingFilter> ServerLoadReportingFilter::Create(
const grpc_auth_property* auth_property =
grpc_auth_property_iterator_next(&auth_it);
if (auth_property != nullptr) {
filter.peer_identity_ =
filter->peer_identity_ =
std::string(auth_property->value, auth_property->value_length);
}
}

@ -39,7 +39,7 @@ class ServerLoadReportingFilter
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ServerLoadReportingFilter> Create(
static absl::StatusOr<std::unique_ptr<ServerLoadReportingFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args);
// Getters.

@ -342,21 +342,23 @@ class CallData {
} // namespace
absl::StatusOr<ClientLoggingFilter> ClientLoggingFilter::Create(
const ChannelArgs& args, ChannelFilter::Args /*filter_args*/) {
absl::StatusOr<std::unique_ptr<ClientLoggingFilter>>
ClientLoggingFilter::Create(const ChannelArgs& args,
ChannelFilter::Args /*filter_args*/) {
absl::optional<absl::string_view> default_authority =
args.GetString(GRPC_ARG_DEFAULT_AUTHORITY);
if (default_authority.has_value()) {
return ClientLoggingFilter(std::string(default_authority.value()));
return std::make_unique<ClientLoggingFilter>(
std::string(default_authority.value()));
}
absl::optional<std::string> server_uri =
args.GetOwnedString(GRPC_ARG_SERVER_URI);
if (server_uri.has_value()) {
return ClientLoggingFilter(
return std::make_unique<ClientLoggingFilter>(
CoreConfiguration::Get().resolver_registry().GetDefaultAuthority(
*server_uri));
}
return ClientLoggingFilter("");
return std::make_unique<ClientLoggingFilter>("");
}
// Construct a promise for one call.
@ -445,9 +447,10 @@ const grpc_channel_filter ClientLoggingFilter::kFilter =
kFilterExaminesInboundMessages |
kFilterExaminesOutboundMessages>("logging");
absl::StatusOr<ServerLoggingFilter> ServerLoggingFilter::Create(
const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/) {
return ServerLoggingFilter();
absl::StatusOr<std::unique_ptr<ServerLoggingFilter>>
ServerLoggingFilter::Create(const ChannelArgs& /*args*/,
ChannelFilter::Args /*filter_args*/) {
return std::make_unique<ServerLoggingFilter>();
}
// Construct a promise for one call.

@ -39,24 +39,25 @@ class ClientLoggingFilter final : public ChannelFilter {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ClientLoggingFilter> Create(
static absl::StatusOr<std::unique_ptr<ClientLoggingFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args /*filter_args*/);
explicit ClientLoggingFilter(std::string default_authority)
: default_authority_(std::move(default_authority)) {}
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
private:
explicit ClientLoggingFilter(std::string default_authority)
: default_authority_(std::move(default_authority)) {}
std::string default_authority_;
const std::string default_authority_;
};
class ServerLoggingFilter final : public ChannelFilter {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ServerLoggingFilter> Create(
static absl::StatusOr<std::unique_ptr<ServerLoggingFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args /*filter_args*/);
// Construct a promise for one call.

@ -25,7 +25,6 @@
#include "absl/strings/str_format.h"
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
@ -142,19 +141,20 @@ const grpc_channel_filter ClientMessageSizeFilter::kFilter =
MakePromiseBasedFilter<ClientMessageSizeFilter, FilterEndpoint::kClient,
kFilterExaminesOutboundMessages |
kFilterExaminesInboundMessages>("message_size");
const grpc_channel_filter ServerMessageSizeFilter::kFilter =
MakePromiseBasedFilter<ServerMessageSizeFilter, FilterEndpoint::kServer,
kFilterExaminesOutboundMessages |
kFilterExaminesInboundMessages>("message_size");
absl::StatusOr<ClientMessageSizeFilter> ClientMessageSizeFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
return ClientMessageSizeFilter(args);
absl::StatusOr<std::unique_ptr<ClientMessageSizeFilter>>
ClientMessageSizeFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
return std::make_unique<ClientMessageSizeFilter>(args);
}
absl::StatusOr<ServerMessageSizeFilter> ServerMessageSizeFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
return ServerMessageSizeFilter(args);
absl::StatusOr<std::unique_ptr<ServerMessageSizeFilter>>
ServerMessageSizeFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
return std::make_unique<ServerMessageSizeFilter>(args);
}
namespace {
@ -168,7 +168,7 @@ ServerMetadataHandle CheckPayload(const Message& msg,
is_send ? "send" : "recv", msg.payload()->Length(), *max_length);
}
if (msg.payload()->Length() <= *max_length) return nullptr;
auto r = GetContext<Arena>()->MakePooled<ServerMetadata>();
auto r = Arena::MakePooled<ServerMetadata>();
r->Set(GrpcStatusMetadata(), GRPC_STATUS_RESOURCE_EXHAUSTED);
r->Set(GrpcMessageMetadata(),
Slice::FromCopiedString(absl::StrFormat(

@ -91,9 +91,12 @@ class ServerMessageSizeFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ServerMessageSizeFilter> Create(
static absl::StatusOr<std::unique_ptr<ServerMessageSizeFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit ServerMessageSizeFilter(const ChannelArgs& args)
: parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {}
class Call {
public:
static const NoInterceptor OnClientInitialMetadata;
@ -107,8 +110,6 @@ class ServerMessageSizeFilter final
};
private:
explicit ServerMessageSizeFilter(const ChannelArgs& args)
: parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {}
const MessageSizeParsedConfig parsed_config_;
};
@ -117,9 +118,12 @@ class ClientMessageSizeFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ClientMessageSizeFilter> Create(
static absl::StatusOr<std::unique_ptr<ClientMessageSizeFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit ClientMessageSizeFilter(const ChannelArgs& args)
: parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {}
class Call {
public:
explicit Call(ClientMessageSizeFilter* filter);
@ -136,8 +140,6 @@ class ClientMessageSizeFilter final
};
private:
explicit ClientMessageSizeFilter(const ChannelArgs& args)
: parsed_config_(MessageSizeParsedConfig::GetFromChannelArgs(args)) {}
const size_t service_config_parser_index_{MessageSizeParser::ParserIndex()};
const MessageSizeParsedConfig parsed_config_;
};

@ -82,14 +82,21 @@ RbacFilter::RbacFilter(size_t index,
service_config_parser_index_(RbacServiceConfigParser::ParserIndex()),
per_channel_evaluate_args_(std::move(per_channel_evaluate_args)) {}
absl::StatusOr<RbacFilter> RbacFilter::Create(const ChannelArgs& args,
ChannelFilter::Args filter_args) {
absl::StatusOr<std::unique_ptr<RbacFilter>> RbacFilter::Create(
const ChannelArgs& args, ChannelFilter::Args filter_args) {
auto* auth_context = args.GetObject<grpc_auth_context>();
if (auth_context == nullptr) {
return GRPC_ERROR_CREATE("No auth context found");
}
return RbacFilter(filter_args.instance_id(),
EvaluateArgs::PerChannelArgs(auth_context, args));
auto* transport = args.GetObject<Transport>();
if (transport == nullptr) {
// This should never happen since the transport is always set on the server
// side.
return GRPC_ERROR_CREATE("No transport configured");
}
return std::make_unique<RbacFilter>(
filter_args.instance_id(),
EvaluateArgs::PerChannelArgs(auth_context, args));
}
void RbacFilterRegister(CoreConfiguration::Builder* builder) {

@ -42,8 +42,11 @@ class RbacFilter : public ImplementChannelFilter<RbacFilter> {
// and enforces the RBAC policy.
static const grpc_channel_filter kFilterVtable;
static absl::StatusOr<RbacFilter> Create(const ChannelArgs& args,
ChannelFilter::Args filter_args);
static absl::StatusOr<std::unique_ptr<RbacFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
RbacFilter(size_t index,
EvaluateArgs::PerChannelArgs per_channel_evaluate_args);
class Call {
public:
@ -57,9 +60,6 @@ class RbacFilter : public ImplementChannelFilter<RbacFilter> {
};
private:
RbacFilter(size_t index,
EvaluateArgs::PerChannelArgs per_channel_evaluate_args);
// The index of this filter instance among instances of the same filter.
size_t index_;
// Assigned index for service config data from the parser.

@ -49,19 +49,22 @@ namespace grpc_core {
namespace {
class ServerConfigSelectorFilter final
: public ImplementChannelFilter<ServerConfigSelectorFilter> {
: public ImplementChannelFilter<ServerConfigSelectorFilter>,
public InternallyRefCounted<ServerConfigSelectorFilter> {
public:
~ServerConfigSelectorFilter() override;
explicit ServerConfigSelectorFilter(
RefCountedPtr<ServerConfigSelectorProvider>
server_config_selector_provider);
ServerConfigSelectorFilter(const ServerConfigSelectorFilter&) = delete;
ServerConfigSelectorFilter& operator=(const ServerConfigSelectorFilter&) =
delete;
ServerConfigSelectorFilter(ServerConfigSelectorFilter&&) = default;
ServerConfigSelectorFilter& operator=(ServerConfigSelectorFilter&&) = default;
static absl::StatusOr<ServerConfigSelectorFilter> Create(
static absl::StatusOr<OrphanablePtr<ServerConfigSelectorFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args);
void Orphan() override;
class Call {
public:
absl::Status OnClientInitialMetadata(ClientMetadata& md,
@ -74,70 +77,66 @@ class ServerConfigSelectorFilter final
};
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> config_selector() {
MutexLock lock(&state_->mu);
return state_->config_selector.value();
MutexLock lock(&mu_);
return config_selector_.value();
}
private:
struct State {
Mutex mu;
absl::optional<absl::StatusOr<RefCountedPtr<ServerConfigSelector>>>
config_selector ABSL_GUARDED_BY(mu);
};
class ServerConfigSelectorWatcher
: public ServerConfigSelectorProvider::ServerConfigSelectorWatcher {
public:
explicit ServerConfigSelectorWatcher(std::shared_ptr<State> state)
: state_(state) {}
explicit ServerConfigSelectorWatcher(
RefCountedPtr<ServerConfigSelectorFilter> filter)
: filter_(filter) {}
void OnServerConfigSelectorUpdate(
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> update) override {
MutexLock lock(&state_->mu);
state_->config_selector = std::move(update);
MutexLock lock(&filter_->mu_);
filter_->config_selector_ = std::move(update);
}
private:
std::shared_ptr<State> state_;
RefCountedPtr<ServerConfigSelectorFilter> filter_;
};
explicit ServerConfigSelectorFilter(
RefCountedPtr<ServerConfigSelectorProvider>
server_config_selector_provider);
RefCountedPtr<ServerConfigSelectorProvider> server_config_selector_provider_;
std::shared_ptr<State> state_;
Mutex mu_;
absl::optional<absl::StatusOr<RefCountedPtr<ServerConfigSelector>>>
config_selector_ ABSL_GUARDED_BY(mu_);
};
absl::StatusOr<ServerConfigSelectorFilter> ServerConfigSelectorFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
absl::StatusOr<OrphanablePtr<ServerConfigSelectorFilter>>
ServerConfigSelectorFilter::Create(const ChannelArgs& args,
ChannelFilter::Args) {
ServerConfigSelectorProvider* server_config_selector_provider =
args.GetObject<ServerConfigSelectorProvider>();
if (server_config_selector_provider == nullptr) {
return absl::UnknownError("No ServerConfigSelectorProvider object found");
}
return ServerConfigSelectorFilter(server_config_selector_provider->Ref());
return MakeOrphanable<ServerConfigSelectorFilter>(
server_config_selector_provider->Ref());
}
ServerConfigSelectorFilter::ServerConfigSelectorFilter(
RefCountedPtr<ServerConfigSelectorProvider> server_config_selector_provider)
: server_config_selector_provider_(
std::move(server_config_selector_provider)),
state_(std::make_shared<State>()) {
std::move(server_config_selector_provider)) {
GPR_ASSERT(server_config_selector_provider_ != nullptr);
auto server_config_selector_watcher =
std::make_unique<ServerConfigSelectorWatcher>(state_);
std::make_unique<ServerConfigSelectorWatcher>(Ref());
auto config_selector = server_config_selector_provider_->Watch(
std::move(server_config_selector_watcher));
MutexLock lock(&state_->mu);
MutexLock lock(&mu_);
// It's possible for the watcher to have already updated config_selector_
if (!state_->config_selector.has_value()) {
state_->config_selector = std::move(config_selector);
if (!config_selector_.has_value()) {
config_selector_ = std::move(config_selector);
}
}
ServerConfigSelectorFilter::~ServerConfigSelectorFilter() {
void ServerConfigSelectorFilter::Orphan() {
if (server_config_selector_provider_ != nullptr) {
server_config_selector_provider_->CancelWatch();
}
Unref();
}
absl::Status ServerConfigSelectorFilter::Call::OnClientInitialMetadata(

@ -72,9 +72,10 @@ const grpc_channel_filter StatefulSessionFilter::kFilter =
kFilterExaminesServerInitialMetadata>(
"stateful_session_filter");
absl::StatusOr<StatefulSessionFilter> StatefulSessionFilter::Create(
const ChannelArgs&, ChannelFilter::Args filter_args) {
return StatefulSessionFilter(filter_args);
absl::StatusOr<std::unique_ptr<StatefulSessionFilter>>
StatefulSessionFilter::Create(const ChannelArgs&,
ChannelFilter::Args filter_args) {
return std::make_unique<StatefulSessionFilter>(filter_args);
}
StatefulSessionFilter::StatefulSessionFilter(ChannelFilter::Args filter_args)

@ -74,9 +74,11 @@ class StatefulSessionFilter
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<StatefulSessionFilter> Create(
static absl::StatusOr<std::unique_ptr<StatefulSessionFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);
explicit StatefulSessionFilter(ChannelFilter::Args filter_args);
class Call {
public:
void OnClientInitialMetadata(ClientMetadata& md,
@ -97,7 +99,6 @@ class StatefulSessionFilter
};
private:
explicit StatefulSessionFilter(ChannelFilter::Args filter_args);
// The relative index of instances of the same filter.
const size_t index_;
// Index of the service config parser.

@ -28,6 +28,7 @@
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h>

@ -159,7 +159,7 @@ class BinderServerListener : public Server::ListenerInterface {
on_destroy_done_ = on_destroy_done;
}
void Orphan() override { delete this; }
void Orphan() override { Unref(); }
~BinderServerListener() override {
ExecCtx::Get()->Flush();
@ -239,9 +239,8 @@ bool AddBinderPort(const std::string& addr, grpc_server* server,
}
std::string conn_id = addr.substr(kBinderUriScheme.size());
Server* core_server = Server::FromC(server);
core_server->AddListener(
OrphanablePtr<Server::ListenerInterface>(new BinderServerListener(
core_server, conn_id, std::move(factory), security_policy)));
core_server->AddListener(MakeOrphanable<BinderServerListener>(
core_server, conn_id, std::move(factory), security_policy));
return true;
}

@ -102,14 +102,12 @@ auto ChaoticGoodClientTransport::PushFrameIntoCall(ServerFragmentFrame frame,
},
[]() -> StatusFlag { return Success{}; });
},
[call_handler, trailers = std::move(frame.trailers)]() mutable {
return If(
trailers != nullptr,
[&call_handler, &trailers]() mutable {
return call_handler.PushServerTrailingMetadata(
std::move(trailers));
},
[]() -> StatusFlag { return Success{}; });
[call_handler,
trailers = std::move(frame.trailers)]() mutable -> StatusFlag {
if (trailers != nullptr) {
call_handler.PushServerTrailingMetadata(std::move(trailers));
}
return Success{};
});
// Wrap the actual sequence with something that owns the call handler so that
// its lifetime extends until the push completes.
@ -223,7 +221,7 @@ void ChaoticGoodClientTransport::AbortWithError() {
for (const auto& pair : stream_map) {
auto call_handler = pair.second;
call_handler.SpawnInfallible("cancel", [call_handler]() mutable {
call_handler.Cancel(ServerMetadataFromStatus(
call_handler.PushServerTrailingMetadata(ServerMetadataFromStatus(
absl::UnavailableError("Transport closed.")));
return Empty{};
});
@ -300,6 +298,10 @@ void ChaoticGoodClientTransport::StartCall(CallHandler call_handler) {
const uint32_t stream_id = MakeStream(call_handler);
return Map(CallOutboundLoop(stream_id, call_handler),
[stream_id, this](absl::Status result) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: Call %d finished with %s",
stream_id, result.ToString().c_str());
}
if (!result.ok()) {
CancelFrame frame;
frame.stream_id = stream_id;

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

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

@ -72,33 +72,29 @@ auto ChaoticGoodServerTransport::TransportWriteLoop(
auto ChaoticGoodServerTransport::PushFragmentIntoCall(
CallInitiator call_initiator, ClientFragmentFrame frame,
uint32_t stream_id) {
auto& headers = frame.headers;
return TrySeq(
If(
headers != nullptr,
[call_initiator, &headers]() mutable {
return call_initiator.PushClientInitialMetadata(std::move(headers));
},
[]() -> StatusFlag { return Success{}; }),
[call_initiator, message = std::move(frame.message)]() mutable {
return If(
message.has_value(),
[&call_initiator, &message]() mutable {
return call_initiator.PushMessage(std::move(message->message));
},
[]() -> StatusFlag { return Success{}; });
},
[this, call_initiator, end_of_stream = frame.end_of_stream,
stream_id]() mutable -> StatusFlag {
if (end_of_stream) {
call_initiator.FinishSends();
// We have received end_of_stream. It is now safe to remove the call
// from the stream map.
MutexLock lock(&mu_);
stream_map_.erase(stream_id);
}
return Success{};
});
GPR_DEBUG_ASSERT(frame.headers == nullptr);
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: PushFragmentIntoCall: frame=%s",
frame.ToString().c_str());
}
return TrySeq(If(
frame.message.has_value(),
[&call_initiator, &frame]() mutable {
return call_initiator.PushMessage(
std::move(frame.message->message));
},
[]() -> StatusFlag { return Success{}; }),
[this, call_initiator, end_of_stream = frame.end_of_stream,
stream_id]() mutable -> StatusFlag {
if (end_of_stream) {
call_initiator.FinishSends();
// We have received end_of_stream. It is now safe to remove
// the call from the stream map.
MutexLock lock(&mu_);
stream_map_.erase(stream_id);
}
return Success{};
});
}
auto ChaoticGoodServerTransport::MaybePushFragmentIntoCall(
@ -244,8 +240,8 @@ auto ChaoticGoodServerTransport::DeserializeAndPushFragmentToNewCall(
FrameLimits{1024 * 1024 * 1024, aligned_bytes_ - 1});
absl::optional<CallInitiator> call_initiator;
if (status.ok()) {
auto create_call_result =
acceptor_->CreateCall(*fragment_frame.headers, arena.release());
auto create_call_result = acceptor_->CreateCall(
std::move(fragment_frame.headers), arena.release());
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO,
"CHAOTIC_GOOD: DeserializeAndPushFragmentToNewCall: "

@ -41,6 +41,7 @@
#include <grpc/grpc.h>
#include <grpc/grpc_posix.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/passive_listener.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -55,6 +56,8 @@
#include "src/core/lib/config/core_configuration.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/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/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -64,6 +67,7 @@
#include "src/core/lib/gprpp/unique_type_name.h"
#include "src/core/lib/iomgr/closure.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/pollset_set.h"
#include "src/core/lib/iomgr/resolve_address.h"
@ -92,9 +96,11 @@
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
namespace grpc_core {
namespace {
using ::grpc_event_engine::experimental::EventEngine;
using grpc_event_engine::experimental::ChannelArgsEndpointConfig;
using grpc_event_engine::experimental::EventEngine;
using grpc_event_engine::experimental::EventEngineSupportsFdExtension;
using grpc_event_engine::experimental::QueryExtension;
const char kUnixUriPrefix[] = "unix:";
const char kUnixAbstractUriPrefix[] = "unix-abstract:";
@ -111,14 +117,23 @@ class Chttp2ServerListener : public Server::ListenerInterface {
Server* server, const char* name, const ChannelArgs& args,
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.
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;
void Start(Server* server,
const std::vector<grpc_pollset*>* pollsets) override;
void AcceptConnectedEndpoint(std::unique_ptr<EventEngine::Endpoint> endpoint);
channelz::ListenSocketNode* channelz_listen_socket_node() const override {
return channelz_listen_socket_.get();
}
@ -128,6 +143,8 @@ class Chttp2ServerListener : public Server::ListenerInterface {
void Orphan() override;
private:
friend class experimental::PassiveListenerImpl;
class ConfigFetcherWatcher
: public grpc_server_config_fetcher::WatcherInterface {
public:
@ -234,34 +251,8 @@ class Chttp2ServerListener : public Server::ListenerInterface {
static void DestroyListener(Server* /*server*/, void* arg,
grpc_closure* destroy_done);
// The interface required by RefCountedPtr<> has been manually implemented
// 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_;
Server* const server_ = nullptr;
grpc_tcp_server* tcp_server_ = nullptr;
grpc_resolved_address resolved_address_;
Chttp2ServerArgsModifier const args_modifier_;
ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr;
@ -284,6 +275,10 @@ class Chttp2ServerListener : public Server::ListenerInterface {
RefCountedPtr<channelz::ListenSocketNode> channelz_listen_socket_;
MemoryQuotaRefPtr memory_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_;
};
//
@ -380,13 +375,17 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
handshake_mgr_(MakeRefCounted<HandshakeManager>()),
deadline_(GetConnectionDeadline(args)),
interested_parties_(grpc_pollset_set_create()) {
grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_);
if (accepting_pollset != nullptr) {
grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_);
}
CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get());
}
Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() {
grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_);
if (accepting_pollset_ != nullptr) {
grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_);
}
grpc_pollset_set_destroy(interested_parties_);
gpr_free(acceptor_);
}
@ -708,83 +707,82 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() {
grpc_error_handle Chttp2ServerListener::Create(
Server* server, grpc_resolved_address* addr, const ChannelArgs& args,
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.
listener = new Chttp2ServerListener(server, args, args_modifier);
error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_,
grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
OnAccept, listener, &listener->tcp_server_);
// Create Chttp2ServerListener.
OrphanablePtr<Chttp2ServerListener> listener =
MakeOrphanable<Chttp2ServerListener>(server, args, args_modifier,
server->config_fetcher());
// The tcp_server will be unreffed when the listener is orphaned, which could
// be at the end of this function if the listener was not added to the
// 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 (listener->config_fetcher_ != nullptr) {
listener->resolved_address_ = *addr;
// TODO(yashykt): Consider binding so as to be able to return the port
// number.
} else {
error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num);
if (!error.ok()) return error;
if (server->config_fetcher() != nullptr) {
listener->resolved_address_ = *addr;
// TODO(yashykt): Consider binding so as to be able to return the port
// number.
} else {
error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num);
if (!error.ok()) return error;
}
// Create channelz node.
if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ)
.value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) {
auto string_address = grpc_sockaddr_to_uri(addr);
if (!string_address.ok()) {
return GRPC_ERROR_CREATE(string_address.status().ToString());
}
listener->channelz_listen_socket_ =
MakeRefCounted<channelz::ListenSocketNode>(
*string_address,
absl::StrCat("chttp2 listener ", *string_address));
}
// Register with the server only upon success
server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
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;
}
}
// Create channelz node.
if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ)
.value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) {
auto string_address = grpc_sockaddr_to_uri(addr);
if (!string_address.ok()) {
return GRPC_ERROR_CREATE(string_address.status().ToString());
}
listener->channelz_listen_socket_ =
MakeRefCounted<channelz::ListenSocketNode>(
*string_address, absl::StrCat("chttp2 listener ", *string_address));
}
return error;
// Register with the server only upon success
server->AddListener(std::move(listener));
return absl::OkStatus();
}
grpc_error_handle Chttp2ServerListener::CreateWithAcceptor(
Server* server, const char* name, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier) {
Chttp2ServerListener* listener =
new Chttp2ServerListener(server, args, args_modifier);
auto listener = MakeOrphanable<Chttp2ServerListener>(
server, args, args_modifier, server->config_fetcher());
grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_,
grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
OnAccept, listener, &listener->tcp_server_);
if (!error.ok()) {
delete listener;
return error;
}
&listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args),
OnAccept, listener.get(), &listener->tcp_server_);
if (!error.ok()) return error;
// TODO(yangg) channelz
TcpServerFdHandler** arg_val = args.GetPointer<TcpServerFdHandler*>(name);
*arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_);
server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
server->AddListener(std::move(listener));
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(
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),
args_modifier_(args_modifier),
args_(args),
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 =
args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS);
if (max_allowed_incoming_connections.has_value()) {
@ -799,6 +797,9 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
ExecCtx::Get()->Flush();
if (passive_listener_ != nullptr) {
passive_listener_->ListenerDestroyed();
}
if (on_destroy_done_ != nullptr) {
ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus());
ExecCtx::Get()->Flush();
@ -808,10 +809,11 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Server callback: start listening on our ports
void Chttp2ServerListener::Start(
Server* /*server*/, const std::vector<grpc_pollset*>* /* pollsets */) {
if (server_->config_fetcher() != nullptr) {
auto watcher = std::make_unique<ConfigFetcherWatcher>(Ref());
if (config_fetcher_ != nullptr) {
auto watcher = std::make_unique<ConfigFetcherWatcher>(
RefAsSubclass<Chttp2ServerListener>());
config_fetcher_watcher_ = watcher.get();
server_->config_fetcher()->StartWatch(
config_fetcher_->StartWatch(
grpc_sockaddr_to_string(&resolved_address_, false).value(),
std::move(watcher));
} else {
@ -825,7 +827,9 @@ void Chttp2ServerListener::Start(
}
void Chttp2ServerListener::StartListening() {
grpc_tcp_server_start(tcp_server_, &server_->pollsets());
if (tcp_server_ != nullptr) {
grpc_tcp_server_start(tcp_server_, &server_->pollsets());
}
}
void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) {
@ -833,6 +837,12 @@ void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* 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,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
@ -857,7 +867,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
endpoint_cleanup(error);
return;
}
if (self->server_->config_fetcher() != nullptr) {
if (self->config_fetcher_ != nullptr) {
if (connection_manager == nullptr) {
grpc_error_handle error = GRPC_ERROR_CREATE(
"No ConnectionManager configured. Closing connection.");
@ -898,7 +908,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
// heap-use-after-free issues where `Ref()` is invoked when the ref of
// tcp_server_ has already reached 0. (Ref() implementation of
// Chttp2ServerListener is grpc_tcp_server_ref().)
listener_ref = self->Ref();
listener_ref = self->RefAsSubclass<Chttp2ServerListener>();
self->connections_.emplace(connection.get(), std::move(connection));
}
}
@ -913,7 +923,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete(
void* arg, grpc_error_handle /*error*/) {
Chttp2ServerListener* self = static_cast<Chttp2ServerListener*>(arg);
self->channelz_listen_socket_.reset();
delete self;
self->Unref();
}
// Server callback: destroy the tcp listener (so we don't generate further
@ -922,7 +932,8 @@ void Chttp2ServerListener::Orphan() {
// Cancel the watch before shutting down so as to avoid holding a ref to the
// listener in the watcher.
if (config_fetcher_watcher_ != nullptr) {
server_->config_fetcher()->CancelWatch(config_fetcher_watcher_);
GPR_ASSERT(config_fetcher_ != nullptr);
config_fetcher_->CancelWatch(config_fetcher_watcher_);
}
std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>> connections;
grpc_tcp_server* tcp_server;
@ -940,12 +951,14 @@ void Chttp2ServerListener::Orphan() {
}
tcp_server = tcp_server_;
}
grpc_tcp_server_shutdown_listeners(tcp_server);
grpc_tcp_server_unref(tcp_server);
if (tcp_server != nullptr) {
grpc_tcp_server_shutdown_listeners(tcp_server);
grpc_tcp_server_unref(tcp_server);
} else {
Unref();
}
}
} // namespace
//
// Chttp2ServerAddPort()
//
@ -1046,6 +1059,50 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args,
}
} // 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
int grpc_server_add_http2_port(grpc_server* server, const char* addr,
@ -1143,3 +1200,31 @@ void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* 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,6 +21,7 @@
#include <functional>
#include <grpc/passive_listener.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -42,6 +43,38 @@ grpc_error_handle Chttp2ServerAddPort(
Server* server, const char* addr, const ChannelArgs& args,
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
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H

@ -1471,9 +1471,11 @@ static void perform_stream_op_locked(void* stream_op,
frame_hdr[3] = static_cast<uint8_t>(len >> 8);
frame_hdr[4] = static_cast<uint8_t>(len);
s->stats.outgoing.framing_bytes += GRPC_HEADER_SIZE_IN_BYTES;
s->stats.outgoing.data_bytes +=
op_payload->send_message.send_message->Length();
if (grpc_core::IsHttp2StatsFixEnabled()) {
s->stats.outgoing.framing_bytes += GRPC_HEADER_SIZE_IN_BYTES;
s->stats.outgoing.data_bytes +=
op_payload->send_message.send_message->Length();
}
s->next_message_end_offset =
s->flow_controlled_bytes_written +
static_cast<int64_t>(s->flow_controlled_buffer.length) +

@ -78,6 +78,9 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
grpc_slice_buffer_move_first_no_ref(inbuf, write_bytes, outbuf);
stats->framing_bytes += header_size;
if (!grpc_core::IsHttp2StatsFixEnabled()) {
stats->data_bytes += write_bytes;
}
}
grpc_core::Poll<grpc_error_handle> grpc_deframe_unprocessed_incoming_frames(

@ -83,7 +83,7 @@ class InprocServerTransport final : public RefCounted<InprocServerTransport>,
"inproc transport disconnected");
}
absl::StatusOr<CallInitiator> AcceptCall(ClientMetadata& md) {
absl::StatusOr<CallInitiator> AcceptCall(ClientMetadataHandle md) {
switch (state_.load(std::memory_order_acquire)) {
case ConnectionState::kInitial:
return absl::InternalError(
@ -93,7 +93,7 @@ class InprocServerTransport final : public RefCounted<InprocServerTransport>,
case ConnectionState::kReady:
break;
}
return acceptor_->CreateCall(md, acceptor_->CreateArena());
return acceptor_->CreateCall(std::move(md), acceptor_->CreateArena());
}
private:
@ -116,10 +116,10 @@ class InprocClientTransport final : public Transport, public ClientTransport {
TrySeq(call_handler.PullClientInitialMetadata(),
[server_transport = server_transport_,
call_handler](ClientMetadataHandle md) {
auto call_initiator = server_transport->AcceptCall(*md);
auto call_initiator =
server_transport->AcceptCall(std::move(md));
if (!call_initiator.ok()) return call_initiator.status();
ForwardCall(call_handler, std::move(*call_initiator),
std::move(md));
ForwardCall(call_handler, std::move(*call_initiator));
return absl::OkStatus();
}));
}

@ -38,6 +38,7 @@
#include "absl/types/optional.h"
#include "absl/types/variant.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/slice.h>

@ -95,43 +95,37 @@ const grpc_channel_filter* PromiseTracingFilterFor(
},
/* init_call: */
[](grpc_channel_element* elem, CallSpineInterface* call) {
auto* c = DownCast<PipeBasedCallSpine*>(call);
auto* source_filter =
static_cast<const DerivedFilter*>(elem->filter)->filter;
call->client_initial_metadata().receiver.InterceptAndMap(
c->client_initial_metadata().receiver.InterceptAndMap(
[source_filter](ClientMetadataHandle md) {
gpr_log(GPR_DEBUG, "%s[%s] OnClientInitialMetadata: %s",
GetContext<Activity>()->DebugTag().c_str(),
source_filter->name, md->DebugString().c_str());
return md;
});
call->client_to_server_messages().receiver.InterceptAndMap(
c->client_to_server_messages().receiver.InterceptAndMap(
[source_filter](MessageHandle msg) {
gpr_log(GPR_DEBUG, "%s[%s] OnClientToServerMessage: %s",
GetContext<Activity>()->DebugTag().c_str(),
source_filter->name, msg->DebugString().c_str());
return msg;
});
call->server_initial_metadata().sender.InterceptAndMap(
c->server_initial_metadata().sender.InterceptAndMap(
[source_filter](ServerMetadataHandle md) {
gpr_log(GPR_DEBUG, "%s[%s] OnServerInitialMetadata: %s",
GetContext<Activity>()->DebugTag().c_str(),
source_filter->name, md->DebugString().c_str());
return md;
});
call->server_to_client_messages().sender.InterceptAndMap(
c->server_to_client_messages().sender.InterceptAndMap(
[source_filter](MessageHandle msg) {
gpr_log(GPR_DEBUG, "%s[%s] OnServerToClientMessage: %s",
GetContext<Activity>()->DebugTag().c_str(),
source_filter->name, msg->DebugString().c_str());
return msg;
});
call->server_trailing_metadata().sender.InterceptAndMap(
[source_filter](ServerMetadataHandle md) {
gpr_log(GPR_DEBUG, "%s[%s] OnServerTrailingMetadata: %s",
GetContext<Activity>()->DebugTag().c_str(),
source_filter->name, md->DebugString().c_str());
return md;
});
},
grpc_channel_next_op,
/* sizeof_call_data: */ 0,

@ -463,8 +463,7 @@ ArenaPromise<ServerMetadataHandle> MakeClientCallPromise(Transport* transport,
[](absl::Status) {});
// Start a promise to receive server initial metadata and then forward it up
// through the receiving pipe.
auto server_initial_metadata =
GetContext<Arena>()->MakePooled<ServerMetadata>();
auto server_initial_metadata = Arena::MakePooled<ServerMetadata>();
party->Spawn(
"recv_initial_metadata",
TrySeq(GetContext<BatchBuilder>()->ReceiveServerInitialMetadata(
@ -501,27 +500,25 @@ ArenaPromise<ServerMetadataHandle> MakeClientCallPromise(Transport* transport,
// Create a promise that will receive server trailing metadata.
// If this fails, we massage the error into metadata that we can report
// upwards.
auto server_trailing_metadata =
GetContext<Arena>()->MakePooled<ServerMetadata>();
auto recv_trailing_metadata =
Map(GetContext<BatchBuilder>()->ReceiveServerTrailingMetadata(
stream->batch_target()),
[](absl::StatusOr<ServerMetadataHandle> status) mutable {
if (!status.ok()) {
auto server_trailing_metadata =
GetContext<Arena>()->MakePooled<ServerMetadata>();
grpc_status_code status_code = GRPC_STATUS_UNKNOWN;
std::string message;
grpc_error_get_status(status.status(), Timestamp::InfFuture(),
&status_code, &message, nullptr, nullptr);
server_trailing_metadata->Set(GrpcStatusMetadata(), status_code);
server_trailing_metadata->Set(GrpcMessageMetadata(),
Slice::FromCopiedString(message));
return server_trailing_metadata;
} else {
return std::move(*status);
}
});
auto server_trailing_metadata = Arena::MakePooled<ServerMetadata>();
auto recv_trailing_metadata = Map(
GetContext<BatchBuilder>()->ReceiveServerTrailingMetadata(
stream->batch_target()),
[](absl::StatusOr<ServerMetadataHandle> status) mutable {
if (!status.ok()) {
auto server_trailing_metadata = Arena::MakePooled<ServerMetadata>();
grpc_status_code status_code = GRPC_STATUS_UNKNOWN;
std::string message;
grpc_error_get_status(status.status(), Timestamp::InfFuture(),
&status_code, &message, nullptr, nullptr);
server_trailing_metadata->Set(GrpcStatusMetadata(), status_code);
server_trailing_metadata->Set(GrpcMessageMetadata(),
Slice::FromCopiedString(message));
return server_trailing_metadata;
} else {
return std::move(*status);
}
});
// Finally the main call promise.
// Concurrently: send initial metadata and receive messages, until BOTH
// complete (or one fails).
@ -784,8 +781,7 @@ ArenaPromise<ServerMetadataHandle> MakeServerCallPromise(
if (status.ok()) {
trailing_metadata = std::move(*status);
} else {
trailing_metadata =
GetContext<Arena>()->MakePooled<ClientMetadata>();
trailing_metadata = Arena::MakePooled<ClientMetadata>();
grpc_status_code status_code = GRPC_STATUS_UNKNOWN;
std::string message;
grpc_error_get_status(status.status(), Timestamp::InfFuture(),
@ -888,18 +884,7 @@ ArenaPromise<ServerMetadataHandle> MakeClientTransportCallPromise(
Transport* transport, CallArgs call_args, NextPromiseFactory) {
auto spine = GetContext<CallContext>()->MakeCallSpine(std::move(call_args));
transport->client_transport()->StartCall(CallHandler{spine});
return Map(spine->server_trailing_metadata().receiver.Next(),
[](NextResult<ServerMetadataHandle> r) {
if (r.has_value()) {
auto md = std::move(r.value());
md->Set(GrpcStatusFromWire(), true);
return md;
}
auto m = GetContext<Arena>()->MakePooled<ServerMetadata>();
m->Set(GrpcStatusMetadata(), GRPC_STATUS_CANCELLED);
m->Set(GrpcCallWasCancelled(), true);
return m;
});
return spine->PullServerTrailingMetadata();
}
const grpc_channel_filter kClientPromiseBasedTransportFilter =

@ -106,7 +106,7 @@ BaseCallData::BaseCallData(
? arena_->New<ReceiveMessage>(this, make_recv_interceptor())
: nullptr),
event_engine_(
static_cast<ChannelFilter*>(elem->channel_data)
ChannelFilterFromElem(elem)
->hack_until_per_channel_stack_event_engines_land_get_event_engine()) {
}
@ -508,7 +508,7 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher,
case State::kGotBatch:
if (allow_push_to_pipe) {
state_ = State::kPushedToPipe;
auto message = GetContext<Arena>()->MakePooled<Message>();
auto message = Arena::MakePooled<Message>();
message->payload()->Swap(batch_->payload->send_message.send_message);
message->mutable_flags() = batch_->payload->send_message.flags;
push_ = interceptor()->Push()->Push(std::move(message));
@ -839,7 +839,7 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher,
} else {
state_ = State::kCompletedWhilePushedToPipe;
}
auto message = GetContext<Arena>()->MakePooled<Message>();
auto message = Arena::MakePooled<Message>();
message->payload()->Swap(&**intercepted_slice_buffer_);
message->mutable_flags() = *intercepted_flags_;
push_ = interceptor()->Push()->Push(std::move(message));
@ -1572,7 +1572,7 @@ void ClientCallData::Cancel(grpc_error_handle error, Flusher* flusher) {
// metadata and return some trailing metadata.
void ClientCallData::StartPromise(Flusher* flusher) {
GPR_ASSERT(send_initial_state_ == SendInitialState::kQueued);
ChannelFilter* filter = static_cast<ChannelFilter*>(elem()->channel_data);
ChannelFilter* filter = promise_filter_detail::ChannelFilterFromElem(elem());
// Construct the promise.
PollContext ctx(this, flusher);
@ -2369,7 +2369,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) {
// Start the promise.
ScopedContext context(this);
// Construct the promise.
ChannelFilter* filter = static_cast<ChannelFilter*>(elem()->channel_data);
ChannelFilter* filter = promise_filter_detail::ChannelFilterFromElem(elem());
FakeActivity(this).Run([this, filter] {
promise_ = filter->MakeCallPromise(
CallArgs{WrapMetadata(recv_initial_metadata_),

@ -534,13 +534,14 @@ inline void InterceptClientToServerMessage(const NoInterceptor*, void*, void*,
template <typename Derived>
inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnClientToServerMessage(*msg);
if (return_md == nullptr) return std::move(msg);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
@ -548,14 +549,15 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnClientToServerMessage(*msg, channel);
if (return_md == nullptr) return std::move(msg);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
@ -563,7 +565,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, channel](MessageHandle msg) {
@ -575,24 +577,26 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
auto r = call->OnClientToServerMessage(std::move(msg), channel);
if (r.ok()) return std::move(*r);
return call_spine->Cancel(ServerMetadataFromStatus(r.status()));
call_spine->PushServerTrailingMetadata(
ServerMetadataFromStatus(r.status()));
return absl::nullopt;
});
}
inline void InterceptClientInitialMetadata(const NoInterceptor*, void*, void*,
CallSpineInterface*) {}
PipeBasedCallSpine*) {}
template <typename Derived>
inline void InterceptClientInitialMetadata(
void (Derived::Call::*fn)(ClientMetadata& md), typename Derived::Call* call,
Derived*, CallSpineInterface* call_spine) {
Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call](ClientMetadataHandle md) {
@ -605,7 +609,7 @@ template <typename Derived>
inline void InterceptClientInitialMetadata(
void (Derived::Call::*fn)(ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call, channel](ClientMetadataHandle md) {
@ -617,14 +621,15 @@ inline void InterceptClientInitialMetadata(
template <typename Derived>
inline void InterceptClientInitialMetadata(
ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine,
call](ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
auto return_md = call->OnClientInitialMetadata(*md);
if (return_md == nullptr) return std::move(md);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
@ -633,28 +638,31 @@ inline void InterceptClientInitialMetadata(
ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md,
Derived* channel),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine, call, channel](
ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
auto return_md = call->OnClientInitialMetadata(*md, channel);
if (return_md == nullptr) return std::move(md);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
template <typename Derived>
inline void InterceptClientInitialMetadata(
absl::Status (Derived::Call::*fn)(ClientMetadata& md),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine,
call](ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
auto status = call->OnClientInitialMetadata(*md);
if (status.ok()) return std::move(md);
return call_spine->Cancel(ServerMetadataFromStatus(status));
call_spine->PushServerTrailingMetadata(
ServerMetadataFromStatus(status));
return absl::nullopt;
});
}
@ -662,14 +670,16 @@ template <typename Derived>
inline void InterceptClientInitialMetadata(
absl::Status (Derived::Call::*fn)(ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine, call, channel](
ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
auto status = call->OnClientInitialMetadata(*md, channel);
if (status.ok()) return std::move(md);
return call_spine->Cancel(ServerMetadataFromStatus(status));
call_spine->PushServerTrailingMetadata(
ServerMetadataFromStatus(status));
return absl::nullopt;
});
}
@ -681,7 +691,7 @@ absl::void_t<decltype(StatusCast<ServerMetadataHandle>(
InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)(
ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(promise_factory == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call, call_spine, channel](ClientMetadataHandle md) {
@ -691,8 +701,9 @@ InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)(
call_spine](PromiseResult<Promise> status) mutable
-> absl::optional<ClientMetadataHandle> {
if (IsStatusOk(status)) return std::move(md);
return call_spine->Cancel(
call_spine->PushServerTrailingMetadata(
StatusCast<ServerMetadataHandle>(std::move(status)));
return absl::nullopt;
});
});
}
@ -766,7 +777,7 @@ inline void InterceptServerInitialMetadata(const NoInterceptor*, void*, void*,
template <typename Derived>
inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&), typename Derived::Call* call,
Derived*, CallSpineInterface* call_spine) {
Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call](ServerMetadataHandle md) {
@ -778,14 +789,16 @@ inline void InterceptServerInitialMetadata(
template <typename Derived>
inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, call_spine](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
auto status = call->OnServerInitialMetadata(*md);
if (status.ok()) return std::move(md);
return call_spine->Cancel(ServerMetadataFromStatus(status));
call_spine->PushServerTrailingMetadata(
ServerMetadataFromStatus(status));
return absl::nullopt;
});
}
@ -793,7 +806,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, channel](ServerMetadataHandle md) {
@ -806,14 +819,16 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, call_spine, channel](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
auto status = call->OnServerInitialMetadata(*md, channel);
if (status.ok()) return std::move(md);
return call_spine->Cancel(ServerMetadataFromStatus(status));
call_spine->PullServerTrailingMetadata(
ServerMetadataFromStatus(status));
return absl::nullopt;
});
}
@ -885,13 +900,14 @@ inline void InterceptServerToClientMessage(const NoInterceptor*, void*, void*,
template <typename Derived>
inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnServerToClientMessage(*msg);
if (return_md == nullptr) return std::move(msg);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
@ -899,14 +915,15 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnServerToClientMessage(*msg, channel);
if (return_md == nullptr) return std::move(msg);
return call_spine->Cancel(std::move(return_md));
call_spine->PushServerTrailingMetadata(std::move(return_md));
return absl::nullopt;
});
}
@ -914,7 +931,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, channel](MessageHandle msg) {
@ -926,14 +943,16 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
auto r = call->OnServerToClientMessage(std::move(msg), channel);
if (r.ok()) return std::move(*r);
return call_spine->Cancel(ServerMetadataFromStatus(r.status()));
call_spine->PushServerTrailingMetadata(
ServerMetadataFromStatus(r.status()));
return absl::nullopt;
});
}
@ -942,40 +961,25 @@ inline void InterceptServerTrailingMetadata(const NoInterceptor*, void*, void*,
template <typename Derived>
inline void InterceptServerTrailingMetadata(
void (Derived::Call::*fn)(ServerMetadata&), typename Derived::Call* call,
Derived*, CallSpineInterface* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
call_spine->server_trailing_metadata().sender.InterceptAndMap(
[call](ServerMetadataHandle md) {
call->OnServerTrailingMetadata(*md);
return md;
});
void (Derived::Call::*)(ServerMetadata&), typename Derived::Call*, Derived*,
PipeBasedCallSpine*) {
gpr_log(GPR_ERROR,
"InterceptServerTrailingMetadata not available for call v2.5");
}
template <typename Derived>
inline void InterceptServerTrailingMetadata(
void (Derived::Call::*fn)(ServerMetadata&, Derived*),
typename Derived::Call* call, Derived* channel,
CallSpineInterface* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
call_spine->server_trailing_metadata().sender.InterceptAndMap(
[call, channel](ServerMetadataHandle md) {
call->OnServerTrailingMetadata(*md, channel);
return md;
});
void (Derived::Call::*)(ServerMetadata&, Derived*), typename Derived::Call*,
Derived*, PipeBasedCallSpine*) {
gpr_log(GPR_ERROR,
"InterceptServerTrailingMetadata not available for call v2.5");
}
template <typename Derived>
inline void InterceptServerTrailingMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&),
typename Derived::Call* call, Derived*, CallSpineInterface* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
call_spine->server_trailing_metadata().sender.InterceptAndMap(
[call](ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
auto status = call->OnServerTrailingMetadata(*md);
if (status.ok()) return std::move(md);
return ServerMetadataFromStatus(status);
});
absl::Status (Derived::Call::*)(ServerMetadata&), typename Derived::Call*,
Derived*, PipeBasedCallSpine*) {
gpr_log(GPR_ERROR,
"InterceptServerTrailingMetadata not available for call v2.5");
}
inline void InterceptFinalize(const NoInterceptor*, void*, void*) {}
@ -1085,23 +1089,20 @@ class ImplementChannelFilter : public ChannelFilter,
GetContext<Arena>()
->ManagedNew<promise_filter_detail::CallWrapper<Derived>>(
static_cast<Derived*>(this));
auto* c = DownCast<PipeBasedCallSpine*>(call_spine);
auto* d = static_cast<Derived*>(this);
promise_filter_detail::InterceptClientInitialMetadata(
&Derived::Call::OnClientInitialMetadata, call,
static_cast<Derived*>(this), call_spine);
&Derived::Call::OnClientInitialMetadata, call, d, c);
promise_filter_detail::InterceptClientToServerMessage(
&Derived::Call::OnClientToServerMessage, call,
static_cast<Derived*>(this), call_spine);
&Derived::Call::OnClientToServerMessage, call, d, c);
promise_filter_detail::InterceptServerInitialMetadata(
&Derived::Call::OnServerInitialMetadata, call,
static_cast<Derived*>(this), call_spine);
&Derived::Call::OnServerInitialMetadata, call, d, c);
promise_filter_detail::InterceptServerToClientMessage(
&Derived::Call::OnServerToClientMessage, call,
static_cast<Derived*>(this), call_spine);
&Derived::Call::OnServerToClientMessage, call, d, c);
promise_filter_detail::InterceptServerTrailingMetadata(
&Derived::Call::OnServerTrailingMetadata, call,
static_cast<Derived*>(this), call_spine);
promise_filter_detail::InterceptFinalize(&Derived::Call::OnFinalize,
static_cast<Derived*>(this), call);
&Derived::Call::OnServerTrailingMetadata, call, d, c);
promise_filter_detail::InterceptFinalize(&Derived::Call::OnFinalize, d,
call);
}
// Polyfill for the original promise scheme.
@ -1840,6 +1841,15 @@ struct BaseCallDataMethods {
}
};
// The type of object returned by a filter's Create method.
template <typename T>
using CreatedType = typename decltype(T::Create(ChannelArgs(), {}))::value_type;
template <typename GrpcChannelOrCallElement>
inline ChannelFilter* ChannelFilterFromElem(GrpcChannelOrCallElement* elem) {
return *static_cast<ChannelFilter**>(elem->channel_data);
}
template <typename CallData, uint8_t kFlags>
struct CallDataFilterWithFlagsMethods {
static absl::Status InitCallElem(grpc_call_element* elem,
@ -1864,32 +1874,25 @@ struct ChannelFilterMethods {
static ArenaPromise<ServerMetadataHandle> MakeCallPromise(
grpc_channel_element* elem, CallArgs call_args,
NextPromiseFactory next_promise_factory) {
return static_cast<ChannelFilter*>(elem->channel_data)
->MakeCallPromise(std::move(call_args),
std::move(next_promise_factory));
return ChannelFilterFromElem(elem)->MakeCallPromise(
std::move(call_args), std::move(next_promise_factory));
}
static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {
if (!static_cast<ChannelFilter*>(elem->channel_data)
->StartTransportOp(op)) {
if (!ChannelFilterFromElem(elem)->StartTransportOp(op)) {
grpc_channel_next_op(elem, op);
}
}
static void PostInitChannelElem(grpc_channel_stack*,
grpc_channel_element* elem) {
static_cast<ChannelFilter*>(elem->channel_data)->PostInit();
}
static void DestroyChannelElem(grpc_channel_element* elem) {
static_cast<ChannelFilter*>(elem->channel_data)->~ChannelFilter();
ChannelFilterFromElem(elem)->PostInit();
}
static void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* info) {
if (!static_cast<ChannelFilter*>(elem->channel_data)
->GetChannelInfo(info)) {
if (!ChannelFilterFromElem(elem)->GetChannelInfo(info)) {
grpc_channel_next_get_info(elem, info);
}
}
@ -1903,15 +1906,16 @@ struct ChannelFilterWithFlagsMethods {
auto status = F::Create(args->channel_args,
ChannelFilter::Args(args->channel_stack, elem));
if (!status.ok()) {
static_assert(
sizeof(promise_filter_detail::InvalidChannelFilter) <= sizeof(F),
"InvalidChannelFilter must fit in F");
new (elem->channel_data) promise_filter_detail::InvalidChannelFilter();
new (elem->channel_data) F*(nullptr);
return absl_status_to_grpc_error(status.status());
}
new (elem->channel_data) F(std::move(*status));
new (elem->channel_data) F*(status->release());
return absl::OkStatus();
}
static void DestroyChannelElem(grpc_channel_element* elem) {
CreatedType<F> channel_elem(DownCast<F*>(ChannelFilterFromElem(elem)));
}
};
} // namespace promise_filter_detail
@ -1957,7 +1961,8 @@ MakePromiseBasedFilter(const char* name) {
// post_init_channel_elem
promise_filter_detail::ChannelFilterMethods::PostInitChannelElem,
// destroy_channel_elem
promise_filter_detail::ChannelFilterMethods::DestroyChannelElem,
promise_filter_detail::ChannelFilterWithFlagsMethods<
F, kFlags>::DestroyChannelElem,
// get_channel_info
promise_filter_detail::ChannelFilterMethods::GetChannelInfo,
// name
@ -2003,7 +2008,8 @@ MakePromiseBasedFilter(const char* name) {
// post_init_channel_elem
promise_filter_detail::ChannelFilterMethods::PostInitChannelElem,
// destroy_channel_elem
promise_filter_detail::ChannelFilterMethods::DestroyChannelElem,
promise_filter_detail::ChannelFilterWithFlagsMethods<
F, kFlags>::DestroyChannelElem,
// get_channel_info
promise_filter_detail::ChannelFilterMethods::GetChannelInfo,
// name
@ -2045,7 +2051,8 @@ MakePromiseBasedFilter(const char* name) {
// post_init_channel_elem
promise_filter_detail::ChannelFilterMethods::PostInitChannelElem,
// destroy_channel_elem
promise_filter_detail::ChannelFilterMethods::DestroyChannelElem,
promise_filter_detail::ChannelFilterWithFlagsMethods<
F, kFlags>::DestroyChannelElem,
// get_channel_info
promise_filter_detail::ChannelFilterMethods::GetChannelInfo,
// name

@ -17,6 +17,7 @@
#include "src/core/lib/channel/server_call_tracer_filter.h"
#include <functional>
#include <memory>
#include <utility>
#include "absl/status/status.h"
@ -49,7 +50,7 @@ class ServerCallTracerFilter
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<ServerCallTracerFilter> Create(
static absl::StatusOr<std::unique_ptr<ServerCallTracerFilter>> Create(
const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/);
class Call {
@ -98,14 +99,16 @@ const grpc_channel_filter ServerCallTracerFilter::kFilter =
kFilterExaminesServerInitialMetadata>(
"server_call_tracer");
absl::StatusOr<ServerCallTracerFilter> ServerCallTracerFilter::Create(
const ChannelArgs& /*args*/, ChannelFilter::Args /*filter_args*/) {
return ServerCallTracerFilter();
absl::StatusOr<std::unique_ptr<ServerCallTracerFilter>>
ServerCallTracerFilter::Create(const ChannelArgs& /*args*/,
ChannelFilter::Args /*filter_args*/) {
return std::make_unique<ServerCallTracerFilter>();
}
} // namespace
void RegisterServerCallTracerFilter(CoreConfiguration::Builder* builder) {
if (IsChaoticGoodEnabled()) return;
builder->channel_init()->RegisterFilter<ServerCallTracerFilter>(
GRPC_SERVER_CHANNEL);
}

@ -112,6 +112,13 @@ class EventEngineSupportsFdExtension {
int fd, const EndpointConfig& config,
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.
/// \a listener_fd - The listening socket fd that accepted the new client
/// connection.

@ -661,7 +661,7 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
const EndpointConfig& config,
MemoryAllocator memory_allocator) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_DEBUG_ASSERT(fd > 0);
GPR_ASSERT(fd > 0);
PosixEventPoller* poller = poller_manager_->Poller();
GPR_DEBUG_ASSERT(poller != nullptr);
EventHandle* handle =
@ -676,6 +676,22 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
#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>>
PosixEventEngine::CreateListener(
Listener::AcceptCallback on_accept,

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

@ -48,6 +48,9 @@ const char* const additional_constraints_event_engine_listener = "{}";
const char* const description_free_large_allocator =
"If set, return all free bytes from a \042big\042 allocator";
const char* const additional_constraints_free_large_allocator = "{}";
const char* const description_http2_stats_fix =
"Fix on HTTP2 outgoing data stats reporting";
const char* const additional_constraints_http2_stats_fix = "{}";
const char* const description_keepalive_fix =
"Allows overriding keepalive_permit_without_calls. Refer "
"https://github.com/grpc/grpc/pull/33428 for more information.";
@ -139,11 +142,6 @@ const char* const description_work_serializer_dispatch =
const char* const additional_constraints_work_serializer_dispatch = "{}";
const uint8_t required_experiments_work_serializer_dispatch[] = {
static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient)};
#ifdef NDEBUG
const bool kDefaultForDebugOnly = false;
#else
const bool kDefaultForDebugOnly = true;
#endif
} // namespace
namespace grpc_core {
@ -152,7 +150,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,
kDefaultForDebugOnly, true},
true, true},
{"call_v3", description_call_v3, additional_constraints_call_v3, nullptr, 0,
false, true},
{"canary_client_privacy", description_canary_client_privacy,
@ -167,6 +165,8 @@ const ExperimentMetadata g_experiment_metadata[] = {
additional_constraints_event_engine_listener, nullptr, 0, false, true},
{"free_large_allocator", description_free_large_allocator,
additional_constraints_free_large_allocator, nullptr, 0, false, true},
{"http2_stats_fix", description_http2_stats_fix,
additional_constraints_http2_stats_fix, nullptr, 0, true, true},
{"keepalive_fix", description_keepalive_fix,
additional_constraints_keepalive_fix, nullptr, 0, false, false},
{"keepalive_server_fix", description_keepalive_server_fix,
@ -206,7 +206,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"tcp_rcv_lowat", description_tcp_rcv_lowat,
additional_constraints_tcp_rcv_lowat, nullptr, 0, false, true},
{"trace_record_callops", description_trace_record_callops,
additional_constraints_trace_record_callops, nullptr, 0, false, true},
additional_constraints_trace_record_callops, nullptr, 0, true, true},
{"unconstrained_max_quota_buffer_size",
description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,
@ -248,6 +248,9 @@ const char* const additional_constraints_event_engine_listener = "{}";
const char* const description_free_large_allocator =
"If set, return all free bytes from a \042big\042 allocator";
const char* const additional_constraints_free_large_allocator = "{}";
const char* const description_http2_stats_fix =
"Fix on HTTP2 outgoing data stats reporting";
const char* const additional_constraints_http2_stats_fix = "{}";
const char* const description_keepalive_fix =
"Allows overriding keepalive_permit_without_calls. Refer "
"https://github.com/grpc/grpc/pull/33428 for more information.";
@ -339,11 +342,6 @@ const char* const description_work_serializer_dispatch =
const char* const additional_constraints_work_serializer_dispatch = "{}";
const uint8_t required_experiments_work_serializer_dispatch[] = {
static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient)};
#ifdef NDEBUG
const bool kDefaultForDebugOnly = false;
#else
const bool kDefaultForDebugOnly = true;
#endif
} // namespace
namespace grpc_core {
@ -352,7 +350,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,
kDefaultForDebugOnly, true},
true, true},
{"call_v3", description_call_v3, additional_constraints_call_v3, nullptr, 0,
false, true},
{"canary_client_privacy", description_canary_client_privacy,
@ -367,6 +365,8 @@ const ExperimentMetadata g_experiment_metadata[] = {
additional_constraints_event_engine_listener, nullptr, 0, true, true},
{"free_large_allocator", description_free_large_allocator,
additional_constraints_free_large_allocator, nullptr, 0, false, true},
{"http2_stats_fix", description_http2_stats_fix,
additional_constraints_http2_stats_fix, nullptr, 0, true, true},
{"keepalive_fix", description_keepalive_fix,
additional_constraints_keepalive_fix, nullptr, 0, false, false},
{"keepalive_server_fix", description_keepalive_server_fix,
@ -406,7 +406,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"tcp_rcv_lowat", description_tcp_rcv_lowat,
additional_constraints_tcp_rcv_lowat, nullptr, 0, false, true},
{"trace_record_callops", description_trace_record_callops,
additional_constraints_trace_record_callops, nullptr, 0, false, true},
additional_constraints_trace_record_callops, nullptr, 0, true, true},
{"unconstrained_max_quota_buffer_size",
description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,
@ -448,6 +448,9 @@ const char* const additional_constraints_event_engine_listener = "{}";
const char* const description_free_large_allocator =
"If set, return all free bytes from a \042big\042 allocator";
const char* const additional_constraints_free_large_allocator = "{}";
const char* const description_http2_stats_fix =
"Fix on HTTP2 outgoing data stats reporting";
const char* const additional_constraints_http2_stats_fix = "{}";
const char* const description_keepalive_fix =
"Allows overriding keepalive_permit_without_calls. Refer "
"https://github.com/grpc/grpc/pull/33428 for more information.";
@ -539,11 +542,6 @@ const char* const description_work_serializer_dispatch =
const char* const additional_constraints_work_serializer_dispatch = "{}";
const uint8_t required_experiments_work_serializer_dispatch[] = {
static_cast<uint8_t>(grpc_core::kExperimentIdEventEngineClient)};
#ifdef NDEBUG
const bool kDefaultForDebugOnly = false;
#else
const bool kDefaultForDebugOnly = true;
#endif
} // namespace
namespace grpc_core {
@ -552,7 +550,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,
kDefaultForDebugOnly, true},
true, true},
{"call_v3", description_call_v3, additional_constraints_call_v3, nullptr, 0,
false, true},
{"canary_client_privacy", description_canary_client_privacy,
@ -567,6 +565,8 @@ const ExperimentMetadata g_experiment_metadata[] = {
additional_constraints_event_engine_listener, nullptr, 0, true, true},
{"free_large_allocator", description_free_large_allocator,
additional_constraints_free_large_allocator, nullptr, 0, false, true},
{"http2_stats_fix", description_http2_stats_fix,
additional_constraints_http2_stats_fix, nullptr, 0, true, true},
{"keepalive_fix", description_keepalive_fix,
additional_constraints_keepalive_fix, nullptr, 0, false, false},
{"keepalive_server_fix", description_keepalive_server_fix,
@ -606,7 +606,7 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"tcp_rcv_lowat", description_tcp_rcv_lowat,
additional_constraints_tcp_rcv_lowat, nullptr, 0, false, true},
{"trace_record_callops", description_trace_record_callops,
additional_constraints_trace_record_callops, nullptr, 0, false, true},
additional_constraints_trace_record_callops, nullptr, 0, true, true},
{"unconstrained_max_quota_buffer_size",
description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,

@ -57,16 +57,8 @@ namespace grpc_core {
#ifdef GRPC_EXPERIMENTS_ARE_FINAL
#if defined(GRPC_CFSTREAM)
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
inline bool IsCallStatusOverrideOnCancellationEnabled() {
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; }
inline bool IsCallV3Enabled() { return false; }
inline bool IsCanaryClientPrivacyEnabled() { return false; }
inline bool IsClientPrivacyEnabled() { return false; }
@ -74,6 +66,8 @@ inline bool IsEventEngineClientEnabled() { return false; }
inline bool IsEventEngineDnsEnabled() { return false; }
inline bool IsEventEngineListenerEnabled() { return false; }
inline bool IsFreeLargeAllocatorEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX
inline bool IsHttp2StatsFixEnabled() { return true; }
inline bool IsKeepaliveFixEnabled() { return false; }
inline bool IsKeepaliveServerFixEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT
@ -93,23 +87,16 @@ inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
inline bool IsServerPrivacyEnabled() { return false; }
inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS
inline bool IsTraceRecordCallopsEnabled() { return true; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; }
#elif defined(GPR_WINDOWS)
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
inline bool IsCallStatusOverrideOnCancellationEnabled() {
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; }
inline bool IsCallV3Enabled() { return false; }
inline bool IsCanaryClientPrivacyEnabled() { return false; }
inline bool IsClientPrivacyEnabled() { return false; }
@ -118,6 +105,8 @@ inline bool IsEventEngineDnsEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_LISTENER
inline bool IsEventEngineListenerEnabled() { return true; }
inline bool IsFreeLargeAllocatorEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX
inline bool IsHttp2StatsFixEnabled() { return true; }
inline bool IsKeepaliveFixEnabled() { return false; }
inline bool IsKeepaliveServerFixEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT
@ -137,23 +126,16 @@ inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
inline bool IsServerPrivacyEnabled() { return false; }
inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS
inline bool IsTraceRecordCallopsEnabled() { return true; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; }
#else
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
inline bool IsCallStatusOverrideOnCancellationEnabled() {
#ifdef NDEBUG
return false;
#else
return true;
#endif
}
inline bool IsCallStatusOverrideOnCancellationEnabled() { return true; }
inline bool IsCallV3Enabled() { return false; }
inline bool IsCanaryClientPrivacyEnabled() { return false; }
inline bool IsClientPrivacyEnabled() { return false; }
@ -163,6 +145,8 @@ inline bool IsEventEngineDnsEnabled() { return true; }
#define GRPC_EXPERIMENT_IS_INCLUDED_EVENT_ENGINE_LISTENER
inline bool IsEventEngineListenerEnabled() { return true; }
inline bool IsFreeLargeAllocatorEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX
inline bool IsHttp2StatsFixEnabled() { return true; }
inline bool IsKeepaliveFixEnabled() { return false; }
inline bool IsKeepaliveServerFixEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_MONITORING_EXPERIMENT
@ -182,7 +166,8 @@ inline bool IsScheduleCancellationOverWriteEnabled() { return false; }
inline bool IsServerPrivacyEnabled() { return false; }
inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_TRACE_RECORD_CALLOPS
inline bool IsTraceRecordCallopsEnabled() { return true; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
@ -200,6 +185,7 @@ enum ExperimentIds {
kExperimentIdEventEngineDns,
kExperimentIdEventEngineListener,
kExperimentIdFreeLargeAllocator,
kExperimentIdHttp2StatsFix,
kExperimentIdKeepaliveFix,
kExperimentIdKeepaliveServerFix,
kExperimentIdMonitoringExperiment,
@ -254,6 +240,10 @@ inline bool IsEventEngineListenerEnabled() {
inline bool IsFreeLargeAllocatorEnabled() {
return IsExperimentEnabled(kExperimentIdFreeLargeAllocator);
}
#define GRPC_EXPERIMENT_IS_INCLUDED_HTTP2_STATS_FIX
inline bool IsHttp2StatsFixEnabled() {
return IsExperimentEnabled(kExperimentIdHttp2StatsFix);
}
#define GRPC_EXPERIMENT_IS_INCLUDED_KEEPALIVE_FIX
inline bool IsKeepaliveFixEnabled() {
return IsExperimentEnabled(kExperimentIdKeepaliveFix);

@ -44,7 +44,7 @@
description:
Avoid overriding call status of successfully finished calls if it races with
cancellation.
expiry: 2024/04/01
expiry: 2024/08/01
owner: vigneshbabu@google.com
test_tags: []
- name: call_v3
@ -98,6 +98,12 @@
expiry: 2024/08/01
owner: alishananda@google.com
test_tags: [resource_quota_test]
- name: http2_stats_fix
description:
Fix on HTTP2 outgoing data stats reporting
expiry: 2024/09/30
owner: yashkt@google.com
test_tags: []
- name: keepalive_fix
description:
Allows overriding keepalive_permit_without_calls.
@ -180,7 +186,7 @@
test_tags: [flow_control_test]
- name: schedule_cancellation_over_write
description: Allow cancellation op to be scheduled over a write
expiry: 2024/04/01
expiry: 2024/08/01
owner: vigneshbabu@google.com
test_tags: []
- name: server_privacy
@ -206,7 +212,7 @@
test_tags: ["endpoint_test", "flow_control_test"]
- name: trace_record_callops
description: Enables tracing of call batch initiation and completion.
expiry: 2024/04/01
expiry: 2024/08/01
owner: vigneshbabu@google.com
test_tags: []
- name: unconstrained_max_quota_buffer_size

@ -41,7 +41,7 @@
# Supported platforms: ios, windows, posix
- name: call_status_override_on_cancellation
default: debug
default: true
- name: call_v3
default: false
- name: canary_client_privacy
@ -109,7 +109,7 @@
- name: tcp_rcv_lowat
default: false
- name: trace_record_callops
default: false
default: true
- name: unconstrained_max_quota_buffer_size
default: false
- name: work_serializer_clears_time_cache

@ -25,6 +25,7 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>

@ -56,13 +56,52 @@ struct Done<StatusFlag> {
static StatusFlag Make(bool cancelled) { return StatusFlag(!cancelled); }
};
template <typename T, typename SfinaeVoid = void>
struct NextValueTraits;
enum class NextValueType {
kValue,
kEndOfStream,
kError,
};
template <typename T>
struct NextValueTraits<T, absl::void_t<typename T::value_type>> {
using Value = typename T::value_type;
static NextValueType Type(const T& t) {
if (t.has_value()) return NextValueType::kValue;
if (t.cancelled()) return NextValueType::kError;
return NextValueType::kEndOfStream;
}
static Value& MutableValue(T& t) { return *t; }
};
template <typename T>
struct NextValueTraits<ValueOrFailure<absl::optional<T>>> {
using Value = T;
static NextValueType Type(const ValueOrFailure<absl::optional<T>>& t) {
if (t.ok()) {
if (t.value().has_value()) return NextValueType::kValue;
return NextValueType::kEndOfStream;
}
return NextValueType::kError;
}
static Value& MutableValue(ValueOrFailure<absl::optional<T>>& t) {
return **t;
}
};
template <typename Reader, typename Action>
class ForEach {
private:
using ReaderNext = decltype(std::declval<Reader>().Next());
using ReaderResult =
typename PollTraits<decltype(std::declval<ReaderNext>()())>::Type;
using ReaderResultValue = typename ReaderResult::value_type;
using ReaderResultValue = typename NextValueTraits<ReaderResult>::Value;
using ActionFactory =
promise_detail::RepeatedPromiseFactory<ReaderResultValue, Action>;
using ActionPromise = typename ActionFactory::Promise;
@ -120,22 +159,37 @@ class ForEach {
Poll<Result> PollReaderNext() {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_DEBUG, "%s PollReaderNext", DebugTag().c_str());
gpr_log(GPR_INFO, "%s PollReaderNext", DebugTag().c_str());
}
auto r = reader_next_();
if (auto* p = r.value_if_ready()) {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_DEBUG, "%s PollReaderNext: got has_value=%s",
DebugTag().c_str(), p->has_value() ? "true" : "false");
}
if (p->has_value()) {
Destruct(&reader_next_);
auto action = action_factory_.Make(std::move(**p));
Construct(&in_action_, std::move(action), std::move(*p));
reading_next_ = false;
return PollAction();
} else {
return Done<Result>::Make(p->cancelled());
switch (NextValueTraits<ReaderResult>::Type(*p)) {
case NextValueType::kValue: {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_INFO, "%s PollReaderNext: got value",
DebugTag().c_str());
}
Destruct(&reader_next_);
auto action = action_factory_.Make(
std::move(NextValueTraits<ReaderResult>::MutableValue(*p)));
Construct(&in_action_, std::move(action), std::move(*p));
reading_next_ = false;
return PollAction();
}
case NextValueType::kEndOfStream: {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_INFO, "%s PollReaderNext: got end of stream",
DebugTag().c_str());
}
return Done<Result>::Make(false);
}
case NextValueType::kError: {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_INFO, "%s PollReaderNext: got error",
DebugTag().c_str());
}
return Done<Result>::Make(true);
}
}
}
return Pending();
@ -143,7 +197,7 @@ class ForEach {
Poll<Result> PollAction() {
if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_DEBUG, "%s PollAction", DebugTag().c_str());
gpr_log(GPR_INFO, "%s PollAction", DebugTag().c_str());
}
auto r = in_action_.promise();
if (auto* p = r.value_if_ready()) {

@ -89,7 +89,7 @@ class NextResult final {
const T& operator*() const;
T& operator*();
// Only valid if !has_value()
bool cancelled() { return cancelled_; }
bool cancelled() const { return cancelled_; }
private:
RefCountedPtr<pipe_detail::Center<T>> center_;

@ -51,14 +51,14 @@ GrpcServerAuthzFilter::GrpcServerAuthzFilter(
per_channel_evaluate_args_(auth_context_.get(), args),
provider_(std::move(provider)) {}
absl::StatusOr<GrpcServerAuthzFilter> GrpcServerAuthzFilter::Create(
const ChannelArgs& args, ChannelFilter::Args) {
absl::StatusOr<std::unique_ptr<GrpcServerAuthzFilter>>
GrpcServerAuthzFilter::Create(const ChannelArgs& args, ChannelFilter::Args) {
auto* auth_context = args.GetObject<grpc_auth_context>();
auto* provider = args.GetObject<grpc_authorization_policy_provider>();
if (provider == nullptr) {
return absl::InvalidArgumentError("Failed to get authorization provider.");
}
return GrpcServerAuthzFilter(
return std::make_unique<GrpcServerAuthzFilter>(
auth_context != nullptr ? auth_context->Ref() : nullptr, args,
provider->Ref());
}

@ -37,8 +37,12 @@ class GrpcServerAuthzFilter final
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<GrpcServerAuthzFilter> Create(const ChannelArgs& args,
ChannelFilter::Args);
static absl::StatusOr<std::unique_ptr<GrpcServerAuthzFilter>> Create(
const ChannelArgs& args, ChannelFilter::Args);
GrpcServerAuthzFilter(
RefCountedPtr<grpc_auth_context> auth_context, const ChannelArgs& args,
RefCountedPtr<grpc_authorization_policy_provider> provider);
class Call {
public:
@ -52,10 +56,6 @@ class GrpcServerAuthzFilter final
};
private:
GrpcServerAuthzFilter(
RefCountedPtr<grpc_auth_context> auth_context, const ChannelArgs& args,
RefCountedPtr<grpc_authorization_policy_provider> provider);
bool IsAuthorized(ClientMetadata& initial_metadata);
RefCountedPtr<grpc_auth_context> auth_context_;

@ -23,6 +23,7 @@
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>

@ -22,6 +22,7 @@
#include <algorithm>
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>

@ -26,6 +26,7 @@
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>

@ -19,6 +19,7 @@
#ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_ALTS_CREDENTIALS_H
#define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_ALTS_CREDENTIALS_H
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>

@ -19,6 +19,7 @@
#ifndef GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_GRPC_ALTS_CREDENTIALS_OPTIONS_H
#define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_ALTS_GRPC_ALTS_CREDENTIALS_OPTIONS_H
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>

@ -19,6 +19,7 @@
#include <string>
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/support/port_platform.h>

@ -23,6 +23,7 @@
#include "absl/strings/string_view.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/json.h>

@ -26,6 +26,7 @@
#include "absl/status/statusor.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/grpc_security_constants.h>

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

Loading…
Cancel
Save