grpc 1.82.0 → 1.83.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +8 -5
  3. data/etc/roots.pem +10400 -3855
  4. data/include/grpc/grpc_audit_logging.h +2 -2
  5. data/include/grpc/grpc_security_constants.h +2 -0
  6. data/include/grpc/impl/channel_arg_names.h +23 -0
  7. data/src/core/call/call_filters.h +19 -3
  8. data/src/core/call/call_spine.h +4 -4
  9. data/src/core/call/client_call.cc +1 -1
  10. data/src/core/call/metadata.cc +7 -2
  11. data/src/core/call/server_call.cc +13 -3
  12. data/src/core/call/server_call.h +5 -3
  13. data/src/core/client_channel/backup_poller.cc +2 -17
  14. data/src/core/client_channel/client_channel.cc +17 -14
  15. data/src/core/client_channel/client_channel.h +3 -1
  16. data/src/core/client_channel/client_channel_filter.cc +11 -13
  17. data/src/core/client_channel/client_channel_service_config.cc +5 -13
  18. data/src/core/client_channel/direct_channel.cc +5 -1
  19. data/src/core/client_channel/direct_channel.h +3 -1
  20. data/src/core/config/experiment_env_var.cc +30 -0
  21. data/src/core/config/experiment_env_var.h +26 -0
  22. data/src/core/credentials/call/regional_access_boundary_fetcher.cc +6 -6
  23. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +14 -2
  24. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.cc +172 -0
  25. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +103 -0
  26. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +3 -2
  27. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +10 -3
  28. data/src/core/credentials/transport/tls/tls_security_connector.cc +14 -2
  29. data/src/core/credentials/transport/xds/xds_credentials.cc +4 -12
  30. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -1
  31. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -13
  32. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +11 -9
  33. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
  34. data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -2
  35. data/src/core/ext/transport/chttp2/transport/frame.cc +58 -1
  36. data/src/core/ext/transport/chttp2/transport/frame.h +13 -1
  37. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -4
  38. data/src/core/ext/transport/chttp2/transport/frame_security.cc +10 -1
  39. data/src/core/ext/transport/chttp2/transport/frame_security.h +2 -1
  40. data/src/core/ext/transport/chttp2/transport/goaway.cc +11 -1
  41. data/src/core/ext/transport/chttp2/transport/goaway.h +17 -1
  42. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -0
  43. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +117 -276
  44. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +44 -17
  45. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +382 -496
  46. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +75 -77
  47. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +1 -1
  48. data/src/core/ext/transport/chttp2/transport/http2_settings.h +30 -11
  49. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +24 -9
  50. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +26 -0
  51. data/src/core/ext/transport/chttp2/transport/http2_transport.h +2 -0
  52. data/src/core/ext/transport/chttp2/transport/internal.h +4 -0
  53. data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
  54. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +1 -1
  55. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +4 -10
  56. data/src/core/ext/transport/chttp2/transport/read_context.h +62 -20
  57. data/src/core/ext/transport/chttp2/transport/security_frame.h +1 -0
  58. data/src/core/ext/transport/chttp2/transport/stream.h +271 -120
  59. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +77 -61
  60. data/src/core/handshaker/security/secure_endpoint.cc +0 -13
  61. data/src/core/lib/channel/promise_based_filter.cc +77 -3
  62. data/src/core/lib/channel/promise_based_filter.h +238 -184
  63. data/src/core/lib/event_engine/extensions/receive_coalescing_extension.h +0 -4
  64. data/src/core/lib/event_engine/extensions/tcp_trace.h +1 -1
  65. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -12
  66. data/src/core/lib/event_engine/shim.cc +2 -16
  67. data/src/core/lib/event_engine/shim.h +0 -4
  68. data/src/core/lib/experiments/experiments.cc +51 -102
  69. data/src/core/lib/experiments/experiments.h +37 -59
  70. data/src/core/lib/iomgr/error.cc +3 -73
  71. data/src/core/lib/iomgr/error.h +8 -6
  72. data/src/core/lib/iomgr/error_cfstream.cc +1 -2
  73. data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -6
  74. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -6
  75. data/src/core/lib/iomgr/tcp_posix.cc +2 -6
  76. data/src/core/lib/security/authorization/audit_logging.cc +2 -2
  77. data/src/core/lib/security/authorization/audit_logging.h +3 -3
  78. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +11 -13
  79. data/src/core/lib/security/authorization/grpc_authorization_engine.h +1 -1
  80. data/src/core/lib/security/authorization/matchers.cc +20 -20
  81. data/src/core/lib/security/authorization/matchers.h +15 -16
  82. data/src/core/lib/security/authorization/rbac_policy.h +1 -1
  83. data/src/core/lib/security/authorization/stdout_logger.cc +3 -3
  84. data/src/core/lib/security/authorization/stdout_logger.h +6 -5
  85. data/src/core/lib/surface/call.cc +0 -8
  86. data/src/core/lib/surface/call.h +2 -0
  87. data/src/core/lib/surface/channel.cc +21 -2
  88. data/src/core/lib/surface/channel.h +14 -6
  89. data/src/core/lib/surface/filter_stack_call.cc +10 -29
  90. data/src/core/lib/surface/legacy_channel.cc +7 -7
  91. data/src/core/lib/surface/legacy_channel.h +3 -1
  92. data/src/core/lib/surface/version.cc +2 -2
  93. data/src/core/lib/transport/bdp_estimator.cc +13 -13
  94. data/src/core/lib/transport/bdp_estimator.h +9 -5
  95. data/src/core/lib/transport/error_utils.cc +26 -138
  96. data/src/core/lib/transport/promise_endpoint.h +2 -4
  97. data/src/core/load_balancing/grpclb/grpclb.cc +2 -1
  98. data/src/core/load_balancing/pick_first/pick_first.cc +33 -2
  99. data/src/core/load_balancing/pick_first/pick_first.h +6 -0
  100. data/src/core/load_balancing/ring_hash/ring_hash.cc +3 -10
  101. data/src/core/load_balancing/rls/rls.cc +2 -1
  102. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +2 -7
  103. data/src/core/load_balancing/xds/cds.cc +80 -56
  104. data/src/core/load_balancing/xds/cds.h +21 -0
  105. data/src/core/mitigation_engine/mitigation.h +53 -0
  106. data/src/core/mitigation_engine/mitigation_provider.h +62 -0
  107. data/src/core/resolver/dns/dns_resolver_plugin.cc +1 -6
  108. data/src/core/resolver/xds/xds_resolver.cc +14 -11
  109. data/src/core/server/server.h +1 -4
  110. data/src/core/server/server_config_selector.h +5 -4
  111. data/src/core/server/server_config_selector_filter.cc +67 -80
  112. data/src/core/server/xds_server_config_fetcher.cc +681 -692
  113. data/src/core/server/xds_server_config_fetcher_legacy.cc +15 -12
  114. data/src/core/telemetry/call_tracer.cc +49 -2
  115. data/src/core/telemetry/call_tracer.h +1 -0
  116. data/src/core/telemetry/tcp_tracer.h +38 -0
  117. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  118. data/src/core/tsi/ssl_telemetry_utils.cc +343 -0
  119. data/src/core/tsi/ssl_telemetry_utils.h +74 -0
  120. data/src/core/tsi/ssl_transport_security.cc +577 -301
  121. data/src/core/tsi/ssl_transport_security.h +22 -6
  122. data/src/core/tsi/ssl_transport_security_utils.cc +2 -0
  123. data/src/core/tsi/transport_security.h +7 -0
  124. data/src/core/util/http_client/httpcli.cc +1 -4
  125. data/src/core/util/http_client/httpcli_security_connector.cc +2 -1
  126. data/src/core/util/status_helper.cc +71 -192
  127. data/src/core/util/status_helper.h +16 -21
  128. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +2 -11
  129. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -7
  130. data/src/core/xds/grpc/xds_cluster_parser.cc +5 -16
  131. data/src/core/xds/grpc/xds_common_types.cc +94 -38
  132. data/src/core/xds/grpc/xds_common_types.h +33 -18
  133. data/src/core/xds/grpc/xds_common_types_parser.cc +168 -100
  134. data/src/core/xds/grpc/xds_common_types_parser.h +18 -1
  135. data/src/core/xds/grpc/xds_endpoint_parser.cc +6 -17
  136. data/src/core/xds/grpc/xds_http_filter_registry.cc +2 -10
  137. data/src/core/xds/grpc/xds_http_rbac_filter.cc +3 -12
  138. data/src/core/xds/grpc/xds_metadata_parser.cc +0 -2
  139. data/src/core/xds/grpc/xds_route_config_parser.cc +7 -11
  140. data/src/core/xds/grpc/xds_routing.cc +113 -82
  141. data/src/core/xds/grpc/xds_routing.h +70 -20
  142. data/src/core/xds/grpc/xds_server_grpc.cc +22 -13
  143. data/src/core/xds/grpc/xds_server_grpc.h +16 -2
  144. data/src/core/xds/grpc/xds_server_grpc_interface.h +10 -0
  145. data/src/core/xds/grpc/xds_transport_grpc.cc +123 -18
  146. data/src/core/xds/grpc/xds_transport_grpc.h +28 -4
  147. data/src/core/xds/xds_client/lrs_client.cc +3 -7
  148. data/src/core/xds/xds_client/xds_bootstrap.cc +4 -16
  149. data/src/core/xds/xds_client/xds_client.cc +2 -15
  150. data/src/core/xds/xds_client/xds_transport.h +3 -0
  151. data/src/ruby/lib/grpc/version.rb +1 -1
  152. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +1 -1
  153. metadata +9 -1
