grpc 1.55.0 → 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 (374) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +100 -68
  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 +86 -104
  11. data/src/core/ext/filters/client_channel/client_channel.h +6 -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/internal.h +1 -15
  56. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  57. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  58. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  59. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  60. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  61. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  62. data/src/core/ext/xds/xds_api.cc +9 -6
  63. data/src/core/ext/xds/xds_api.h +3 -2
  64. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  65. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  66. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  67. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  68. data/src/core/ext/xds/xds_client.cc +5 -4
  69. data/src/core/ext/xds/xds_client_stats.h +1 -1
  70. data/src/core/ext/xds/xds_cluster.cc +20 -19
  71. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  72. data/src/core/ext/xds/xds_common_types.cc +3 -1
  73. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  74. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  75. data/src/core/ext/xds/xds_http_filters.h +4 -2
  76. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  77. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  78. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  79. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  80. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  81. data/src/core/ext/xds/xds_listener.cc +1 -0
  82. data/src/core/ext/xds/xds_route_config.cc +40 -3
  83. data/src/core/ext/xds/xds_routing.cc +2 -2
  84. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  85. data/src/core/lib/avl/avl.h +5 -0
  86. data/src/core/lib/channel/channel_args.cc +80 -22
  87. data/src/core/lib/channel/channel_args.h +34 -1
  88. data/src/core/lib/channel/channel_trace.cc +16 -12
  89. data/src/core/lib/channel/channelz.cc +159 -132
  90. data/src/core/lib/channel/channelz.h +42 -35
  91. data/src/core/lib/channel/channelz_registry.cc +23 -20
  92. data/src/core/lib/channel/connected_channel.cc +17 -6
  93. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  94. data/src/core/lib/channel/promise_based_filter.h +2 -0
  95. data/src/core/lib/compression/compression_internal.cc +2 -5
  96. data/src/core/lib/config/config_vars.cc +20 -18
  97. data/src/core/lib/config/config_vars.h +4 -4
  98. data/src/core/lib/config/load_config.cc +13 -0
  99. data/src/core/lib/config/load_config.h +6 -0
  100. data/src/core/lib/debug/event_log.h +1 -1
  101. data/src/core/lib/debug/stats_data.h +1 -1
  102. data/src/core/lib/debug/trace.cc +24 -55
  103. data/src/core/lib/debug/trace.h +3 -1
  104. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  105. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  106. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  107. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  108. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  109. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  110. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  111. data/src/core/lib/event_engine/poller.h +2 -2
  112. data/src/core/lib/event_engine/posix.h +4 -0
  113. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  114. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  115. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  116. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
  117. data/src/core/lib/event_engine/posix_engine/posix_engine.h +1 -1
  118. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +4 -4
  119. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +7 -8
  120. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  121. data/src/core/lib/event_engine/shim.cc +7 -1
  122. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  123. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  124. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  125. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  126. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  127. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  128. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  129. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  130. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  131. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  132. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  133. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  134. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  135. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  136. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  137. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  138. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  139. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  140. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  141. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  142. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  143. data/src/core/lib/experiments/config.cc +38 -7
  144. data/src/core/lib/experiments/config.h +16 -0
  145. data/src/core/lib/experiments/experiments.cc +67 -20
  146. data/src/core/lib/experiments/experiments.h +27 -21
  147. data/src/core/lib/gpr/log_internal.h +55 -0
  148. data/src/core/lib/gprpp/crash.cc +10 -0
  149. data/src/core/lib/gprpp/crash.h +3 -0
  150. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  151. data/src/core/lib/gprpp/per_cpu.h +29 -6
  152. data/src/core/lib/gprpp/time.cc +1 -0
  153. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  154. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  155. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  156. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  157. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  158. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  159. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  160. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  161. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  162. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  163. data/src/core/lib/iomgr/socket_windows.h +9 -2
  164. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  165. data/src/core/lib/iomgr/tcp_server_posix.cc +148 -107
  166. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -1
  167. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  168. data/src/core/lib/json/json.h +2 -166
  169. data/src/core/lib/json/json_object_loader.cc +8 -9
  170. data/src/core/lib/json/json_object_loader.h +25 -18
  171. data/src/core/lib/json/json_reader.cc +13 -6
  172. data/src/core/lib/json/json_util.cc +6 -11
  173. data/src/core/lib/json/json_writer.cc +7 -8
  174. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  175. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  176. data/src/core/lib/matchers/matchers.cc +3 -4
  177. data/src/core/lib/matchers/matchers.h +2 -1
  178. data/src/core/lib/promise/activity.cc +5 -0
  179. data/src/core/lib/promise/activity.h +10 -0
  180. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  181. data/src/core/lib/promise/party.cc +31 -13
  182. data/src/core/lib/promise/party.h +11 -2
  183. data/src/core/lib/promise/pipe.h +9 -2
  184. data/src/core/lib/promise/prioritized_race.h +95 -0
  185. data/src/core/lib/promise/sleep.cc +2 -1
  186. data/src/core/lib/resolver/server_address.cc +0 -8
  187. data/src/core/lib/resolver/server_address.h +0 -6
  188. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  189. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  190. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  191. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  192. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  193. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  194. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  195. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  196. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  197. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  198. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  199. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  200. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  201. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  202. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  203. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  204. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  205. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  206. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  207. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  208. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  209. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  210. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  211. data/src/core/lib/security/util/json_util.cc +1 -0
  212. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  213. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  214. data/src/core/lib/surface/call.cc +38 -23
  215. data/src/core/lib/surface/completion_queue.cc +6 -2
  216. data/src/core/lib/surface/version.cc +2 -2
  217. data/src/core/lib/transport/batch_builder.cc +15 -12
  218. data/src/core/lib/transport/batch_builder.h +39 -35
  219. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  220. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  221. data/src/ruby/ext/grpc/extconf.rb +8 -9
  222. data/src/ruby/lib/grpc/version.rb +1 -1
  223. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  224. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  225. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  226. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  227. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  228. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  229. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  230. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  231. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  232. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  233. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  234. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  235. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  236. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  237. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  238. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  239. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  240. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  241. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  242. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  243. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  244. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  245. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  246. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  247. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  248. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  249. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  250. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  251. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  252. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  253. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  254. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  255. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  262. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  278. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  279. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  280. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  281. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  282. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  283. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  284. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  286. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  288. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  289. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  295. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  296. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  297. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  298. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  299. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  300. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  301. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  302. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  303. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  304. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  305. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  306. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  307. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  308. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  309. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  310. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  311. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  312. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  313. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  314. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  315. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  316. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  317. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  318. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  319. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  320. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  321. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  322. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  323. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  324. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  325. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  326. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  327. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  328. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  329. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  331. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  332. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  333. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  334. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  336. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  337. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  338. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  339. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  340. data/third_party/cares/cares/include/ares.h +23 -1
  341. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  342. data/third_party/cares/cares/include/ares_rules.h +2 -2
  343. data/third_party/cares/cares/include/ares_version.h +3 -3
  344. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  345. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  346. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  347. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  348. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  349. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  350. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  351. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  352. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  353. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  354. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  355. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  356. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  357. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  358. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  359. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  360. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  361. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  362. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  363. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  364. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  365. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  366. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  367. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  368. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  369. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  370. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  371. metadata +50 -14
  372. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  373. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  374. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -43,6 +43,7 @@ static ULONG g_iocp_kick_token;
