grpc 1.55.3 → 1.56.0.pre3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (385) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +100 -70
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/module.modulemap +2 -0
  6. data/include/grpc/support/json.h +218 -0
  7. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  8. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  9. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  10. data/src/core/ext/filters/client_channel/client_channel.cc +82 -98
  11. data/src/core/ext/filters/client_channel/client_channel.h +4 -0
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  13. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  14. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  15. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +52 -20
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +32 -39
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  40. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  42. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  43. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  45. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  46. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  47. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  48. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  49. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  50. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  51. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  52. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  54. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +543 -567
  56. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +9 -150
  57. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +32 -46
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +5 -18
  59. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  60. data/src/core/ext/transport/chttp2/transport/parsing.cc +12 -12
  61. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  62. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  63. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  64. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  65. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  66. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  67. data/src/core/ext/xds/xds_api.cc +9 -6
  68. data/src/core/ext/xds/xds_api.h +3 -2
  69. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  70. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  71. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  72. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  73. data/src/core/ext/xds/xds_client.cc +5 -4
  74. data/src/core/ext/xds/xds_client_stats.h +1 -1
  75. data/src/core/ext/xds/xds_cluster.cc +20 -19
  76. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  77. data/src/core/ext/xds/xds_common_types.cc +3 -1
  78. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  79. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  80. data/src/core/ext/xds/xds_http_filters.h +4 -2
  81. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  82. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  83. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  84. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  85. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  86. data/src/core/ext/xds/xds_listener.cc +1 -0
  87. data/src/core/ext/xds/xds_route_config.cc +40 -3
  88. data/src/core/ext/xds/xds_routing.cc +2 -2
  89. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  90. data/src/core/lib/avl/avl.h +5 -0
  91. data/src/core/lib/backoff/random_early_detection.h +0 -5
  92. data/src/core/lib/channel/channel_args.cc +80 -22
  93. data/src/core/lib/channel/channel_args.h +34 -1
  94. data/src/core/lib/channel/channel_trace.cc +16 -12
  95. data/src/core/lib/channel/channelz.cc +159 -132
  96. data/src/core/lib/channel/channelz.h +42 -35
  97. data/src/core/lib/channel/channelz_registry.cc +23 -20
  98. data/src/core/lib/channel/connected_channel.cc +17 -6
  99. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  100. data/src/core/lib/channel/promise_based_filter.h +2 -0
  101. data/src/core/lib/compression/compression_internal.cc +2 -5
  102. data/src/core/lib/config/config_vars.cc +20 -18
  103. data/src/core/lib/config/config_vars.h +4 -4
  104. data/src/core/lib/config/load_config.cc +13 -0
  105. data/src/core/lib/config/load_config.h +6 -0
  106. data/src/core/lib/debug/event_log.h +1 -1
  107. data/src/core/lib/debug/stats_data.h +1 -1
  108. data/src/core/lib/debug/trace.cc +24 -55
  109. data/src/core/lib/debug/trace.h +3 -1
  110. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  111. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  112. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  113. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  114. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  115. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  116. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  117. data/src/core/lib/event_engine/poller.h +2 -2
  118. data/src/core/lib/event_engine/posix.h +4 -0
  119. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  120. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  121. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  122. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +3 -2
  123. data/src/core/lib/event_engine/posix_engine/posix_engine.h +1 -2
  124. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +4 -33
  125. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +7 -11
  126. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  127. data/src/core/lib/event_engine/shim.cc +7 -1
  128. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  129. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  130. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  131. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  132. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  133. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  134. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  135. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  136. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  137. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  138. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  139. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  140. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  141. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  142. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  143. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  144. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  145. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  146. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  147. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  148. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  149. data/src/core/lib/experiments/config.cc +38 -7
  150. data/src/core/lib/experiments/config.h +16 -0
  151. data/src/core/lib/experiments/experiments.cc +67 -20
  152. data/src/core/lib/experiments/experiments.h +27 -21
  153. data/src/core/lib/gpr/log_internal.h +55 -0
  154. data/src/core/lib/gprpp/crash.cc +10 -0
  155. data/src/core/lib/gprpp/crash.h +3 -0
  156. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  157. data/src/core/lib/gprpp/per_cpu.h +29 -6
  158. data/src/core/lib/gprpp/time.cc +1 -0
  159. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  160. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  161. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  162. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  163. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  164. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  165. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  166. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  167. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  168. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  169. data/src/core/lib/iomgr/socket_windows.h +9 -2
  170. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  171. data/src/core/lib/iomgr/tcp_server_posix.cc +156 -140
  172. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -13
  173. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +0 -21
  174. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  175. data/src/core/lib/json/json.h +2 -166
  176. data/src/core/lib/json/json_object_loader.cc +8 -9
  177. data/src/core/lib/json/json_object_loader.h +25 -18
  178. data/src/core/lib/json/json_reader.cc +13 -6
  179. data/src/core/lib/json/json_util.cc +6 -11
  180. data/src/core/lib/json/json_writer.cc +7 -8
  181. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  182. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  183. data/src/core/lib/matchers/matchers.cc +3 -4
  184. data/src/core/lib/matchers/matchers.h +2 -1
  185. data/src/core/lib/promise/activity.cc +5 -0
  186. data/src/core/lib/promise/activity.h +10 -0
  187. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  188. data/src/core/lib/promise/party.cc +31 -13
  189. data/src/core/lib/promise/party.h +11 -2
  190. data/src/core/lib/promise/pipe.h +9 -2
  191. data/src/core/lib/promise/prioritized_race.h +95 -0
  192. data/src/core/lib/promise/sleep.cc +2 -1
  193. data/src/core/lib/resolver/server_address.cc +0 -8
  194. data/src/core/lib/resolver/server_address.h +0 -6
  195. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  196. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  197. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  198. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  199. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  200. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  201. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  202. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  203. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  204. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  205. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  206. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  207. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  208. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  209. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  210. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  211. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  212. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  213. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  214. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  215. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  216. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  217. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  218. data/src/core/lib/security/util/json_util.cc +1 -0
  219. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  220. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  221. data/src/core/lib/surface/call.cc +38 -23
  222. data/src/core/lib/surface/completion_queue.cc +6 -2
  223. data/src/core/lib/surface/validate_metadata.cc +22 -37
  224. data/src/core/lib/surface/validate_metadata.h +3 -13
  225. data/src/core/lib/surface/version.cc +2 -2
  226. data/src/core/lib/transport/batch_builder.cc +15 -12
  227. data/src/core/lib/transport/batch_builder.h +39 -35
  228. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  229. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  230. data/src/ruby/ext/grpc/extconf.rb +8 -9
  231. data/src/ruby/lib/grpc/version.rb +1 -1
  232. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  233. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  234. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  235. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  236. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  237. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  238. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  239. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  240. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  241. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  242. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  243. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  244. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  245. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  246. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  247. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  248. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  249. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  250. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  251. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  252. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  253. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  254. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  255. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  262. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  271. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  278. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  279. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  280. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  281. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  282. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  283. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  284. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  286. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  288. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  289. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  290. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  291. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  292. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  293. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  297. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  298. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  299. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  300. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  301. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  302. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  303. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  304. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  305. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  306. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  307. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  308. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  309. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  310. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  311. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  312. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  313. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  314. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  315. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  316. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  317. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  318. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  319. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  320. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  321. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  322. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  323. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  324. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  325. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  326. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  327. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  328. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  329. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  330. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  331. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  332. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  333. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  334. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  335. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  336. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  337. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  338. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  339. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  340. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  341. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  342. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  343. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  344. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  345. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  346. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  347. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  348. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  349. data/third_party/cares/cares/include/ares.h +23 -1
  350. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  351. data/third_party/cares/cares/include/ares_rules.h +2 -2
  352. data/third_party/cares/cares/include/ares_version.h +3 -3
  353. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  354. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  355. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  356. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  357. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  358. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  359. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  360. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  361. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  362. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  363. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  364. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  365. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  366. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  367. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  368. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  369. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  370. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  371. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  372. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  373. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  374. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  375. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  376. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  377. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  378. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  379. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  380. metadata +50 -16
  381. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  382. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  383. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.cc +0 -176
  384. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +0 -325
  385. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -0,0 +1,146 @@