@@ -70,6 +70,8 @@
70
70
  #include "src/core/util/debug_location.h"
71
71
  #include "src/core/util/grpc_check.h"
72
72
  #include "src/core/util/match.h"
73
+ #include "src/core/util/orphanable.h"
74
+ #include "src/core/util/ref_counted_ptr.h"
73
75
  #include "src/core/util/time.h"
74
76
  #include "absl/container/inlined_vector.h"
75
77
  #include "absl/functional/function_ref.h"
@@ -1273,192 +1275,241 @@ class V3InterceptorToV2Bridge : public ChannelFilter, public Interceptor {
1273
1275
  InterActivityLatch<std::optional<ServerMetadataHandle>>
1274
1276
  server_initial_metadata;
1275
1277
  InterActivityPipe<MessageHandle, 1> server_to_client_messages;
1278
+ InterActivityLatch<ServerMetadataHandle> server_trailing_metadata;
1276
1279
  };
1277
1280
  auto* pipe_owner = GetContext<Arena>()->ManagedNew<PipeOwner>();
1281
+ if (IsV2NonOwningWakerImplementationEnabled()) {
1282
+ // We need to start polling the initiator for server trailing
1283
+ // metadata immediately, since the v3 interceptor may generate a
1284
+ // failure before any of the other promises resolve.
1285
+ //
1286
+ // Spawn a promise on the initiator's activity to pull server trailing
1287
+ // metadata and pass it to the v2 activity via an inter-activity latch.
1288
+ initiator.SpawnInfallible(
1289
+ "pull_server_trailing_metadata",
1290
+ [initiator = initiator, pipe_owner]() mutable {
1291
+ return Map(
1292
+ initiator.PullServerTrailingMetadata(),
1293
+ [pipe_owner](ServerMetadataHandle metadata) {
1294
+ pipe_owner->server_trailing_metadata.Set(std::move(metadata));
1295
+ return Empty{};
1296
+ });
1297
+ });
1298
+ }
1278
1299
  // Now return a promise that does all the things.