43
43
  static OVERLAPPED g_iocp_custom_overlap;
44
44
 
45
45
  static gpr_atm g_custom_events = 0;
46
+ static gpr_atm g_pending_socket_shutdowns = 0;
46
47
 
47
48
  static HANDLE g_iocp;
48
49
 
@@ -90,6 +91,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_core::Timestamp deadline) {
90
91
  } else {
91
92
  abort();
92
93
  }
94
+ gpr_mu_lock(&socket->state_mu);
93
95
  if (socket->shutdown_called) {
94
96
  info->bytes_transferred = 0;
95
97
  info->wsa_error = WSA_OPERATION_ABORTED;
@@ -100,7 +102,11 @@ grpc_iocp_work_status grpc_iocp_work(grpc_core::Timestamp deadline) {
100
102
  info->wsa_error = success ? 0 : WSAGetLastError();
101
103
  }
102
104
  GPR_ASSERT(overlapped == &info->overlapped);
103
- grpc_socket_become_ready(socket, info);
105
+ bool should_destroy = grpc_socket_become_ready(socket, info);
106
+ gpr_mu_unlock(&socket->state_mu);
107
+ if (should_destroy) {
108
+ grpc_winsocket_finish(socket);
109
+ }
104
110
  return GRPC_IOCP_WORK_WORK;
105
111
  }
106
112
 
@@ -122,11 +128,13 @@ void grpc_iocp_kick(void) {
122
128
  void grpc_iocp_flush(void) {
123
129
  grpc_core::ExecCtx exec_ctx;
124
130
  grpc_iocp_work_status work_status;
125
-
131
+ // This method is called during grpc_shutdown. We make the loop
132
+ // spin until any pending socket shutdowns are complete.
126
133
  do {
127
134
  work_status = grpc_iocp_work(grpc_core::Timestamp::InfPast());
128
135
  } while (work_status == GRPC_IOCP_WORK_KICK ||
129
- grpc_core::ExecCtx::Get()->Flush());
136
+ grpc_core::ExecCtx::Get()->Flush() ||
137
+ gpr_atm_acq_load(&g_pending_socket_shutdowns) != 0);
130
138
  }
131
139
 