1
+ // Copyright 2023 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #ifndef GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFSTREAM_ENDPOINT_H
15
+ #define GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFSTREAM_ENDPOINT_H
16
+ #include <grpc/support/port_platform.h>
17
+
18
+ #ifdef GPR_APPLE
19
+
20
+ #include <CoreFoundation/CoreFoundation.h>
21
+
22
+ #include "absl/strings/str_format.h"
23
+
24
+ #include <grpc/event_engine/event_engine.h>
25
+
26
+ #include "src/core/lib/address_utils/sockaddr_utils.h"
27
+ #include "src/core/lib/event_engine/cf_engine/cf_engine.h"
28
+ #include "src/core/lib/event_engine/cf_engine/cftype_unique_ref.h"
29
+ #include "src/core/lib/event_engine/posix_engine/lockfree_event.h"
30
+ #include "src/core/lib/event_engine/tcp_socket_utils.h"
31
+ #include "src/core/lib/gprpp/host_port.h"
32
+ #include "src/core/lib/gprpp/ref_counted.h"
33
+ #include "src/core/lib/gprpp/ref_counted_ptr.h"
34
+
35
+ namespace grpc_event_engine {
36
+ namespace experimental {
37
+
38
+ class CFStreamEndpointImpl
39
+ : public grpc_core::RefCounted<CFStreamEndpointImpl> {
40
+ public:
41
+ CFStreamEndpointImpl(std::shared_ptr<CFEventEngine> engine,
42
+ MemoryAllocator memory_allocator);
43
+ ~CFStreamEndpointImpl();
44
+
45
+ void Shutdown();
46
+
47
+ bool Read(absl::AnyInvocable<void(absl::Status)> on_read, SliceBuffer* buffer,
48
+ const EventEngine::Endpoint::ReadArgs* args);
49
+ bool Write(absl::AnyInvocable<void(absl::Status)> on_writable,
50
+ SliceBuffer* data, const EventEngine::Endpoint::WriteArgs* args);
51
+
52
+ const EventEngine::ResolvedAddress& GetPeerAddress() const {
53
+ return peer_address_;
54
+ }
55
+ const EventEngine::ResolvedAddress& GetLocalAddress() const {
56
+ return local_address_;
57
+ }
58
+
59
+ public:
60
+ void Connect(absl::AnyInvocable<void(absl::Status)> on_connect,
61
+ EventEngine::ResolvedAddress addr);
62
+ bool CancelConnect(absl::Status status);
63
+
64
+ private:
65
+ void DoWrite(absl::AnyInvocable<void(absl::Status)> on_writable,
66
+ SliceBuffer* data);
67
+ void DoRead(absl::AnyInvocable<void(absl::Status)> on_read,
68
+ SliceBuffer* buffer);
69
+
70
+ private:
71
+ static void* Retain(void* info) {
72
+ auto that = static_cast<CFStreamEndpointImpl*>(info);
73
+ return that->Ref().release();
74
+ }
75
+
76
+ static void Release(void* info) {
77
+ auto that = static_cast<CFStreamEndpointImpl*>(info);
78
+ that->Unref();
79
+ }
80
+
81
+ static void ReadCallback(CFReadStreamRef stream, CFStreamEventType type,
82
+ void* client_callback_info);
83
+ static void WriteCallback(CFWriteStreamRef stream, CFStreamEventType type,
84
+ void* client_callback_info);
85
+
86
+ private:
87
+ CFTypeUniqueRef<CFReadStreamRef> cf_read_stream_;
88
+ CFTypeUniqueRef<CFWriteStreamRef> cf_write_stream_;
89
+
90
+ std::shared_ptr<CFEventEngine> engine_;
91
+
92
+ EventEngine::ResolvedAddress peer_address_;
93
+ EventEngine::ResolvedAddress local_address_;
94
+ std::string peer_address_string_;
95
+ std::string local_address_string_;
96
+ MemoryAllocator memory_allocator_;
97
+
98
+ LockfreeEvent open_event_;
99
+ LockfreeEvent read_event_;
100
+ LockfreeEvent write_event_;
101
+ };
102
+
103
+ class CFStreamEndpoint : public EventEngine::Endpoint {
104
+ public:
105
+ CFStreamEndpoint(std::shared_ptr<CFEventEngine> engine,
106
+ MemoryAllocator memory_allocator) {
107
+ impl_ = grpc_core::MakeRefCounted<CFStreamEndpointImpl>(
108
+ std::move(engine), std::move(memory_allocator));
109
+ }
110
+ ~CFStreamEndpoint() override { impl_->Shutdown(); }
111
+
112
+ bool Read(absl::AnyInvocable<void(absl::Status)> on_read, SliceBuffer* buffer,
113
+ const ReadArgs* args) override {
114
+ return impl_->Read(std::move(on_read), buffer, args);
115
+ }
116
+ bool Write(absl::AnyInvocable<void(absl::Status)> on_writable,
117
+ SliceBuffer* data, const WriteArgs* args) override {
118
+ return impl_->Write(std::move(on_writable), data, args);
119
+ }
120
+
121
+ const EventEngine::ResolvedAddress& GetPeerAddress() const override {
122
+ return impl_->GetPeerAddress();
123
+ }
124
+ const EventEngine::ResolvedAddress& GetLocalAddress() const override {
125
+ return impl_->GetLocalAddress();
126
+ }
127
+
128
+ public:
129
+ void Connect(absl::AnyInvocable<void(absl::Status)> on_connect,
130
+ EventEngine::ResolvedAddress addr) {
131
+ impl_->Connect(std::move(on_connect), std::move(addr));
132
+ }
133
+ bool CancelConnect(absl::Status status) {
134
+ return impl_->CancelConnect(std::move(status));
135
+ }
136
+
137
+ private:
138
+ grpc_core::RefCountedPtr<CFStreamEndpointImpl> impl_;
139
+ };
140
+
141
+ } // namespace experimental
142
+ } // namespace grpc_event_engine
143
+
144
+ #endif // GPR_APPLE
145
+
146
+ #endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFSTREAM_ENDPOINT_H
@@ -0,0 +1,79 @@
1
+ // Copyright 2023 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #ifndef GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFTYPE_UNIQUE_REF_H
15
+ #define GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFTYPE_UNIQUE_REF_H
16
+ #include <grpc/support/port_platform.h>
17
+
18
+ #ifdef GPR_APPLE
19
+
20
+ #include <CoreFoundation/CoreFoundation.h>
21
+
22
+ namespace grpc_event_engine {
23
+ namespace experimental {
24
+
25
+ template <typename T>
26
+ class CFTypeUniqueRef {
27
+ static_assert(std::is_convertible<T, CFTypeRef>::value,
28
+ "T should be `CFXxxRef` type");
29
+
30
+ public:
31
+ /* implicit */
32
+ CFTypeUniqueRef(T cf_type_ref = nullptr) : cf_type_ref_(cf_type_ref) {}
33
+ ~CFTypeUniqueRef() { reset(); }
34
+
35
+ CFTypeUniqueRef(CFTypeUniqueRef const&) = delete;
36
+ CFTypeUniqueRef& operator=(CFTypeUniqueRef const&) = delete;
37
+
38
+ CFTypeUniqueRef(CFTypeUniqueRef&& other) : cf_type_ref_(other.release()){};
39
+ CFTypeUniqueRef& operator=(CFTypeUniqueRef&& other) {
40
+ reset(other.release());
41
+ return *this;
42
+ }
43
+
44
+ operator T() { return cf_type_ref_; }
45
+
46
+ // Note: this is for passing a CFTypeRef as output parameter to a CF API, the
47
+ // current ref is released (if any) regardless of whether new value is set
48
+ T* operator&() {
49
+ reset();
50
+ return &cf_type_ref_;
51
+ }
52
+
53
+ T release() {
54
+ T old = cf_type_ref_;
55
+ cf_type_ref_ = nullptr;
56
+ return old;
57
+ }
58
+
59
+ void reset(T other = nullptr) {
60
+ if (cf_type_ref_ == other) {
61
+ return;
62
+ }
63
+ T old = cf_type_ref_;
64
+ cf_type_ref_ = other;
65
+ if (old) {
66
+ CFRelease(old);
67
+ }
68
+ }
69
+
70
+ private:
71
+ T cf_type_ref_;
72
+ };
73
+
74
+ } // namespace experimental
75
+ } // namespace grpc_event_engine
76
+
77
+ #endif // GPR_APPLE
78
+
79
+ #endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_CFTYPE_UNIQUE_REF_H
@@ -32,6 +32,10 @@
32
32
  #include "src/core/lib/gprpp/no_destruct.h"