1279
- return Race(
1280
- // We need to start polling the initiator for server trailing
1281
- // metadata immediately, since the v3 interceptor may generate a
1282
- // failure before any of the other promises resolve.
1283
- initiator.PullServerTrailingMetadata(),
1284
- // This promise does the rest of the things, but it will always
1285
- // return pending, because the promise can't actually finish
1286
- // until the initiator returns trailing metadata above.
1287
- TrySeq(
1288
- state->call_handler_latch.Wait(),
1289
- [initiator = initiator, pipe_owner,
1290
- call_args = std::move(call_args),
1291
- next_promise_factory =
1292
- std::move(next_promise_factory)](CallHandler handler) mutable {
1293
- // Intercept all pipes from v2 API.
1294
- //
1295
- // For client-to-server messages, we do the following:
1296
- // 1. Push the message into the v3 initiator, which sends
1297
- // it to the v3 interceptor. Note that this needs to
1298
- // be done inside of the v3 initiator's activity.
1299
- // 2. Pull the message from the v3 handler, where it will
1300
- // arrive when the v3 interceptor is done with it.
1301
- // Note that this needs to be done inside of the v3
1302
- // handler's activity. We then push the message into
1303
- // an inter-activity pipe to return it to the v2 activity.
1304
- // 3. In the v2 activity, read the message from the
1305
- // inter-activity pipe and send it on to the next
1306
- // filter.
1307
- //
1308
- // Step 2: Spawn a promise to pull messages from the v3
1309
- // handler and push them into an inter-activity pipe to
1310
- // return them to the v2 activity.
1311
- handler.SpawnGuarded(
1312
- "pull_client_to_server_message",
1313
- [handler, pipe_owner]() mutable {
1314
- return ForEach(
1315
- MessagesFrom(handler),
1316
- [pipe_owner](MessageHandle message) {
1317
- return Map(
1318
- pipe_owner->client_to_server_messages.sender.Push(
1319
- std::move(message)),
1320
- [](bool x) { return StatusFlag(x); });
1321
- });
1322
- });
1323
- call_args.client_to_server_messages->InterceptAndMap(
1324
- [initiator, handler,
1325
- pipe_owner](MessageHandle message) mutable {
1326
- // Step 1: Push the message onto the v3 initiator in
1327
- // its activity.
1328
- initiator.SpawnPushMessage(std::move(message));
1329
- // Step 3: Here in the v2 activity, read the message
1330
- // from the inter-activity pipe and return it.
1331
- return Map(
1332
- pipe_owner->client_to_server_messages.receiver.Next(),
1333
- [](InterActivityPipe<MessageHandle, 1>::NextResult
1334
- message) -> std::optional<MessageHandle> {
1335
- if (!message.has_value()) return std::nullopt;
1336
- return std::move(*message);
1337
- });
1338
- });
1339
- // For server initial metadata, we do a similar thing, but
1340
- // in the opposite direction, and using an inter-activity
1341
- // latch instead of a pipe:
1342
- // 1. Push the metadata into the v3 handler, which sends
1343
- // it to the v3 interceptor. Note that this needs to
1344
- // be done inside of the v3 handler's activity.
1345
- // 2. Pull the metadata from the v3 initiator, where it will
1346
- // arrive when the v3 interceptor is done with it.
1347
- // Note that this needs to be done inside of the v3
1348
- // initiator's activity. We then use an inter-activity
1349
- // latch to return the metadata to the v2 activity.
1350
- // 3. In the v2 activity, read the metadata from the
1351
- // inter-activity latch and send it on to the previous
1352
- // filter.
1353
- //
1354
- // Step 2: Spawn a promise to pull the metadata from the v3
1355
- // initiator and use an inter-activity latch to return it to
1356
- // the v2 activity.
1357
- initiator.SpawnGuarded(
1358
- "pull_server_initial_metadata",
1359
- [initiator, pipe_owner]() mutable {
1360
- return TrySeq(
1361
- initiator.PullServerInitialMetadata(),
1362
- [pipe_owner](
1363
- std::optional<ServerMetadataHandle> metadata) {
1364
- pipe_owner->server_initial_metadata.Set(
1365
- std::move(metadata));
1366
- });
1367
- });
1368
- call_args.server_initial_metadata->InterceptAndMap(
1369
- [initiator, handler,
1370
- pipe_owner](ServerMetadataHandle metadata) mutable {
1371
- // Step 1: Push the metadata onto the v3 handler in
1372
- // its activity.
1373
- handler.SpawnPushServerInitialMetadata(std::move(metadata));
1374
- // Step 3: Here in the v2 activity, read from the
1375
- // inter-activity latch and return the metadata.
1376
- return pipe_owner->server_initial_metadata.Wait();
1377
- });
1378
- // We handle server-to-client messages the same as
1379
- // client-to-server messages, except in the opposite
1380
- // direction:
1381
- // 1. Push the message into the v3 handler, which sends
1382
- // it to the v3 interceptor. Note that this needs to
1383
- // be done inside of the v3 handler's activity.
1384
- // 2. Pull the message from the v3 initiator, where it will
1385
- // arrive when the v3 interceptor is done with it.
1386
- // Note that this needs to be done inside of the v3
1387
- // initiator's activity. We then push the message into
1388
- // an inter-activity pipe to return it to the v2 activity.
1389
- // 3. In the v2 activity, read the message from the
1390
- // inter-activity pipe and send it on to the next
1391
- // filter.
1392
- //
1393
- // Step 2: Spawn a promise to pull messages from the v3
1394
- // initiator and push them into an inter-activity pipe to
1395
- // return them to the v2 activity.
1396
- initiator.SpawnGuarded(
1397
- "pull_server_to_client_message",
1398
- [initiator, pipe_owner]() mutable {
1399
- return ForEach(
1400
- MessagesFrom(initiator),
1401
- [pipe_owner](MessageHandle message) {
1402
- return Map(
1403
- pipe_owner->server_to_client_messages.sender.Push(
1404
- std::move(message)),
1405
- [](bool x) { return StatusFlag(x); });
1406
- });
1407
- });
1408
- call_args.server_to_client_messages->InterceptAndMap(
1409
- [initiator, handler,
1410
- pipe_owner](MessageHandle message) mutable {
1411
- // Step 1: Push the message onto the v3 handler in
1412
- // its activity.
1413
- handler.SpawnPushMessage(std::move(message));
1414
- // Step 3: Here in the v2 activity, read from the
1415
- // inter-activity pipe and return the messages.
1416
- return Map(
1417
- pipe_owner->server_to_client_messages.receiver.Next(),
1418
- [](InterActivityPipe<MessageHandle, 1>::NextResult
1419
- message) -> std::optional<MessageHandle> {
1420
- if (!message.has_value()) return std::nullopt;
1421
- return std::move(*message);
1422
- });
1423
- });
1424
- // In the v3 handler's activity, pull client initial metadata.
1425
- // Use an inter-activity latch to get it back to the v2
1426
- // activity.
1427
- handler.SpawnGuarded(
1428
- "pull_client_initial_metadata",
1429
- [handler, pipe_owner]() mutable {
1430
- return TrySeq(handler.PullClientInitialMetadata(),
1431
- [pipe_owner](ClientMetadataHandle metadata) {
1432
- pipe_owner->client_initial_metadata.Set(
1433
- std::move(metadata));
1434
- });
1435
- });
1436
- // A wrapper for next_promise_factory that does the following:
1437
- // - Pulls client initial metadata from the V3 handler via
1438
- // the inter-activity latch and injects it into the next
1439
- // V2 filter via CallArgs.
1440
- // - Polls the next promise to get server trailing metadata
1441
- // from the next V2 filter and feeds it into the V3 handler.
1442
- // Note that this does not actually pull the trailing metadata
1443
- // from the V3 initiator; instead, we do that in a separate
1444
- // promise above. That promise will always complete at the
1445
- // end of the call, so we always return pending here.
1446
- return Seq(
1447
- pipe_owner->client_initial_metadata.Wait(),
1448
- [next_promise_factory = std::move(next_promise_factory),
1449
- call_args = std::move(call_args),
1450
- handler](ClientMetadataHandle metadata) mutable {
1451
- call_args.client_initial_metadata = std::move(metadata);
1452
- return Seq(next_promise_factory(std::move(call_args)),
1453
- [handler](ServerMetadataHandle metadata) mutable
1454
- -> Poll<ServerMetadataHandle> {
1455
- handler.SpawnPushServerTrailingMetadata(
1456
- std::move(metadata));
1457
- // We always lose the race.
1458
- return Pending{};
1459
- });
1460
- });
1461
- }));
1300
+ // The returned promise is wrapped in OnCancel so that, if the v2 stack
1301
+ // destroys it before it completes (e.g. the forced-cancellation path in
1302
+ // ServerCallData::Completed, which resets promise_ to an empty
1303
+ // ArenaPromise), we actively propagate a cancellation into the v3 call
1304
+ // pair.
1305
+ return OnCancel(
1306
+ Race(
1307
+ // Get server trailing metadata from the v3 promise via the
1308
+ // inter-activity latch.
1309
+ If(
1310
+ IsV2NonOwningWakerImplementationEnabled(),
1311
+ [pipe_owner]() {
1312
+ return pipe_owner->server_trailing_metadata.Wait();
1313
+ },
1314
+ [initiator = initiator]() mutable {
1315
+ return initiator.PullServerTrailingMetadata();
1316
+ }),
1317
+ // This promise does the rest of the things, but it will always
1318
+ // return pending, because the promise can't actually finish
1319
+ // until the initiator returns trailing metadata above.
1320
+ TrySeq(
1321
+ state->call_handler_latch.Wait(),
1322
+ [initiator = initiator, pipe_owner,
1323
+ call_args = std::move(call_args),
1324
+ next_promise_factory = std::move(next_promise_factory)](
1325
+ CallHandler handler) mutable {
1326
+ // Intercept all pipes from v2 API.
1327
+ //
1328
+ // For client-to-server messages, we do the following:
1329
+ // 1. Push the message into the v3 initiator, which sends
1330
+ // it to the v3 interceptor. Note that this needs to
1331
+ // be done inside of the v3 initiator's activity.
1332
+ // 2. Pull the message from the v3 handler, where it will
1333
+ // arrive when the v3 interceptor is done with it.
1334
+ // Note that this needs to be done inside of the v3
1335
+ // handler's activity. We then push the message into
1336
+ // an inter-activity pipe to return it to the v2 activity.
1337
+ // 3. In the v2 activity, read the message from the
1338
+ // inter-activity pipe and send it on to the next
1339
+ // filter.
1340
+ //
1341
+ // Step 2: Spawn a promise to pull messages from the v3
1342
+ // handler and push them into an inter-activity pipe to
1343
+ // return them to the v2 activity.
1344
+ handler.SpawnGuarded(
1345
+ "pull_client_to_server_message",
1346
+ [handler, pipe_owner]() mutable {
1347
+ return ForEach(
1348
+ MessagesFrom(handler),
1349
+ [pipe_owner](MessageHandle message) {
1350
+ return Map(pipe_owner->client_to_server_messages
1351
+ .sender.Push(std::move(message)),
1352
+ [](bool x) { return StatusFlag(x); });
1353
+ });
1354
+ });
1355
+ call_args.client_to_server_messages->InterceptAndMap(
1356
+ [initiator, handler,
1357
+ pipe_owner](MessageHandle message) mutable {
1358
+ // Step 1: Push the message onto the v3 initiator in
1359
+ // its activity.
1360
+ initiator.SpawnPushMessage(std::move(message));
1361
+ // Step 3: Here in the v2 activity, read the message
1362
+ // from the inter-activity pipe and return it.
1363
+ return Map(
1364
+ pipe_owner->client_to_server_messages.receiver
1365
+ .Next(),
1366
+ [](InterActivityPipe<MessageHandle, 1>::NextResult
1367
+ message) -> std::optional<MessageHandle> {
1368
+ if (!message.has_value()) return std::nullopt;
1369
+ return std::move(*message);
1370
+ });
1371
+ });
1372
+ // For server initial metadata, we do a similar thing, but
1373
+ // in the opposite direction, and using an inter-activity
1374
+ // latch instead of a pipe:
1375
+ // 1. Push the metadata into the v3 handler, which sends
1376
+ // it to the v3 interceptor. Note that this needs to
1377
+ // be done inside of the v3 handler's activity.
1378
+ // 2. Pull the metadata from the v3 initiator, where it will
1379
+ // arrive when the v3 interceptor is done with it.
1380
+ // Note that this needs to be done inside of the v3
1381
+ // initiator's activity. We then use an inter-activity
1382
+ // latch to return the metadata to the v2 activity.
1383
+ // 3. In the v2 activity, read the metadata from the
1384
+ // inter-activity latch and send it on to the previous
1385
+ // filter.
1386
+ //
1387
+ // Step 2: Spawn a promise to pull the metadata from the v3
1388
+ // initiator and use an inter-activity latch to return it to
1389
+ // the v2 activity.
1390
+ initiator.SpawnGuarded(
1391
+ "pull_server_initial_metadata",
1392
+ [initiator, pipe_owner]() mutable {
1393
+ return TrySeq(
1394
+ initiator.PullServerInitialMetadata(),
1395
+ [pipe_owner](
1396
+ std::optional<ServerMetadataHandle> metadata) {
1397
+ pipe_owner->server_initial_metadata.Set(
1398
+ std::move(metadata));
1399
+ });
1400
+ });
1401
+ call_args.server_initial_metadata->InterceptAndMap(
1402
+ [initiator, handler,
1403
+ pipe_owner](ServerMetadataHandle metadata) mutable {
1404
+ // Step 1: Push the metadata onto the v3 handler in
1405
+ // its activity.
1406
+ handler.SpawnPushServerInitialMetadata(
1407
+ std::move(metadata));
1408
+ // Step 3: Here in the v2 activity, read from the
1409
+ // inter-activity latch and return the metadata.
1410
+ return pipe_owner->server_initial_metadata.Wait();
1411
+ });
1412
+ // We handle server-to-client messages the same as
1413
+ // client-to-server messages, except in the opposite
1414
+ // direction:
1415
+ // 1. Push the message into the v3 handler, which sends
1416
+ // it to the v3 interceptor. Note that this needs to
1417
+ // be done inside of the v3 handler's activity.
1418
+ // 2. Pull the message from the v3 initiator, where it will
1419
+ // arrive when the v3 interceptor is done with it.
1420
+ // Note that this needs to be done inside of the v3
1421
+ // initiator's activity. We then push the message into
1422
+ // an inter-activity pipe to return it to the v2 activity.
1423
+ // 3. In the v2 activity, read the message from the
1424
+ // inter-activity pipe and send it on to the next
1425
+ // filter.
1426
+ //
1427
+ // Step 2: Spawn a promise to pull messages from the v3
1428
+ // initiator and push them into an inter-activity pipe to
1429
+ // return them to the v2 activity.
1430
+ initiator.SpawnGuarded(
1431
+ "pull_server_to_client_message",
1432
+ [initiator, pipe_owner]() mutable {
1433
+ return ForEach(
1434
+ MessagesFrom(initiator),
1435
+ [pipe_owner](MessageHandle message) {
1436
+ return Map(pipe_owner->server_to_client_messages
1437
+ .sender.Push(std::move(message)),
1438
+ [](bool x) { return StatusFlag(x); });
1439
+ });
1440
+ });
1441
+ call_args.server_to_client_messages->InterceptAndMap(
1442
+ [initiator, handler,
1443
+ pipe_owner](MessageHandle message) mutable {
1444
+ // Step 1: Push the message onto the v3 handler in
1445
+ // its activity.
1446
+ handler.SpawnPushMessage(std::move(message));
1447
+ // Step 3: Here in the v2 activity, read from the
1448
+ // inter-activity pipe and return the messages.
1449
+ return Map(
1450
+ pipe_owner->server_to_client_messages.receiver
1451
+ .Next(),
1452
+ [](InterActivityPipe<MessageHandle, 1>::NextResult
1453
+ message) -> std::optional<MessageHandle> {
1454
+ if (!message.has_value()) return std::nullopt;
1455
+ return std::move(*message);
1456
+ });
1457
+ });
1458
+ // In the v3 handler's activity, pull client initial metadata.
1459
+ // Use an inter-activity latch to get it back to the v2
1460
+ // activity.
1461
+ handler.SpawnGuarded(
1462
+ "pull_client_initial_metadata",
1463
+ [handler, pipe_owner]() mutable {
1464
+ return TrySeq(
1465
+ handler.PullClientInitialMetadata(),
1466
+ [pipe_owner](ClientMetadataHandle metadata) {
1467
+ pipe_owner->client_initial_metadata.Set(
1468
+ std::move(metadata));
1469
+ });
1470
+ });
1471
+ // A wrapper for next_promise_factory that does the following:
1472
+ // - Pulls client initial metadata from the V3 handler via
1473
+ // the inter-activity latch and injects it into the next
1474
+ // V2 filter via CallArgs.
1475
+ // - Polls the next promise to get server trailing metadata
1476
+ // from the next V2 filter and feeds it into the V3 handler.
1477
+ // Note that this does not actually pull the trailing metadata
1478
+ // from the V3 initiator; instead, we do that in a separate
1479
+ // promise above. That promise will always complete at the
1480
+ // end of the call, so we always return pending here.
1481
+ return Seq(
1482
+ pipe_owner->client_initial_metadata.Wait(),
1483
+ [next_promise_factory = std::move(next_promise_factory),
1484
+ call_args = std::move(call_args),
1485
+ handler](ClientMetadataHandle metadata) mutable {
1486
+ call_args.client_initial_metadata = std::move(metadata);
1487
+ return Seq(
1488
+ next_promise_factory(std::move(call_args)),
1489
+ [handler](ServerMetadataHandle metadata) mutable
1490
+ -> Poll<ServerMetadataHandle> {
1491
+ handler.SpawnPushServerTrailingMetadata(
1492
+ std::move(metadata));
1493
+ // We always lose the race.
1494
+ return Pending{};
1495
+ });
1496
+ });
1497
+ })),
1498
+ [initiator = initiator]() mutable {
1499
+ // The v2 promise was destroyed before completing: propagate the
1500
+ // cancellation into the v3 call pair so its CallSpine is torn down
1501
+ // and the v3 interceptor is notified.
1502
+ if (IsV2NonOwningWakerImplementationEnabled()) {
1503
+ initiator.SpawnCancel(
1504
+ absl::CancelledError("call cancelled by v2 filter stack"));
1505
+ } else {
1506
+ initiator.SpawnInfallible("v2-force-cancel", [initiator]() mutable {
1507
+ initiator.Cancel();
1508
+ return Map(initiator.PullServerTrailingMetadata(),
1509
+ [](ServerMetadataHandle) { return Empty{}; });
1510
+ });
1511
+ }
1512
+ });
1462
1513
  }