132
140
  void grpc_iocp_shutdown(void) {
@@ -155,4 +163,17 @@ void grpc_iocp_add_socket(grpc_winsocket* socket) {
155
163
  GPR_ASSERT(ret == g_iocp);
156
164
  }
157
165
 
166
+ void grpc_iocp_register_socket_shutdown_socket_locked(grpc_winsocket* socket) {
167
+ if (!socket->shutdown_registered) {
168
+ socket->shutdown_registered = true;
169
+ gpr_atm_full_fetch_add(&g_pending_socket_shutdowns, 1);
170
+ }
171
+ }
172
+
173
+ void grpc_iocp_finish_socket_shutdown(grpc_winsocket* socket) {
174
+ if (socket->shutdown_registered) {
175
+ gpr_atm_full_fetch_add(&g_pending_socket_shutdowns, -1);
176
+ }
177
+ }
178
+
158
179
  #endif // GRPC_WINSOCK_SOCKET
@@ -43,6 +43,17 @@ void grpc_iocp_flush(void);
43
43
  void grpc_iocp_shutdown(void);
44
44
  void grpc_iocp_add_socket(grpc_winsocket*);
45
45
 
46
+ // Register that this socket has started shutting down.
47
+ // This prevents gRPC from completing its own shutdown until this socket's
48
+ // shutdown is finished. IOCP must continue doing work until all such sockets
49
+ // have finished shutting down. The socket's state_mu must be locked.
50
+ void grpc_iocp_register_socket_shutdown_socket_locked(grpc_winsocket* socket);
51
+
52
+ // Mark that this socket has finished shutting down.
53
+ // The socket's state lock does not need to be held since this function is only
54
+ // called once the socket is ready to be destroyed.
55
+ void grpc_iocp_finish_socket_shutdown(grpc_winsocket* socket);
56
+
46
57
  #endif
47
58
 
48
59
  #endif // GRPC_SRC_CORE_LIB_IOMGR_IOCP_WINDOWS_H
@@ -73,7 +73,7 @@ static bool apple_iomgr_platform_is_any_background_poller_thread(void) {
73
73
  }
74
74
 
75
75
  static bool apple_iomgr_platform_add_closure_to_background_poller(
76
- grpc_closure* closure, grpc_error_handle error) {
76
+ grpc_closure* /*closure*/, grpc_error_handle /*error*/) {
77
77
  return false;
78
78
  }
79
79
 
@@ -357,8 +357,10 @@ grpc_error_handle grpc_set_socket_tcp_user_timeout(
357
357
  return absl::OkStatus();
358
358
  }
359
359
  if (newval != timeout) {
360
- // Do not fail on failing to set TCP_USER_TIMEOUT for now.
361
- gpr_log(GPR_ERROR, "Failed to set TCP_USER_TIMEOUT");
360
+ gpr_log(GPR_INFO,
361
+ "Setting TCP_USER_TIMEOUT to value %d ms. Actual "
362
+ "TCP_USER_TIMEOUT value is %d ms",
363
+ timeout, newval);
362
364
  return absl::OkStatus();
363
365
  }
364
366
  }
@@ -76,6 +76,51 @@ void grpc_winsocket_shutdown(grpc_winsocket* winsocket) {
76
76
  return;
77
77
  }
78
78
  winsocket->shutdown_called = true;
79
+ bool register_shutdown = false;
80
+ // If there is already a scheduled read closure, run it immediately. This
81
+ // follows the same semantics applied to posix endpoint which also runs any
82
+ // already registered closure immediately in the event of a shutdown.
83
+ if (winsocket->read_info.closure && !winsocket->read_info.has_pending_iocp) {
84
+ winsocket->read_info.bytes_transferred = 0;
85
+ winsocket->read_info.wsa_error = WSA_OPERATION_ABORTED;
86
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, winsocket->read_info.closure,
87
+ absl::OkStatus());
88
+ // Note that while the read_info.closure closure is run, it is not set to
89
+ // NULL here. This ensures that the socket cannot get deleted yet until any
90
+ // pending I/O operations are flushed by the thread executing
91
+ // grpc_iocp_work. We set read_info.closure_already_executed_at_shutdown to
92
+ // true so that when the pending read I/O operations are flushed, the
93
+ // associated closure is not executed in the grpc_socket_became_ready
94
+ // function.
95
+ winsocket->read_info.closure_already_executed_at_shutdown = true;
96
+ register_shutdown = true;
97
+ }
98
+
99
+ // If there is already a scheduled write closure, run it immediately. This
100
+ // follows the same semantics applied to posix endpoint which also runs any
101
+ // already registered closure immediately in the event of a shutdown.
102
+ if (winsocket->write_info.closure &&
103
+ !winsocket->write_info.has_pending_iocp) {
104
+ winsocket->write_info.bytes_transferred = 0;
105
+ winsocket->write_info.wsa_error = WSA_OPERATION_ABORTED;
106
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, winsocket->write_info.closure,
107
+ absl::OkStatus());
108
+ // Note that while the write_info.closure closure is run, it is not set to
109
+ // NULL here. This ensures that the socket cannot get deleted yet until any
110
+ // pending I/O operations are flushed by the thread executing
111
+ // grpc_iocp_work. We set
112
+ // write_info.closure.closure_already_executed_at_shutdown to true so that
113
+ // when the pending write I/O operations are flushed, the associated closure
114
+ // is not executed in the grpc_socket_became_ready function.
115
+ winsocket->write_info.closure_already_executed_at_shutdown = true;
116
+ register_shutdown = true;
117
+ }
118
+
119
+ if (register_shutdown) {
120
+ // Instruct gRPC to avoid completing any shutdowns until this socket is
121
+ // cleaned up.
122
+ grpc_iocp_register_socket_shutdown_socket_locked(winsocket);
123
+ }
79
124
  gpr_mu_unlock(&winsocket->state_mu);