33
33
  #include "src/core/lib/gprpp/sync.h"
34
34
 
35
+ #ifdef GRPC_MAXIMIZE_THREADYNESS
36
+ #include "src/core/lib/event_engine/thready_event_engine/thready_event_engine.h" // IWYU pragma: keep
37
+ #endif
38
+
35
39
  namespace grpc_event_engine {
36
40
  namespace experimental {
37
41
 
@@ -57,13 +61,21 @@ void EventEngineFactoryReset() {
57
61
  g_event_engine->reset();
58
62
  }
59
63
 
60
- std::unique_ptr<EventEngine> CreateEventEngine() {
64
+ std::unique_ptr<EventEngine> CreateEventEngineInner() {
61
65
  if (auto* factory = g_event_engine_factory.load()) {
62
66
  return (*factory)();
63
67
  }
64
68
  return DefaultEventEngineFactory();
65
69
  }
66
70
 
71
+ std::unique_ptr<EventEngine> CreateEventEngine() {
72
+ #ifdef GRPC_MAXIMIZE_THREADYNESS
73
+ return std::make_unique<ThreadyEventEngine>(CreateEventEngineInner());
74
+ #else
75
+ return CreateEventEngineInner();
76
+ #endif
77
+ }
78
+
67
79
  std::shared_ptr<EventEngine> GetDefaultEventEngine(
68
80
  grpc_core::SourceLocation location) {
69
81
  grpc_core::MutexLock lock(&*g_mu);
@@ -20,7 +20,7 @@
20
20
 
21
21
  #include <grpc/event_engine/event_engine.h>
22
22
 
23
- #ifdef GPR_WINDOWS
23
+ #if defined(GPR_WINDOWS)
24
24
  #include "src/core/lib/event_engine/windows/windows_engine.h"
25
25
 
26
26
  namespace grpc_event_engine {
@@ -32,7 +32,19 @@ std::unique_ptr<EventEngine> DefaultEventEngineFactory() {
32
32
 
33
33
  } // namespace experimental
34
34
  } // namespace grpc_event_engine
35
- #else // not GPR_WINDOWS
35
+ #elif defined(GRPC_CFSTREAM)
36
+ #include "src/core/lib/event_engine/cf_engine/cf_engine.h"
37
+
38
+ namespace grpc_event_engine {
39
+ namespace experimental {
40
+
41
+ std::unique_ptr<EventEngine> DefaultEventEngineFactory() {
42
+ return std::make_unique<CFEventEngine>();
43
+ }
44
+
45
+ } // namespace experimental
46
+ } // namespace grpc_event_engine
47
+ #else
36
48
  #include "src/core/lib/event_engine/posix_engine/posix_engine.h"
37
49
 
38
50
  namespace grpc_event_engine {
@@ -43,12 +43,12 @@ class Poller {
43
43
  // * Poller::WorkResult::kKicked if it was Kicked. A poller that was Kicked
44
44
  // may still process some events and if so, it may have run the
45
45
  // schedule_poll_again callback function synchronously. When the poller
46
- // returns Poller::WorkResult::kKicked tts upto the user to determine
46
+ // returns Poller::WorkResult::kKicked it's up to the user to determine
47
47
  // if the schedule_poll_again callback has run or not.
48
48
  // * Poller::WorkResult::kDeadlineExceeded if timeout occurred. The
49
49
  // schedule_poll_again callback is not run in this case.
50
50
  // * Poller::WorkResult::kOk, otherwise indicating that the
51
- // schedule_poll_again callback function was run synchonously before some
51
+ // schedule_poll_again callback function was run synchronously before some
52
52
  // events were processed.
53
53
  virtual WorkResult Work(EventEngine::Duration timeout,
54
54
  absl::FunctionRef<void()> schedule_poll_again) = 0;
@@ -37,6 +37,10 @@ class PosixEndpointWithFdSupport : public EventEngine::Endpoint {
37
37
  /// Returns the file descriptor associated with the posix endpoint.
38
38
  virtual int GetWrappedFd() = 0;
39
39
 
40
+ /// Returns if the Endpoint supports tracking events from errmsg queues on
41
+ /// posix systems.
42
+ virtual bool CanTrackErrors() = 0;
43
+
40
44
  /// Shutdown the endpoint. This function call should trigger execution of
41
45
  /// any pending endpoint Read/Write callbacks with appropriate error
42
46
  /// absl::Status. After this function call any subsequent endpoint
@@ -349,7 +349,7 @@ void Epoll1EventHandle::HandleShutdownInternal(absl::Status why,
349
349
  }
350
350
  }
351
351
  write_closure_->SetShutdown(why);
352
- write_closure_->SetShutdown(why);
352
+ error_closure_->SetShutdown(why);
353
353
  }
354
354
  }
355
355
 
@@ -86,7 +86,7 @@ void LockfreeEvent::DestroyEvent() {
86
86
  // pattern to prevent error retention in a deleted object
87
87
  } while (!state_.compare_exchange_strong(curr, kShutdownBit,
88
88
  std::memory_order_acq_rel,
89
- std::memory_order_relaxed));
89
+ std::memory_order_acquire));
90
90
  }
91
91
 
92
92
  void LockfreeEvent::NotifyOn(PosixEngineClosure* closure) {
@@ -103,14 +103,9 @@ void LockfreeEvent::NotifyOn(PosixEngineClosure* closure) {
103
103
  case kClosureNotReady: {
104
104
  // kClosureNotReady -> <closure>.
105
105
 
106
- // We're guaranteed by API that there's an acquire barrier before here,
107
- // so there's no need to double-dip and this can be a release-only.
108
-
109
- // The release itself pairs with the acquire half of a set_ready full
110
- // barrier.
111
106
  if (state_.compare_exchange_strong(
112
107
  curr, reinterpret_cast<intptr_t>(closure),
113
- std::memory_order_acq_rel, std::memory_order_relaxed)) {
108
+ std::memory_order_acq_rel, std::memory_order_acquire)) {
114
109
  return; // Successful. Return
115
110
  }
116
111
 
@@ -122,13 +117,9 @@ void LockfreeEvent::NotifyOn(PosixEngineClosure* closure) {
122
117
  // successful. If not, the state most likely transitioned to shutdown.
123
118
  // We should retry.
124
119
 
125
- // This can be a no-barrier cas since the state is being transitioned to
126
- // kClosureNotReady; set_ready and set_shutdown do not schedule any
127
- // closure when transitioning out of CLOSURE_NO_READY state (i.e there
128
- // is no other code that needs to 'happen-after' this)
129
120
  if (state_.compare_exchange_strong(curr, kClosureNotReady,
130
121
  std::memory_order_acq_rel,
131
- std::memory_order_relaxed)) {
122
+ std::memory_order_acquire)) {
132
123
  scheduler_->Run(closure);
133
124
  return; // Successful. Return.
134
125
  }
@@ -175,7 +166,7 @@ bool LockfreeEvent::SetShutdown(absl::Status shutdown_error) {
175
166
  // doesn't need a barrier
176
167
  if (state_.compare_exchange_strong(curr, new_state,
177
168
  std::memory_order_acq_rel,
178
- std::memory_order_relaxed)) {
169
+ std::memory_order_acquire)) {
179
170
  return true; // early out
180
171
  }
181
172
  break; // retry
@@ -196,7 +187,7 @@ bool LockfreeEvent::SetShutdown(absl::Status shutdown_error) {
196
187
  // loading the shutdown state.
197
188
  if (state_.compare_exchange_strong(curr, new_state,
198
189
  std::memory_order_acq_rel,
199
- std::memory_order_relaxed)) {
190
+ std::memory_order_acquire)) {
200
191
  auto closure = reinterpret_cast<PosixEngineClosure*>(curr);
201
192
  closure->SetStatus(shutdown_error);
202
193
  scheduler_->Run(closure);
@@ -225,11 +216,9 @@ void LockfreeEvent::SetReady() {
225
216
  }
226
217
 
227
218
  case kClosureNotReady: {
228
- // No barrier required as we're transitioning to a state that does not
229
- // involve a closure
230
219
  if (state_.compare_exchange_strong(curr, kClosureReady,
231
220
  std::memory_order_acq_rel,
232
- std::memory_order_relaxed)) {
221
+ std::memory_order_acquire)) {
233
222
  return; // early out
234
223
  }
235
224
  break; // retry
@@ -242,7 +231,7 @@ void LockfreeEvent::SetReady() {
242
231
  return;
243
232
  } else if (state_.compare_exchange_strong(curr, kClosureNotReady,
244
233
  std::memory_order_acq_rel,
245
- std::memory_order_relaxed)) {
234
+ std::memory_order_acquire)) {
246
235
  // Full cas: acquire pairs with this cas' release in the event of a
247
236
  // spurious set_ready; release pairs with this or the acquire in
248
237
  // notify_on (or set_shutdown)
@@ -493,6 +493,8 @@ class PosixEndpointImpl : public grpc_core::RefCounted<PosixEndpointImpl> {
493
493
 
494
494
  int GetWrappedFd() { return fd_; }
495
495
 
496
+ bool CanTrackErrors() const { return poller_->CanTrackErrors(); }
497
+
496
498
  void MaybeShutdown(
497
499
  absl::Status why,
498
500
  absl::AnyInvocable<void(absl::StatusOr<int> release_fd)> on_release_fd);
@@ -635,6 +637,8 @@ class PosixEndpoint : public PosixEndpointWithFdSupport {
635
637
 
636
638
  int GetWrappedFd() override { return impl_->GetWrappedFd(); }
637
639
 
640
+ bool CanTrackErrors() override { return impl_->CanTrackErrors(); }
641
+
638
642
  void Shutdown(absl::AnyInvocable<void(absl::StatusOr<int> release_fd)>
639
643
  on_release_fd) override {
640
644
  if (!shutdown_.exchange(true, std::memory_order_acq_rel)) {
@@ -691,6 +695,11 @@ class PosixEndpoint : public PosixEndpointWithFdSupport {
691
695
  "PosixEndpoint::GetWrappedFd not supported on this platform");
692
696
  }
693
697
 
698
+ bool CanTrackErrors() override {
699
+ grpc_core::Crash(
700
+ "PosixEndpoint::CanTrackErrors not supported on this platform");
701
+ }
702
+
694
703
  void Shutdown(absl::AnyInvocable<void(absl::StatusOr<int> release_fd)>
695
704
  on_release_fd) override {
696
705
  grpc_core::Crash("PosixEndpoint::Shutdown not supported on this platform");
@@ -44,6 +44,7 @@
44
44
  #include "src/core/lib/event_engine/tcp_socket_utils.h"
45
45
  #include "src/core/lib/event_engine/trace.h"
46
46
  #include "src/core/lib/event_engine/utils.h"
47
+ #include "src/core/lib/gpr/useful.h"
47
48
  #include "src/core/lib/gprpp/crash.h"
48
49
  #include "src/core/lib/gprpp/sync.h"
49
50
 
@@ -342,7 +343,7 @@ PosixEnginePollerManager::~PosixEnginePollerManager() {
342
343
 
343
344
  PosixEventEngine::PosixEventEngine(PosixEventPoller* poller)
344
345
  : connection_shards_(std::max(2 * gpr_cpu_num_cores(), 1u)),
345
- executor_(std::make_shared<ThreadPool>()),
346
+ executor_(MakeThreadPool(grpc_core::Clamp(gpr_cpu_num_cores(), 2u, 16u))),
346
347
  timer_manager_(executor_) {
347
348
  #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
348
349
  poller_manager_ = std::make_shared<PosixEnginePollerManager>(poller);
@@ -351,7 +352,7 @@ PosixEventEngine::PosixEventEngine(PosixEventPoller* poller)
351
352
 
352
353
  PosixEventEngine::PosixEventEngine()
353
354
  : connection_shards_(std::max(2 * gpr_cpu_num_cores(), 1u)),
354
- executor_(std::make_shared<ThreadPool>()),
355
+ executor_(MakeThreadPool(grpc_core::Clamp(gpr_cpu_num_cores(), 2u, 16u))),
355
356
  timer_manager_(executor_) {
356
357
  #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
357
358
  poller_manager_ = std::make_shared<PosixEnginePollerManager>(executor_);
@@ -38,7 +38,7 @@
38
38
  #include "src/core/lib/event_engine/posix.h"
39
39
  #include "src/core/lib/event_engine/posix_engine/event_poller.h"
40
40
  #include "src/core/lib/event_engine/posix_engine/timer_manager.h"
41
- #include "src/core/lib/event_engine/thread_pool.h"
41
+ #include "src/core/lib/event_engine/thread_pool/thread_pool.h"
42
42
  #include "src/core/lib/gprpp/sync.h"
43
43
  #include "src/core/lib/iomgr/port.h"
44
44
  #include "src/core/lib/surface/init_internally.h"
@@ -196,7 +196,6 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport,
196
196
  const DNSResolver::ResolverOptions& options) override;
197
197
  void Run(Closure* closure) override;
198
198
  void Run(absl::AnyInvocable<void()> closure) override;
199
- // Caution!! The timer implementation cannot create any fds. See #20418.
200
199
  TaskHandle RunAfter(Duration when, Closure* closure) override;
201
200
  TaskHandle RunAfter(Duration when,
202
201
  absl::AnyInvocable<void()> closure) override;
@@ -23,9 +23,7 @@
23
23
  #include <sys/socket.h> // IWYU pragma: keep
24
24
  #include <unistd.h> // IWYU pragma: keep
25
25
 
26
- #include <atomic>
27
26
  #include <string>
28
- #include <tuple>
29
27
  #include <utility>
30
28
 
31
29
  #include "absl/functional/any_invocable.h"
@@ -43,7 +41,6 @@
43
41
  #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h"
44
42
  #include "src/core/lib/event_engine/tcp_socket_utils.h"
45
43
  #include "src/core/lib/gprpp/status_helper.h"
46
- #include "src/core/lib/gprpp/time.h"
47
44
  #include "src/core/lib/iomgr/socket_mutator.h"
48
45
 
49
46
  namespace grpc_event_engine {
@@ -67,7 +64,7 @@ PosixEngineListenerImpl::PosixEngineListenerImpl(
67
64
  absl::StatusOr<int> PosixEngineListenerImpl::Bind(
68
65
  const EventEngine::ResolvedAddress& addr,
69
66
  PosixListenerWithFdSupport::OnPosixBindNewFdCallback on_bind_new_fd) {
70
- absl::MutexLock lock(&this->mu_);
67
+ grpc_core::MutexLock lock(&this->mu_);
71
68
  if (this->started_) {
72
69
  return absl::FailedPreconditionError(
73
70
  "Listener is already started, ports can no longer be bound");
@@ -139,32 +136,6 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::NotifyOnAccept(
139
136
  switch (errno) {
140
137
  case EINTR:
141
138
  continue;
142
- case EMFILE:
143
- // When the process runs out of fds, accept4() returns EMFILE. When
144
- // this happens, the connection is left in the accept queue until
145
- // either a read event triggers the on_read callback, or time has
146
- // passed and the accept should be re-tried regardless. This callback
147
- // is not cancelled, so a spurious wakeup may occur even when there's
148
- // nothing to accept. This is not a performant code path, but if an fd
149
- // limit has been reached, the system is likely in an unhappy state
150
- // regardless.
151
- GRPC_LOG_EVERY_N_SEC(1, GPR_ERROR, "%s",
152
- "File descriptor limit reached. Retrying.");
153
- handle_->NotifyOnRead(notify_on_accept_);
154
- // Do not schedule another timer if one is already armed.
155
- if (retry_timer_armed_.exchange(true)) return;
156
- // Hold a ref while the retry timer is waiting, to prevent listener
157
- // destruction and the races that would ensue.
158
- Ref();
159
- std::ignore =
160
- engine_->RunAfter(grpc_core::Duration::Seconds(1), [this]() {
161
- retry_timer_armed_.store(false);
162
- if (!handle_->IsHandleShutdown()) {
163
- handle_->SetReadable();
164
- }
165
- Unref();
166
- });
167
- return;
168
139
  case EAGAIN:
169
140
  case ECONNABORTED:
170
141
  handle_->NotifyOnRead(notify_on_accept_);
@@ -283,7 +254,7 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::Shutdown() {
283
254
  }
284
255
 
285
256
  absl::Status PosixEngineListenerImpl::Start() {
286
- absl::MutexLock lock(&this->mu_);
257
+ grpc_core::MutexLock lock(&this->mu_);
287
258
  // Start each asynchronous acceptor.
288
259
  GPR_ASSERT(!this->started_);
289
260
  this->started_ = true;
@@ -296,7 +267,7 @@ absl::Status PosixEngineListenerImpl::Start() {
296
267
  void PosixEngineListenerImpl::TriggerShutdown() {
297
268
  // This would get invoked from the destructor of the parent
298
269
  // PosixEngineListener object.
299
- absl::MutexLock lock(&this->mu_);
270
+ grpc_core::MutexLock lock(&this->mu_);
300
271
  for (auto it = acceptors_.begin(); it != acceptors_.end(); it++) {
301
272
  // Trigger shutdown of each asynchronous acceptor. This in-turn calls
302
273
  // ShutdownHandle on the associated poller event handle. It may also
@@ -307,7 +278,7 @@ void PosixEngineListenerImpl::TriggerShutdown() {
307
278
  }
308
279
 
309
280
  PosixEngineListenerImpl::~PosixEngineListenerImpl() {
310
- // This should get invoked only after all the AsyncConnectionAcceptor's have
281
+ // This should get invoked only after all the AsyncConnectionAcceptors have
311
282
  // been destroyed. This is because each AsyncConnectionAcceptor has a
312
283
  // shared_ptr ref to the parent PosixEngineListenerImpl.
313
284
  if (on_shutdown_ != nullptr) {
@@ -28,7 +28,6 @@
28
28
  #include "absl/functional/any_invocable.h"
29
29
  #include "absl/status/status.h"
30
30
  #include "absl/status/statusor.h"
31
- #include "absl/synchronization/mutex.h"
32
31
 
33
32
  #include <grpc/event_engine/endpoint_config.h>
34
33
  #include <grpc/event_engine/event_engine.h>
@@ -36,6 +35,7 @@
36
35
  #include <grpc/event_engine/slice_buffer.h>
37
36
 
38
37
  #include "src/core/lib/event_engine/posix.h"
38
+ #include "src/core/lib/gprpp/sync.h"
39
39
  #include "src/core/lib/iomgr/port.h"
40
40
 
41
41
  #ifdef GRPC_POSIX_SOCKET_TCP
@@ -79,7 +79,7 @@ class PosixEngineListenerImpl
79
79
  // This class represents accepting for one bind fd belonging to the listener.
80
80
  // Each AsyncConnectionAcceptor takes a ref to the parent
81
81
  // PosixEngineListenerImpl object. So the PosixEngineListenerImpl can be
82
- // deleted only after all AsyncConnectionAcceptor's get destroyed.
82
+ // deleted only after all AsyncConnectionAcceptors get destroyed.
83
83
  class AsyncConnectionAcceptor {
84
84
  public:
85
85
  AsyncConnectionAcceptor(std::shared_ptr<EventEngine> engine,
@@ -121,9 +121,6 @@ class PosixEngineListenerImpl
121
121
  ListenerSocketsContainer::ListenerSocket socket_;
122
122
  EventHandle* handle_;
123
123
  PosixEngineClosure* notify_on_accept_;
124
- // Tracks the status of a backup timer to retry accept4 calls after file
125
- // descriptor exhaustion.
126
- std::atomic<bool> retry_timer_armed_{false};
127
124
  };
128
125
  class ListenerAsyncAcceptors : public ListenerSocketsContainer {
129
126
  public:
@@ -146,12 +143,11 @@ class PosixEngineListenerImpl
146
143
  absl::StatusOr<ListenerSocket> Find(
147
144
  const grpc_event_engine::experimental::EventEngine::ResolvedAddress&
148
145
  addr) override {
149
- for (auto acceptor = acceptors_.begin(); acceptor != acceptors_.end();
150
- ++acceptor) {
151
- if ((*acceptor)->Socket().addr.size() == addr.size() &&
152
- memcmp((*acceptor)->Socket().addr.address(), addr.address(),
146
+ for (auto* acceptor : acceptors_) {
147
+ if (acceptor->Socket().addr.size() == addr.size() &&
148
+ memcmp(acceptor->Socket().addr.address(), addr.address(),
153
149
  addr.size()) == 0) {
154
- return (*acceptor)->Socket();
150
+ return acceptor->Socket();
155
151
  }
156
152
  }
157
153
  return absl::NotFoundError("Socket not found!");
@@ -175,7 +171,7 @@ class PosixEngineListenerImpl
175
171
  friend class AsyncConnectionAcceptor;
176
172
  // The mutex ensures thread safety when multiple threads try to call Bind
177
173
  // and Start in parallel.
178
- absl::Mutex mu_;
174
+ grpc_core::Mutex mu_;
179
175
  PosixEventPoller* poller_;
180
176
  PosixTcpOptions options_;
181
177
  std::shared_ptr<EventEngine> engine_;
@@ -33,7 +33,7 @@
33
33
 
34
34
  #include "src/core/lib/event_engine/forkable.h"
35
35
  #include "src/core/lib/event_engine/posix_engine/timer.h"
36
- #include "src/core/lib/event_engine/thread_pool.h"
36
+ #include "src/core/lib/event_engine/thread_pool/thread_pool.h"
37
37
  #include "src/core/lib/gprpp/notification.h"
38
38
  #include "src/core/lib/gprpp/sync.h"
39
39
  #include "src/core/lib/gprpp/thd.h"
@@ -22,6 +22,12 @@
22
22
  namespace grpc_event_engine {
23
23
  namespace experimental {
24
24
 
25
+ #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
26
+ bool g_event_engine_supports_fd = true;
27
+ #else
28
+ bool g_event_engine_supports_fd = false;
29
+ #endif
30
+
25
31
  bool UseEventEngineClient() {
26
32
  // TODO(hork, eryu): Adjust the ifdefs accordingly when event engines become
27
33
  // available for other platforms.
@@ -48,7 +54,7 @@ bool UseEventEngineListener() {
48
54
 
49
55
  bool EventEngineSupportsFd() {
50
56
  #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
51
- return true;
57
+ return g_event_engine_supports_fd;
52
58
  #else
53
59
  return false;
54
60
  #endif