1463
1514
 
1464
1515
  protected:
@@ -1917,9 +1968,11 @@ class BaseCallData : public Activity,
1917
1968
  std::string LogTag() const;
1918
1969
 
1919
1970
  private:
1971
+ class WeakWakerHandle;
1972
+
1920
1973
  // Wakeable implementation.
1921
1974
  void Wakeup(WakeupMask) final;
1922
- void WakeupAsync(WakeupMask) final { Crash("not implemented"); }
1975
+ void WakeupAsync(WakeupMask) final;
1923
1976
  void Drop(WakeupMask) final;
1924
1977
 
1925
1978
  virtual void OnWakeup() = 0;
@@ -1931,6 +1984,7 @@ class BaseCallData : public Activity,
1931
1984
  const Timestamp deadline_;
1932
1985
  CallFinalization finalization_;
1933
1986
  std::atomic<grpc_polling_entity*> pollent_{nullptr};
1987
+ OrphanablePtr<WeakWakerHandle> handle_;
1934
1988
  Pipe<ServerMetadataHandle>* const server_initial_metadata_pipe_;
1935
1989
  SendMessage* const send_message_;
1936
1990
  ReceiveMessage* const receive_message_;
@@ -37,10 +37,6 @@ class ReceiveCoalescingExtension {
37
37
  /// It is safe to call this only when there are no outstanding Reads on
38
38
  /// the Endpoint.
39
39
  virtual void DisableRpcReceiveCoalescing() = 0;
40
-
41
- /// If invoked, the endpoint tries to preserve proper order and alignment of
42
- /// any memory that maybe shared across reads.
43
- virtual void EnforceRxMemoryAlignment() = 0;
44
40
  };