80
125
 
81
126
  status = WSAIoctl(winsocket->socket, SIO_GET_EXTENSION_FUNCTION_POINTER,
@@ -90,6 +135,8 @@ void grpc_winsocket_shutdown(grpc_winsocket* winsocket) {
90
135
  utf8_message);
91
136
  gpr_free(utf8_message);
92
137
  }
138
+ // Calling closesocket triggers invocation of any pending I/O operations with
139
+ // ABORTED status.
93
140
  closesocket(winsocket->socket);
94
141
  }
95
142
 
@@ -105,13 +152,20 @@ static bool check_destroyable(grpc_winsocket* winsocket) {
105
152
  winsocket->read_info.closure == NULL;
106
153
  }
107
154
 
155
+ void grpc_winsocket_finish(grpc_winsocket* winsocket) {
156
+ grpc_iocp_finish_socket_shutdown(winsocket);
157
+ destroy(winsocket);
158
+ }
159
+
108
160
  void grpc_winsocket_destroy(grpc_winsocket* winsocket) {
109
161
  gpr_mu_lock(&winsocket->state_mu);
110
162
  GPR_ASSERT(!winsocket->destroy_called);
111
163
  winsocket->destroy_called = true;
112
164
  bool should_destroy = check_destroyable(winsocket);
113
165
  gpr_mu_unlock(&winsocket->state_mu);
114
- if (should_destroy) destroy(winsocket);
166
+ if (should_destroy) {
167
+ grpc_winsocket_finish(winsocket);
168
+ }
115
169
  }
116
170
 
117
171
  // Calling notify_on_read or write means either of two things:
@@ -140,19 +194,19 @@ void grpc_socket_notify_on_read(grpc_winsocket* socket, grpc_closure* closure) {
140
194
  socket_notify_on_iocp(socket, closure, &socket->read_info);
141
195
  }
142
196
 
143
- void grpc_socket_become_ready(grpc_winsocket* socket,
197
+ bool grpc_socket_become_ready(grpc_winsocket* socket,
144
198
  grpc_winsocket_callback_info* info) {
145
199
  GPR_ASSERT(!info->has_pending_iocp);
146
- gpr_mu_lock(&socket->state_mu);
147
200
  if (info->closure) {
148
- grpc_core::ExecCtx::Run(DEBUG_LOCATION, info->closure, absl::OkStatus());
201
+ // Only run the closure once at shutdown.
202
+ if (!info->closure_already_executed_at_shutdown) {
203
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, info->closure, absl::OkStatus());
204
+ }
149
205
  info->closure = NULL;
150
206
  } else {
151
207
  info->has_pending_iocp = 1;
152
208
  }
153
- bool should_destroy = check_destroyable(socket);
154
- gpr_mu_unlock(&socket->state_mu);
155
- if (should_destroy) destroy(socket);
209
+ return check_destroyable(socket);
156
210
  }
157
211
 
158
212
  static gpr_once g_probe_ipv6_once = GPR_ONCE_INIT;
@@ -61,6 +61,9 @@ typedef struct grpc_winsocket_callback_info {
61
61
  // The results of the overlapped operation.
62
62
  DWORD bytes_transferred;
63
63
  int wsa_error;
64
+ // Tracks whether the final closure has already been run when the socket is
65
+ // shut down. This allows closures to be run immediately upon socket shutdown.
66
+ bool closure_already_executed_at_shutdown = false;
64
67
  } grpc_winsocket_callback_info;
65
68
 
66
69
  // This is a wrapper to a Windows socket. A socket can have one outstanding