45
41
 
46
42
  } // namespace grpc_event_engine::experimental
@@ -36,7 +36,7 @@ class TcpTraceExtension {
36
36
  // Enable TCP telemetry collection using the Instrumentation API.
37
37
  virtual void EnableTcpTelemetry(
38
38
  grpc_core::RefCountedPtr<grpc_core::CollectionScope> collection_scope,
39
- bool is_control_endpoint) = 0;
39
+ bool is_control_endpoint, bool trace_full_buffer) = 0;
40
40
  };
41
41
 
42
42
  } // namespace grpc_event_engine::experimental
@@ -76,14 +76,6 @@ namespace grpc_event_engine::experimental {
76
76
 
77
77
  namespace {
78
78
 
79
- bool ShouldUsePosixPoller() {
80
- #if defined(GRPC_PYTHON_BUILD)
81
- return grpc_core::IsEventEnginePollerForPythonEnabled();
82
- #else
83
- return true;
84
- #endif
85
- }
86
-
87
79
  #if GRPC_ENABLE_FORK_SUPPORT && GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
88
80
 
89
81
  // Thread pool can outlive EE but we need to ensure the ordering if both
@@ -434,10 +426,8 @@ PosixEventEngine::PosixEventEngine(const Options& options)
434
426
  : connection_shards_(options.connection_shards),
435
427
  executor_(MakeThreadPool(options.reserve_threads)),
436
428
  timer_manager_(std::make_shared<TimerManager>(executor_)) {
437
- if (ShouldUsePosixPoller()) {
438
- poller_ = grpc_event_engine::experimental::MakeDefaultPoller(executor_);
439
- SchedulePoller();
440
- }
429
+ poller_ = grpc_event_engine::experimental::MakeDefaultPoller(executor_);
430
+ SchedulePoller();
441
431
  }
442
432
 
443
433
  #endif // GRPC_POSIX_SOCKET_TCP
@@ -21,14 +21,10 @@
21
21
 
22
22
  namespace grpc_event_engine::experimental {
23
23
 
24
- bool UseEventEngineClient() {
25
- return !EventEngineExperimentDisabledForPython() &&
26
- grpc_core::IsEventEngineClientEnabled();
27
- }
24
+ bool UseEventEngineClient() { return grpc_core::IsEventEngineClientEnabled(); }
28
25
 
29
26
  bool UseEventEngineListener() {
30
- return !EventEngineExperimentDisabledForPython() &&
31
- grpc_core::IsEventEngineListenerEnabled();
27
+ return grpc_core::IsEventEngineListenerEnabled();
32
28
  }
33
29
 
34
30
  bool UsePollsetAlternative() {
@@ -36,14 +32,4 @@ bool UsePollsetAlternative() {
36
32
  grpc_core::IsPollsetAlternativeEnabled();
37
33
  }
38
34
 
39
- // Returns true if the poller is disabled by build configuration or experiment
40
- // flags.
41
- bool EventEngineExperimentDisabledForPython() {
42
- #ifdef GRPC_PYTHON_BUILD
43
- return !grpc_core::IsEventEnginePollerForPythonEnabled();
44
- #else
45
- return false;
46
- #endif
47
- }
48
-
49
35
  } // namespace grpc_event_engine::experimental
@@ -35,10 +35,6 @@ bool UseEventEngineListener();
35
35
  // may disable the poller in some builds.
36
36
  bool UsePollsetAlternative();
37
37
 
38
- // Returns true if the poller is disabled by build configuration or experiment
39
- // flags.
40
- bool EventEngineExperimentDisabledForPython();
41
-
42
38
  } // namespace grpc_event_engine::experimental
43
39
 
44
40
  #endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_SHIM_H