@@ -81,6 +84,7 @@ typedef struct grpc_winsocket {
81
84
 
82
85
  gpr_mu state_mu;
83
86
  bool shutdown_called;
87
+ bool shutdown_registered;
84
88
 
85
89
  // You can't add the same socket twice to the same IO Completion Port.
86
90
  // This prevents that.
@@ -109,8 +113,8 @@ void grpc_socket_notify_on_write(grpc_winsocket* winsocket,
109
113
  void grpc_socket_notify_on_read(grpc_winsocket* winsocket,
110
114
  grpc_closure* closure);
111
115
 
112
- void grpc_socket_become_ready(grpc_winsocket* winsocket,
113
- grpc_winsocket_callback_info* ci);
116
+ bool grpc_socket_become_ready(grpc_winsocket* socket,
117
+ grpc_winsocket_callback_info* info);
114
118
 
115
119
  // Returns true if this system can create AF_INET6 sockets bound to ::1.
116
120
  // The value is probed once, and cached for the life of the process.
@@ -120,6 +124,9 @@ void grpc_wsa_socket_flags_init();
120
124
 
121
125
  DWORD grpc_get_default_wsa_socket_flags();
122
126
 
127
+ // Final cleanup operations on the socket prior to deletion.
128
+ void grpc_winsocket_finish(grpc_winsocket*);
129
+
123
130
  #endif
124
131
 
125
132
  #endif // GRPC_SRC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H
@@ -33,6 +33,7 @@
33
33
  #include <grpc/support/sync.h>
34
34
 
35
35
  #include "src/core/lib/address_utils/sockaddr_utils.h"
36
+ #include "src/core/lib/event_engine/shim.h"
36
37
  #include "src/core/lib/gprpp/crash.h"
37
38
  #include "src/core/lib/gprpp/host_port.h"
38
39
  #include "src/core/lib/iomgr/cfstream_handle.h"
@@ -40,6 +41,7 @@
40
41
  #include "src/core/lib/iomgr/endpoint_cfstream.h"
41
42
  #include "src/core/lib/iomgr/error.h"
42
43
  #include "src/core/lib/iomgr/error_cfstream.h"
44
+ #include "src/core/lib/iomgr/event_engine_shims/tcp_client.h"
43
45
  #include "src/core/lib/iomgr/tcp_client.h"
44
46
  #include "src/core/lib/iomgr/timer.h"
45
47
 
@@ -149,9 +151,14 @@ static void ParseResolvedAddress(const grpc_resolved_address* addr,
149
151
 
150
152
  static int64_t CFStreamClientConnect(
151
153
  grpc_closure* closure, grpc_endpoint** ep,
152
- grpc_pollset_set* interested_parties,
153
- const grpc_event_engine::experimental::EndpointConfig& /*config*/,
154
+ grpc_pollset_set* /*interested_parties*/,
155
+ const grpc_event_engine::experimental::EndpointConfig& config,
154
156
  const grpc_resolved_address* resolved_addr, grpc_core::Timestamp deadline) {
157
+ if (grpc_event_engine::experimental::UseEventEngineClient()) {
158
+ return grpc_event_engine::experimental::event_engine_tcp_client_connect(
159
+ closure, ep, config, resolved_addr, deadline);
160
+ }
161
+
155
162
  auto addr_uri = grpc_sockaddr_to_uri(resolved_addr);
156
163
  if (!addr_uri.ok()) {
157
164
  grpc_error_handle error = GRPC_ERROR_CREATE(addr_uri.status().ToString());
@@ -198,7 +205,11 @@ static int64_t CFStreamClientConnect(
198
205
  return 0;
199
206
  }
200
207
 
201
- static bool CFStreamClientCancelConnect(int64_t /*connection_handle*/) {
208
+ static bool CFStreamClientCancelConnect(int64_t connection_handle) {
209
+ if (grpc_event_engine::experimental::UseEventEngineClient()) {
210
+ return grpc_event_engine::experimental::
211
+ event_engine_tcp_client_cancel_connect(connection_handle);
212
+ }
202
213
  return false;
203
214
  }
204
215
 
@@ -16,13 +16,16 @@
16
16
  //
17
17
  //
18
18
 
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include <grpc/support/atm.h>
22
+
19
23
  // FIXME: "posix" files shouldn't be depending on _GNU_SOURCE
20
24
  #ifndef _GNU_SOURCE
21
25
  #define _GNU_SOURCE
26
+ #include <grpc/event_engine/event_engine.h>
22
27
  #endif
23
28
 
24
- #include <grpc/support/port_platform.h>
25
-
26
29
  #include "src/core/lib/iomgr/port.h"
27
30
 
28
31
  #ifdef GRPC_POSIX_SOCKET_TCP_SERVER
@@ -86,99 +89,118 @@ using ::grpc_event_engine::experimental::SliceBuffer;
86
89
  static grpc_error_handle CreateEventEngineListener(
87
90
  grpc_tcp_server* s, grpc_closure* shutdown_complete,
88
91
  const EndpointConfig& config, grpc_tcp_server** server) {
89
- PosixEventEngineWithFdSupport::PosixAcceptCallback accept_cb =
90
- [s](int listener_fd, std::unique_ptr<EventEngine::Endpoint> ep,
91
- bool is_external, MemoryAllocator /*allocator*/,
92
- SliceBuffer* pending_data) {
93
- grpc_core::ApplicationCallbackExecCtx app_ctx;
94
- grpc_core::ExecCtx exec_ctx;
95
- grpc_tcp_server_acceptor* acceptor =
96
- static_cast<grpc_tcp_server_acceptor*>(
97
- gpr_malloc(sizeof(*acceptor)));
98
- acceptor->from_server = s;
99
- acceptor->port_index = -1;
100
- acceptor->fd_index = -1;
101
- if (!is_external) {
102
- auto it = s->listen_fd_to_index_map.find(listener_fd);
103
- if (it != s->listen_fd_to_index_map.end()) {
104
- acceptor->port_index = std::get<0>(it->second);
105
- acceptor->fd_index = std::get<1>(it->second);
92
+ absl::StatusOr<std::unique_ptr<EventEngine::Listener>> listener;
93
+ if (grpc_event_engine::experimental::EventEngineSupportsFd()) {
94
+ PosixEventEngineWithFdSupport::PosixAcceptCallback accept_cb =
95
+ [s](int listener_fd, std::unique_ptr<EventEngine::Endpoint> ep,
96
+ bool is_external, MemoryAllocator /*allocator*/,
97
+ SliceBuffer* pending_data) {
98
+ grpc_core::ApplicationCallbackExecCtx app_ctx;
99
+ grpc_core::ExecCtx exec_ctx;
100
+ grpc_tcp_server_acceptor* acceptor =
101
+ static_cast<grpc_tcp_server_acceptor*>(
102
+ gpr_malloc(sizeof(*acceptor)));
103
+ acceptor->from_server = s;
104
+ acceptor->port_index = -1;
105
+ acceptor->fd_index = -1;
106
+ if (!is_external) {
107
+ auto it = s->listen_fd_to_index_map.find(listener_fd);
108
+ if (it != s->listen_fd_to_index_map.end()) {
109
+ acceptor->port_index = std::get<0>(it->second);
110
+ acceptor->fd_index = std::get<1>(it->second);
111
+ }
112
+ } else {
113
+ // External connection handling.
114
+ grpc_resolved_address addr;
115
+ memset(&addr, 0, sizeof(addr));
116
+ addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
117
+ // Get the fd of the socket connected to peer.
118
+ int fd = reinterpret_cast<grpc_event_engine::experimental::
119
+ PosixEndpointWithFdSupport*>(ep.get())
120
+ ->GetWrappedFd();
121
+ if (getpeername(fd, reinterpret_cast<struct sockaddr*>(addr.addr),
122
+ &(addr.len)) < 0) {
123
+ gpr_log(GPR_ERROR, "Failed getpeername: %s",
124
+ grpc_core::StrError(errno).c_str());
125
+ close(fd);
126
+ return;
127
+ }
128
+ (void)grpc_set_socket_no_sigpipe_if_possible(fd);
129
+ auto addr_uri = grpc_sockaddr_to_uri(&addr);
130
+ if (!addr_uri.ok()) {
131
+ gpr_log(GPR_ERROR, "Invalid address: %s",
132
+ addr_uri.status().ToString().c_str());
133
+ return;
134
+ }
135
+ if (grpc_tcp_trace.enabled()) {
136
+ gpr_log(GPR_INFO,
137
+ "SERVER_CONNECT: incoming external connection: %s",
138
+ addr_uri->c_str());
139
+ }
106
140
  }
107
- } else {
108
- // External connection handling.
109
- grpc_resolved_address addr;
110
- memset(&addr, 0, sizeof(addr));
111
- addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
112
- // Get the fd of the socket connected to peer.
113
- int fd =
114
- reinterpret_cast<
115
- grpc_event_engine::experimental::PosixEndpointWithFdSupport*>(
116
- ep.get())
117
- ->GetWrappedFd();
118
- if (getpeername(fd, reinterpret_cast<struct sockaddr*>(addr.addr),
119
- &(addr.len)) < 0) {
120
- gpr_log(GPR_ERROR, "Failed getpeername: %s",
121
- grpc_core::StrError(errno).c_str());
122
- close(fd);
123
- return;
124
- }
125
- (void)grpc_set_socket_no_sigpipe_if_possible(fd);
126
- auto addr_uri = grpc_sockaddr_to_uri(&addr);
127
- if (!addr_uri.ok()) {
128
- gpr_log(GPR_ERROR, "Invalid address: %s",
129
- addr_uri.status().ToString().c_str());
130
- return;
141
+ grpc_pollset* read_notifier_pollset =
142
+ (*(s->pollsets))[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
143
+ &s->next_pollset_to_assign, 1)) %
144
+ s->pollsets->size()];
145
+ acceptor->external_connection = is_external;
146
+ acceptor->listener_fd = listener_fd;
147
+ grpc_byte_buffer* buf = nullptr;
148
+ if (pending_data != nullptr && pending_data->Length() > 0) {
149
+ buf = grpc_raw_byte_buffer_create(nullptr, 0);
150
+ grpc_slice_buffer_swap(&buf->data.raw.slice_buffer,
151
+ pending_data->c_slice_buffer());
152
+ pending_data->Clear();
131
153
  }
132
- if (grpc_tcp_trace.enabled()) {
133
- gpr_log(GPR_INFO,
134
- "SERVER_CONNECT: incoming external connection: %s",
135
- addr_uri->c_str());
136
- }
137
- }
138
- grpc_pollset* read_notifier_pollset =
139
- (*(s->pollsets))[static_cast<size_t>(gpr_atm_no_barrier_fetch_add(
140
- &s->next_pollset_to_assign, 1)) %
141
- s->pollsets->size()];
142
- acceptor->external_connection = is_external;
143
- acceptor->listener_fd = listener_fd;
144
- grpc_byte_buffer* buf = nullptr;
145
- if (pending_data != nullptr && pending_data->Length() > 0) {
146
- buf = grpc_raw_byte_buffer_create(nullptr, 0);
147
- grpc_slice_buffer_swap(&buf->data.raw.slice_buffer,
148
- pending_data->c_slice_buffer());
149
- pending_data->Clear();
150
- }
151
- acceptor->pending_data = buf;
152
- s->on_accept_cb(
153
- s->on_accept_cb_arg,
154
- grpc_event_engine::experimental::grpc_event_engine_endpoint_create(
155
- std::move(ep)),
156
- read_notifier_pollset, acceptor);
157
- };
158
- auto on_shutdown_complete_cb =
159
- grpc_event_engine::experimental::GrpcClosureToStatusCallback(
160
- shutdown_complete);
161
- PosixEventEngineWithFdSupport* engine_ptr =
162
- reinterpret_cast<PosixEventEngineWithFdSupport*>(
163
- config.GetVoidPointer(GRPC_INTERNAL_ARG_EVENT_ENGINE));
164
- // Keeps the engine alive for some tests that have not otherwise instantiated
165
- // an EventEngine
166
- std::shared_ptr<EventEngine> keeper;
167
- if (engine_ptr == nullptr) {
168
- keeper = grpc_event_engine::experimental::GetDefaultEventEngine();
169
- engine_ptr = reinterpret_cast<PosixEventEngineWithFdSupport*>(keeper.get());
170
- }
171
- auto listener = engine_ptr->CreatePosixListener(
172
- std::move(accept_cb),
173
- [s, shutdown_complete](absl::Status status) {
174
- grpc_event_engine::experimental::RunEventEngineClosure(
175
- shutdown_complete, absl_status_to_grpc_error(status));
176
- delete s->fd_handler;
177
- delete s;
178
- },
179
- config,
180
- std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>(
181
- s->memory_quota));
154
+ acceptor->pending_data = buf;
155
+ s->on_accept_cb(s->on_accept_cb_arg,
156
+ grpc_event_engine::experimental::
157
+ grpc_event_engine_endpoint_create(std::move(ep)),
158
+ read_notifier_pollset, acceptor);
159
+ };
160
+ PosixEventEngineWithFdSupport* engine_ptr =
161
+ reinterpret_cast<PosixEventEngineWithFdSupport*>(
162
+ config.GetVoidPointer(GRPC_INTERNAL_ARG_EVENT_ENGINE));
163
+ // Keeps the engine alive for some tests that have not otherwise
164
+ // instantiated an EventEngine
165
+ std::shared_ptr<EventEngine> keeper;
166
+ if (engine_ptr == nullptr) {
167
+ keeper = grpc_event_engine::experimental::GetDefaultEventEngine();
168
+ engine_ptr =
169
+ reinterpret_cast<PosixEventEngineWithFdSupport*>(keeper.get());
170
+ }
171
+ listener = engine_ptr->CreatePosixListener(
172
+ std::move(accept_cb),
173
+ [s, shutdown_complete](absl::Status status) {
174
+ grpc_event_engine::experimental::RunEventEngineClosure(
175
+ shutdown_complete, absl_status_to_grpc_error(status));
176
+ delete s->fd_handler;
177
+ delete s;
178
+ },
179
+ config,
180
+ std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>(
181
+ s->memory_quota));
182
+ } else {
183
+ EventEngine::Listener::AcceptCallback accept_cb =
184
+ [s](std::unique_ptr<EventEngine::Endpoint> ep, MemoryAllocator) {
185
+ s->on_accept_cb(s->on_accept_cb_arg,
186
+ grpc_event_engine::experimental::
187
+ grpc_event_engine_endpoint_create(std::move(ep)),
188
+ nullptr, nullptr);
189
+ };
190
+ auto ee = grpc_event_engine::experimental::GetDefaultEventEngine();
191
+ listener = ee->CreateListener(
192
+ std::move(accept_cb),
193
+ [s, ee, shutdown_complete](absl::Status status) {
194
+ GPR_ASSERT(gpr_atm_no_barrier_load(&s->refs.count) == 0);
195
+ grpc_event_engine::experimental::RunEventEngineClosure(
196
+ shutdown_complete, absl_status_to_grpc_error(status));
197
+ delete s->fd_handler;
198
+ delete s;
199
+ },
200
+ config,
201
+ std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>(
202
+ s->memory_quota));
203
+ }
182
204
  if (!listener.ok()) {
183
205
  delete s;
184
206
  *server = nullptr;
@@ -565,16 +587,27 @@ static grpc_error_handle tcp_server_add_port(grpc_tcp_server* s,
565
587
  return absl::UnknownError("Server already shutdown");
566
588
  }
567
589
  int fd_index = 0;
568
- auto port = s->ee_listener->BindWithFd(
569
- grpc_event_engine::experimental::CreateResolvedAddress(*addr),
570
- [s, &fd_index](absl::StatusOr<int> listen_fd) {
571
- if (!listen_fd.ok()) {
572
- return;
573
- }
574
- GPR_DEBUG_ASSERT(*listen_fd > 0);
575
- s->listen_fd_to_index_map.insert_or_assign(
576
- *listen_fd, std::make_tuple(s->n_bind_ports, fd_index++));
577
- });
590
+ absl::StatusOr<int> port;
591
+ if (grpc_event_engine::experimental::EventEngineSupportsFd()) {
592
+ port =
593
+ static_cast<
594
+ grpc_event_engine::experimental::PosixListenerWithFdSupport*>(
595
+ s->ee_listener.get())
596
+ ->BindWithFd(
597
+ grpc_event_engine::experimental::CreateResolvedAddress(*addr),
598
+ [s, &fd_index](absl::StatusOr<int> listen_fd) {
599
+ if (!listen_fd.ok()) {
600
+ return;
601
+ }
602
+ GPR_DEBUG_ASSERT(*listen_fd > 0);
603
+ s->listen_fd_to_index_map.insert_or_assign(
604
+ *listen_fd,
605
+ std::make_tuple(s->n_bind_ports, fd_index++));
606
+ });
607
+ } else {
608
+ port = s->ee_listener->Bind(
609
+ grpc_event_engine::experimental::CreateResolvedAddress(*addr));
610
+ }
578
611
  if (port.ok()) {
579
612
  s->n_bind_ports++;
580
613
  *out_port = *port;
@@ -774,7 +807,11 @@ static void tcp_server_shutdown_listeners(grpc_tcp_server* s) {
774
807
  gpr_mu_lock(&s->mu);
775
808
  s->shutdown_listeners = true;
776
809
  if (grpc_event_engine::experimental::UseEventEngineListener()) {
777
- s->ee_listener->ShutdownListeningFds();
810
+ if (grpc_event_engine::experimental::EventEngineSupportsFd()) {
811
+ static_cast<grpc_event_engine::experimental::PosixListenerWithFdSupport*>(
812
+ s->ee_listener.get())
813
+ ->ShutdownListeningFds();
814
+ }
778
815
  }
779
816
  /* shutdown all fd's */
780
817
  if (s->active_ports) {
@@ -804,15 +841,19 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
804
841
  // TODO(yangg) resolve duplicate code with on_read
805
842
  void Handle(int listener_fd, int fd, grpc_byte_buffer* buf) override {
806
843
  if (grpc_event_engine::experimental::UseEventEngineListener()) {
844
+ GPR_ASSERT(grpc_event_engine::experimental::EventEngineSupportsFd());
807
845
  grpc_event_engine::experimental::SliceBuffer pending_data;
808
846
  if (buf != nullptr) {
809
847
  pending_data =
810
848
  grpc_event_engine::experimental::SliceBuffer::TakeCSliceBuffer(
811
849
  buf->data.raw.slice_buffer);
812
850
  }
813
- GPR_ASSERT(GRPC_LOG_IF_ERROR("listener_handle_external_connection",
814
- s_->ee_listener->HandleExternalConnection(
815
- listener_fd, fd, &pending_data)));
851
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
852
+ "listener_handle_external_connection",
853
+ static_cast<
854
+ grpc_event_engine::experimental::PosixListenerWithFdSupport*>(
855
+ s_->ee_listener.get())
856
+ ->HandleExternalConnection(listener_fd, fd, &pending_data)));
816
857
  return;
817
858
  }
818
859
  grpc_pollset* read_notifier_pollset;
@@ -107,7 +107,7 @@ struct grpc_tcp_server {
107
107
  /* used when event engine based servers are enabled */
108
108
  int n_bind_ports = 0;
109
109
  absl::flat_hash_map<int, std::tuple<int, int>> listen_fd_to_index_map;
110
- std::unique_ptr<grpc_event_engine::experimental::PosixListenerWithFdSupport>
110
+ std::unique_ptr<grpc_event_engine::experimental::EventEngine::Listener>
111
111
  ee_listener = nullptr;
112
112
  /* used to store a pre-allocated FD assigned to a socket */
113
113
  int pre_allocated_fd;
@@ -634,7 +634,7 @@ static grpc_error_handle event_engine_create(grpc_closure* shutdown_complete,
634
634
  engine_ptr->poller(), std::move(accept_cb), std::move(on_shutdown),
635
635
  std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>(
636
636
  resource_quota->memory_quota()),
637
- engine_ptr->shared_from_this(), engine_ptr->executor(), config);
637
+ engine_ptr->shared_from_this(), engine_ptr->thread_pool(), config);
638
638
  s->active_ports = -1;
639
639
  s->on_accept_cb = [](void* /* arg */, grpc_endpoint* /* ep */,
640
640
  grpc_pollset* /* accepting_pollset */,