grpc 1.38.0 → 1.40.0

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 (340) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +68 -21
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +23 -29
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +21 -36
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +33 -19
  11. data/include/grpc/impl/codegen/port_platform.h +41 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +415 -249
  13. data/src/core/ext/filters/client_channel/client_channel.h +42 -18
  14. data/src/core/ext/filters/client_channel/config_selector.h +19 -6
  15. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  16. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  17. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
  20. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
  21. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
  24. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -36
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +68 -103
  29. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
  30. data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  34. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  35. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  36. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +116 -76
  37. data/src/core/ext/filters/client_channel/retry_filter.cc +967 -544
  38. data/src/core/ext/filters/client_channel/retry_service_config.cc +57 -28
  39. data/src/core/ext/filters/client_channel/retry_service_config.h +9 -3
  40. data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
  41. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
  43. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
  47. data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +23 -16
  48. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +12 -10
  50. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  52. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
  53. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
  54. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
  56. data/src/core/ext/transport/chttp2/transport/internal.h +2 -1
  57. data/src/core/ext/transport/chttp2/transport/parsing.cc +72 -56
  58. data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
  59. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  60. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
  61. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
  62. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
  66. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
  73. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
  74. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
  75. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
  76. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
  77. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
  78. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
  79. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
  80. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
  81. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
  82. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
  83. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
  84. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
  85. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
  86. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
  87. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
  88. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
  89. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
  90. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
  91. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
  92. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
  93. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
  94. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
  95. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
  96. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
  97. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
  98. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
  99. data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
  100. data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
  101. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
  102. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
  103. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
  104. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
  105. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
  106. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
  107. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
  108. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
  109. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
  110. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
  111. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
  112. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
  113. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
  114. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
  115. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
  116. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
  117. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  118. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
  119. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
  120. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
  121. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
  122. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
  123. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  124. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
  125. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  126. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
  127. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
  128. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
  129. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
  130. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
  131. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
  132. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
  133. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
  134. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
  135. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
  136. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
  137. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
  138. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
  139. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  140. data/src/core/ext/xds/xds_api.cc +582 -257
  141. data/src/core/ext/xds/xds_api.h +46 -8
  142. data/src/core/ext/xds/xds_bootstrap.cc +4 -1
  143. data/src/core/ext/xds/xds_client.cc +66 -43
  144. data/src/core/ext/xds/xds_client.h +0 -4
  145. data/src/core/ext/xds/xds_http_filters.cc +3 -2
  146. data/src/core/ext/xds/xds_http_filters.h +3 -0
  147. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  148. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  149. data/src/core/lib/channel/call_tracer.h +85 -0
  150. data/src/core/lib/channel/channel_stack.h +1 -1
  151. data/src/core/lib/channel/channelz.h +3 -0
  152. data/src/core/lib/channel/context.h +3 -0
  153. data/src/core/lib/channel/status_util.h +4 -0
  154. data/src/core/lib/compression/stream_compression.h +1 -1
  155. data/src/core/lib/compression/stream_compression_gzip.h +1 -1
  156. data/src/core/lib/compression/stream_compression_identity.h +1 -1
  157. data/src/core/lib/debug/stats.h +1 -1
  158. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  159. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  160. data/src/core/lib/event_engine/event_engine.cc +50 -0
  161. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  162. data/src/core/lib/event_engine/sockaddr.h +44 -0
  163. data/src/core/lib/gpr/murmur_hash.cc +4 -2
  164. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  165. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  166. data/src/core/lib/gprpp/orphanable.h +3 -3
  167. data/src/core/lib/gprpp/status_helper.h +3 -0
  168. data/src/core/lib/gprpp/sync.h +2 -30
  169. data/src/core/lib/iomgr/buffer_list.cc +1 -1
  170. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  171. data/src/core/lib/iomgr/error.cc +5 -4
  172. data/src/core/lib/iomgr/error.h +1 -1
  173. data/src/core/lib/iomgr/ev_apple.h +1 -1
  174. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  175. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  176. data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
  177. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  178. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  179. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  180. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  181. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  182. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  183. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  184. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  185. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  186. data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
  187. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  188. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  189. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  190. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  191. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  192. data/src/core/lib/iomgr/iomgr.cc +1 -1
  193. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  194. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  195. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  196. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  197. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  198. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  199. data/src/core/lib/iomgr/port.h +7 -5
  200. data/src/core/lib/iomgr/python_util.h +1 -1
  201. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  202. data/src/core/lib/iomgr/resolve_address.h +6 -0
  203. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  204. data/src/core/lib/iomgr/sockaddr.h +1 -0
  205. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  206. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  207. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  208. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  209. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  210. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
  211. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  212. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  213. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  214. data/src/core/lib/iomgr/tcp_server_posix.cc +7 -0
  215. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  216. data/src/core/lib/iomgr/timer.h +6 -1
  217. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  218. data/src/core/lib/json/json_reader.cc +1 -2
  219. data/src/core/lib/matchers/matchers.cc +8 -20
  220. data/src/core/lib/matchers/matchers.h +2 -1
  221. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  222. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  223. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  224. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  225. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  226. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  227. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
  228. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
  229. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  230. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  231. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  232. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  233. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
  234. data/src/core/lib/security/transport/security_handshaker.cc +12 -4
  235. data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
  236. data/src/core/lib/slice/slice.cc +12 -2
  237. data/src/core/lib/slice/slice_internal.h +1 -0
  238. data/src/core/lib/surface/call.cc +26 -7
  239. data/src/core/lib/surface/call.h +11 -0
  240. data/src/core/lib/surface/completion_queue.cc +22 -22
  241. data/src/core/lib/surface/completion_queue.h +1 -1
  242. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  243. data/src/core/lib/surface/init.cc +1 -3
  244. data/src/core/lib/surface/init.h +10 -1
  245. data/src/core/lib/surface/server.cc +3 -1
  246. data/src/core/lib/surface/server.h +3 -3
  247. data/src/core/lib/surface/version.cc +2 -4
  248. data/src/core/lib/transport/error_utils.cc +2 -2
  249. data/src/core/lib/transport/metadata_batch.cc +13 -2
  250. data/src/core/lib/transport/metadata_batch.h +7 -0
  251. data/src/core/lib/transport/transport.h +2 -0
  252. data/src/core/lib/transport/transport_op_string.cc +1 -1
  253. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  254. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  255. data/src/ruby/ext/grpc/extconf.rb +2 -0
  256. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  257. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  258. data/src/ruby/lib/grpc/version.rb +1 -1
  259. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  260. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  261. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  262. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  264. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  277. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  278. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  279. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  280. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  281. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  282. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  283. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  284. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  286. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  288. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  289. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  297. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  298. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  299. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  300. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  301. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  302. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  303. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  304. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  305. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  306. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  307. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  308. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  309. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  310. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  311. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  312. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  313. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  314. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  315. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  316. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  317. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  318. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  319. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  320. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  321. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  322. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  323. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  324. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  325. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  326. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  327. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  328. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  331. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  332. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  334. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  336. data/third_party/xxhash/xxhash.h +77 -195
  337. metadata +81 -39
  338. data/src/core/lib/gpr/arena.h +0 -47
  339. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  340. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -0,0 +1,24 @@
1
+ // Copyright 2021 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_CORE_LIB_IOMGR_EVENT_ENGINE_IOMGR_H
15
+ #define GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_IOMGR_H
16
+ #include <grpc/support/port_platform.h>
17
+
18
+ #include <grpc/event_engine/event_engine.h>
19
+
20
+ // This can be called anywhere in the EE-based iomgr impl where we need to
21
+ // access the global EE instance.
22
+ grpc_event_engine::experimental::EventEngine* grpc_iomgr_event_engine();
23
+
24
+ #endif // GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_IOMGR_H
@@ -0,0 +1,87 @@
1
+ // Copyright 2021 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
+ #include <grpc/support/port_platform.h>
15
+
16
+ #ifdef GRPC_USE_EVENT_ENGINE
17
+ #include <grpc/event_engine/event_engine.h>
18
+
19
+ #include "src/core/lib/iomgr/event_engine/pollset.h"
20
+ #include "src/core/lib/iomgr/iomgr_internal.h"
21
+ #include "src/core/lib/iomgr/pollset.h"
22
+ #include "src/core/lib/iomgr/pollset_set.h"
23
+
24
+ namespace {
25
+
26
+ static gpr_mu g_mu;
27
+ static gpr_cv g_cv;
28
+
29
+ // --- pollset vtable API ---
30
+ void pollset_global_init(void) {
31
+ gpr_mu_init(&g_mu);
32
+ gpr_cv_init(&g_cv);
33
+ }
34
+ void pollset_global_shutdown(void) {
35
+ gpr_cv_destroy(&g_cv);
36
+ gpr_mu_destroy(&g_mu);
37
+ }
38
+ void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { *mu = &g_mu; }
39
+ void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
40
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
41
+ }
42
+ void pollset_destroy(grpc_pollset* pollset) {}
43
+ grpc_error* pollset_work(grpc_pollset* pollset, grpc_pollset_worker** worker,
44
+ grpc_millis deadline) {
45
+ (void)worker;
46
+ gpr_cv_wait(&g_cv, &g_mu,
47
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME));
48
+ return GRPC_ERROR_NONE;
49
+ }
50
+ grpc_error* pollset_kick(grpc_pollset* pollset,
51
+ grpc_pollset_worker* specific_worker) {
52
+ (void)pollset;
53
+ (void)specific_worker;
54
+ return GRPC_ERROR_NONE;
55
+ }
56
+ size_t pollset_size(void) { return 1; }
57
+
58
+ // --- pollset_set vtable API ---
59
+ grpc_pollset_set* pollset_set_create(void) { return nullptr; }
60
+ void pollset_set_destroy(grpc_pollset_set* pollset_set) {}
61
+ void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
62
+ grpc_pollset* pollset) {}
63
+
64
+ void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
65
+ grpc_pollset* pollset) {}
66
+ void pollset_set_add_pollset_set(grpc_pollset_set* bag,
67
+ grpc_pollset_set* item) {}
68
+ void pollset_set_del_pollset_set(grpc_pollset_set* bag,
69
+ grpc_pollset_set* item) {}
70
+
71
+ } // namespace
72
+
73
+ void grpc_pollset_ee_broadcast_event() { gpr_cv_signal(&g_cv); }
74
+
75
+ // --- vtables ---
76
+ grpc_pollset_vtable grpc_event_engine_pollset_vtable = {
77
+ pollset_global_init, pollset_global_shutdown,
78
+ pollset_init, pollset_shutdown,
79
+ pollset_destroy, pollset_work,
80
+ pollset_kick, pollset_size};
81
+
82
+ grpc_pollset_set_vtable grpc_event_engine_pollset_set_vtable = {
83
+ pollset_set_create, pollset_set_destroy,
84
+ pollset_set_add_pollset, pollset_set_del_pollset,
85
+ pollset_set_add_pollset_set, pollset_set_del_pollset_set};
86
+
87
+ #endif // GRPC_USE_EVENT_ENGINE
@@ -11,18 +11,15 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- #ifndef GRPC_EVENT_ENGINE_CHANNEL_ARGS_H
15
- #define GRPC_EVENT_ENGINE_CHANNEL_ARGS_H
14
+ #ifndef GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_POLLSET_H
15
+ #define GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_POLLSET_H
16
16
 
17
17
  #include <grpc/support/port_platform.h>
18
18
 
19
- namespace grpc_event_engine {
20
- namespace experimental {
19
+ #ifdef GRPC_USE_EVENT_ENGINE
21
20
 
22
- // TODO(hork): define
23
- class ChannelArgs;
21
+ /// Signals pollset_work that some work has been done.
22
+ void grpc_pollset_ee_broadcast_event();
24
23
 
25
- } // namespace experimental
26
- } // namespace grpc_event_engine
27
-
28
- #endif // GRPC_EVENT_ENGINE_CHANNEL_ARGS_H
24
+ #endif
25
+ #endif // GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_POLLSET_H
@@ -0,0 +1,51 @@
1
+ // Copyright 2021 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_CORE_LIB_IOMGR_EVENT_ENGINE_PROMISE_H
15
+ #define GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_PROMISE_H
16
+ #include <grpc/support/port_platform.h>
17
+
18
+ #include "src/core/lib/gprpp/sync.h"
19
+
20
+ namespace grpc_event_engine {
21
+ namespace experimental {
22
+
23
+ /// A minimal promise implementation.
24
+ ///
25
+ /// This is light-duty, syntactical sugar around cv wait & signal, which is
26
+ /// useful in some cases. A more robust implementation is being worked on
27
+ /// separately.
28
+ template <typename T>
29
+ class Promise {
30
+ public:
31
+ T& Get() {
32
+ absl::MutexLock lock(&mu_);
33
+ cv_.Wait(&mu_);
34
+ return val_;
35
+ }
36
+ void Set(T&& val) {
37
+ absl::MutexLock lock(&mu_);
38
+ val_ = std::move(val);
39
+ cv_.Signal();
40
+ }
41
+
42
+ private:
43
+ absl::Mutex mu_;
44
+ absl::CondVar cv_;
45
+ T val_;
46
+ };
47
+
48
+ } // namespace experimental
49
+ } // namespace grpc_event_engine
50
+
51
+ #endif // GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_PROMISE_H
@@ -0,0 +1,41 @@
1
+ // Copyright 2021 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
+ #include <grpc/support/port_platform.h>
15
+
16
+ #include "src/core/lib/iomgr/event_engine/resolved_address_internal.h"
17
+
18
+ #include <grpc/event_engine/event_engine.h>
19
+
20
+ #include "src/core/lib/address_utils/sockaddr_utils.h"
21
+ #include "src/core/lib/iomgr/resolve_address.h"
22
+
23
+ namespace grpc_event_engine {
24
+ namespace experimental {
25
+
26
+ EventEngine::ResolvedAddress CreateResolvedAddress(
27
+ const grpc_resolved_address& addr) {
28
+ return EventEngine::ResolvedAddress(
29
+ reinterpret_cast<const sockaddr*>(addr.addr), addr.len);
30
+ }
31
+
32
+ grpc_resolved_address CreateGRPCResolvedAddress(
33
+ const EventEngine::ResolvedAddress& ra) {
34
+ grpc_resolved_address grpc_addr;
35
+ memcpy(grpc_addr.addr, ra.address(), ra.size());
36
+ grpc_addr.len = ra.size();
37
+ return grpc_addr;
38
+ }
39
+
40
+ } // namespace experimental
41
+ } // namespace grpc_event_engine
@@ -0,0 +1,35 @@
1
+ // Copyright 2021 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_CORE_LIB_IOMGR_EVENT_ENGINE_RESOLVED_ADDRESS_INTERNAL_H
15
+ #define GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_RESOLVED_ADDRESS_INTERNAL_H
16
+
17
+ #include <grpc/support/port_platform.h>
18
+
19
+ #include <grpc/event_engine/event_engine.h>
20
+
21
+ #include "src/core/lib/iomgr/resolve_address.h"
22
+
23
+ namespace grpc_event_engine {
24
+ namespace experimental {
25
+
26
+ EventEngine::ResolvedAddress CreateResolvedAddress(
27
+ const grpc_resolved_address& addr);
28
+
29
+ grpc_resolved_address CreateGRPCResolvedAddress(
30
+ const EventEngine::ResolvedAddress& ra);
31
+
32
+ } // namespace experimental
33
+ } // namespace grpc_event_engine
34
+
35
+ #endif // GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_RESOLVED_ADDRESS_INTERNAL_H
@@ -0,0 +1,110 @@
1
+ // Copyright 2021 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
+ #include <grpc/support/port_platform.h>
15
+
16
+ #ifdef GRPC_USE_EVENT_ENGINE
17
+ #include <grpc/event_engine/event_engine.h>
18
+ #include "absl/functional/bind_front.h"
19
+
20
+ #include "src/core/lib/address_utils/sockaddr_utils.h"
21
+ #include "src/core/lib/gprpp/sync.h"
22
+ #include "src/core/lib/iomgr/error.h"
23
+ #include "src/core/lib/iomgr/event_engine/iomgr.h"
24
+ #include "src/core/lib/iomgr/event_engine/promise.h"
25
+ #include "src/core/lib/iomgr/event_engine/resolved_address_internal.h"
26
+ #include "src/core/lib/iomgr/resolve_address.h"
27
+ #include "src/core/lib/iomgr/work_serializer.h"
28
+ #include "src/core/lib/surface/init.h"
29
+ #include "src/core/lib/transport/error_utils.h"
30
+
31
+ namespace {
32
+ using ::grpc_event_engine::experimental::CreateGRPCResolvedAddress;
33
+ using ::grpc_event_engine::experimental::EventEngine;
34
+ using ::grpc_event_engine::experimental::Promise;
35
+
36
+ /// A fire-and-forget class representing an individual DNS request.
37
+ ///
38
+ /// This provides a place to store the ownership of the DNSResolver object until
39
+ /// the request is complete.
40
+ class DnsRequest {
41
+ public:
42
+ DnsRequest(std::unique_ptr<EventEngine::DNSResolver> dns_resolver,
43
+ absl::string_view address, absl::string_view default_port,
44
+ grpc_closure* on_done, grpc_resolved_addresses** addresses)
45
+ : dns_resolver_(std::move(dns_resolver)),
46
+ cb_(on_done),
47
+ addresses_(addresses) {
48
+ dns_resolver_->LookupHostname(
49
+ absl::bind_front(&DnsRequest::OnLookupComplete, this), address,
50
+ default_port, absl::InfiniteFuture());
51
+ }
52
+
53
+ private:
54
+ void OnLookupComplete(
55
+ absl::StatusOr<std::vector<EventEngine::ResolvedAddress>> addresses) {
56
+ grpc_core::ExecCtx exec_ctx;
57
+ // Convert addresses to iomgr form.
58
+ *addresses_ = static_cast<grpc_resolved_addresses*>(
59
+ gpr_malloc(sizeof(grpc_resolved_addresses)));
60
+ (*addresses_)->naddrs = addresses->size();
61
+ (*addresses_)->addrs = static_cast<grpc_resolved_address*>(
62
+ gpr_malloc(sizeof(grpc_resolved_address) * addresses->size()));
63
+ for (size_t i = 0; i < addresses->size(); ++i) {
64
+ (*addresses_)->addrs[i] = CreateGRPCResolvedAddress((*addresses)[i]);
65
+ }
66
+ grpc_closure* cb = cb_;
67
+ delete this;
68
+ grpc_core::Closure::Run(DEBUG_LOCATION, cb,
69
+ absl_status_to_grpc_error(addresses.status()));
70
+ }
71
+
72
+ std::unique_ptr<EventEngine::DNSResolver> dns_resolver_;
73
+ grpc_closure* cb_;
74
+ grpc_resolved_addresses** addresses_;
75
+ };
76
+
77
+ void resolve_address(const char* addr, const char* default_port,
78
+ grpc_pollset_set* /* interested_parties */,
79
+ grpc_closure* on_done,
80
+ grpc_resolved_addresses** addresses) {
81
+ auto dns_resolver = grpc_iomgr_event_engine()->GetDNSResolver();
82
+ if (!dns_resolver.ok()) {
83
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_done,
84
+ absl_status_to_grpc_error(dns_resolver.status()));
85
+ return;
86
+ }
87
+ new DnsRequest(std::move(*dns_resolver), addr, default_port, on_done,
88
+ addresses);
89
+ }
90
+
91
+ void blocking_handle_async_resolve_done(void* arg, grpc_error_handle error) {
92
+ static_cast<Promise<grpc_error_handle>*>(arg)->Set(std::move(error));
93
+ }
94
+
95
+ grpc_error* blocking_resolve_address(const char* name, const char* default_port,
96
+ grpc_resolved_addresses** addresses) {
97
+ grpc_closure on_done;
98
+ Promise<grpc_error_handle> evt;
99
+ GRPC_CLOSURE_INIT(&on_done, blocking_handle_async_resolve_done, &evt,
100
+ grpc_schedule_on_exec_ctx);
101
+ resolve_address(name, default_port, nullptr, &on_done, addresses);
102
+ return evt.Get();
103
+ }
104
+
105
+ } // namespace
106
+
107
+ grpc_address_resolver_vtable grpc_event_engine_resolver_vtable{
108
+ resolve_address, blocking_resolve_address};
109
+
110
+ #endif // GRPC_USE_EVENT_ENGINE
@@ -0,0 +1,263 @@
1
+ // Copyright 2021 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
+ #include <grpc/support/port_platform.h>
15
+
16
+ #ifdef GRPC_USE_EVENT_ENGINE
17
+ #include <grpc/event_engine/event_engine.h>
18
+
19
+ #include "src/core/lib/address_utils/sockaddr_utils.h"
20
+ #include "src/core/lib/event_engine/endpoint_config_internal.h"
21
+ #include "src/core/lib/event_engine/sockaddr.h"
22
+ #include "src/core/lib/gprpp/ref_counted.h"
23
+ #include "src/core/lib/iomgr/event_engine/closure.h"
24
+ #include "src/core/lib/iomgr/event_engine/endpoint.h"
25
+ #include "src/core/lib/iomgr/event_engine/iomgr.h"
26
+ #include "src/core/lib/iomgr/event_engine/pollset.h"
27
+ #include "src/core/lib/iomgr/resolve_address.h"
28
+ #include "src/core/lib/iomgr/tcp_client.h"
29
+ #include "src/core/lib/iomgr/tcp_server.h"
30
+ #include "src/core/lib/surface/init.h"
31
+ #include "src/core/lib/transport/error_utils.h"
32
+
33
+ extern grpc_core::TraceFlag grpc_tcp_trace;
34
+
35
+ namespace {
36
+ using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig;
37
+ using ::grpc_event_engine::experimental::EventEngine;
38
+ using ::grpc_event_engine::experimental::GrpcClosureToCallback;
39
+ using ::grpc_event_engine::experimental::SliceAllocator;
40
+ using ::grpc_event_engine::experimental::SliceAllocatorFactory;
41
+ using ::grpc_event_engine::experimental::SliceBuffer;
42
+ } // namespace
43
+
44
+ // TODO(hork): remove these classes in PR #26643, when the iomgr APIs change to
45
+ // accept SliceAllocators and SliceAllocatorFactory(ie)s. In the meantime, the
46
+ // libuv work has temporary implementations as well.
47
+ class NoopSliceAllocator : public SliceAllocator {
48
+ public:
49
+ absl::Status Allocate(size_t size, SliceBuffer* dest,
50
+ SliceAllocator::AllocateCallback cb) {
51
+ return absl::OkStatus();
52
+ }
53
+ };
54
+
55
+ class NoopSliceAllocatorFactory : public SliceAllocatorFactory {
56
+ public:
57
+ std::unique_ptr<SliceAllocator> CreateSliceAllocator(
58
+ absl::string_view peer_name) {
59
+ return absl::make_unique<NoopSliceAllocator>();
60
+ };
61
+ };
62
+
63
+ struct grpc_tcp_server {
64
+ explicit grpc_tcp_server(std::unique_ptr<EventEngine::Listener> listener)
65
+ : refcount(1, GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace) ? "tcp" : nullptr),
66
+ listener(std::move(listener)) {
67
+ shutdown_starting.head = nullptr;
68
+ shutdown_starting.tail = nullptr;
69
+ };
70
+ ~grpc_tcp_server() {
71
+ grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &shutdown_starting);
72
+ grpc_core::ExecCtx::Get()->Flush();
73
+ }
74
+ grpc_core::RefCount refcount;
75
+ grpc_core::Mutex mu;
76
+ std::unique_ptr<EventEngine::Listener> listener;
77
+ grpc_closure_list shutdown_starting ABSL_GUARDED_BY(mu);
78
+ grpc_tcp_server_cb on_accept_internal;
79
+ void* on_accept_internal_arg;
80
+ };
81
+
82
+ namespace {
83
+
84
+ /// Converts a grpc_closure to an EventEngine Callback. The closure is expected
85
+ /// to already be initialized.
86
+ EventEngine::OnConnectCallback GrpcClosureToOnConnectCallback(
87
+ grpc_closure* closure, grpc_endpoint** endpoint_ptr) {
88
+ return [closure, endpoint_ptr](
89
+ absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) {
90
+ grpc_core::ExecCtx exec_ctx;
91
+ if (endpoint.ok()) {
92
+ auto* grpc_endpoint_out =
93
+ reinterpret_cast<grpc_event_engine_endpoint*>(*endpoint_ptr);
94
+ grpc_endpoint_out->endpoint = std::move(*endpoint);
95
+ } else {
96
+ grpc_endpoint_destroy(*endpoint_ptr);
97
+ *endpoint_ptr = nullptr;
98
+ }
99
+ grpc_core::Closure::Run(DEBUG_LOCATION, closure,
100
+ absl_status_to_grpc_error(endpoint.status()));
101
+ exec_ctx.Flush();
102
+ grpc_pollset_ee_broadcast_event();
103
+ };
104
+ }
105
+
106
+ /// Usage note: this method does not take ownership of any pointer arguments.
107
+ void tcp_connect(grpc_closure* on_connect, grpc_endpoint** endpoint,
108
+ grpc_pollset_set* /* interested_parties */,
109
+ const grpc_channel_args* channel_args,
110
+ const grpc_resolved_address* addr, grpc_millis deadline) {
111
+ grpc_event_engine_endpoint* ee_endpoint =
112
+ reinterpret_cast<grpc_event_engine_endpoint*>(
113
+ grpc_tcp_create(channel_args, grpc_sockaddr_to_uri(addr)));
114
+ *endpoint = &ee_endpoint->base;
115
+ EventEngine::OnConnectCallback ee_on_connect =
116
+ GrpcClosureToOnConnectCallback(on_connect, endpoint);
117
+ // TODO(hork): tcp_connect will change to accept a SliceAllocator. This is
118
+ // temporary.
119
+ auto sa = absl::make_unique<NoopSliceAllocator>();
120
+ EventEngine::ResolvedAddress ra(reinterpret_cast<const sockaddr*>(addr->addr),
121
+ addr->len);
122
+ absl::Time ee_deadline = grpc_core::ToAbslTime(
123
+ grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
124
+ ChannelArgsEndpointConfig endpoint_config(channel_args);
125
+ absl::Status connected = grpc_iomgr_event_engine()->Connect(
126
+ ee_on_connect, ra, endpoint_config, std::move(sa), ee_deadline);
127
+ if (!connected.ok()) {
128
+ // EventEngine failed to start an asynchronous connect.
129
+ grpc_endpoint_destroy(*endpoint);
130
+ *endpoint = nullptr;
131
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_connect,
132
+ absl_status_to_grpc_error(connected));
133
+ }
134
+ }
135
+
136
+ grpc_error* tcp_server_create(grpc_closure* shutdown_complete,
137
+ const grpc_channel_args* args,
138
+ grpc_tcp_server** server) {
139
+ ChannelArgsEndpointConfig endpoint_config(args);
140
+ grpc_resource_quota* rq = grpc_resource_quota_from_channel_args(args);
141
+ if (rq == nullptr) {
142
+ rq = grpc_resource_quota_create(nullptr);
143
+ }
144
+ // TODO(hork): tcp_server_create will change to accept a
145
+ // SliceAllocatorFactory. This is temporary.
146
+ auto saf = absl::make_unique<NoopSliceAllocatorFactory>();
147
+ EventEngine* event_engine = grpc_iomgr_event_engine();
148
+ absl::StatusOr<std::unique_ptr<EventEngine::Listener>> listener =
149
+ event_engine->CreateListener(
150
+ [server](std::unique_ptr<EventEngine::Endpoint> ee_endpoint) {
151
+ grpc_core::ExecCtx exec_ctx;
152
+ GPR_ASSERT((*server)->on_accept_internal != nullptr);
153
+ grpc_event_engine_endpoint* iomgr_endpoint =
154
+ grpc_tcp_server_endpoint_create(std::move(ee_endpoint));
155
+ grpc_tcp_server_acceptor* acceptor =
156
+ static_cast<grpc_tcp_server_acceptor*>(
157
+ gpr_zalloc(sizeof(*acceptor)));
158
+ acceptor->from_server = *server;
159
+ acceptor->external_connection = false;
160
+ (*server)->on_accept_internal((*server)->on_accept_internal_arg,
161
+ &iomgr_endpoint->base, nullptr,
162
+ acceptor);
163
+ exec_ctx.Flush();
164
+ grpc_pollset_ee_broadcast_event();
165
+ },
166
+ GrpcClosureToCallback(shutdown_complete, GRPC_ERROR_NONE),
167
+ endpoint_config, std::move(saf));
168
+ if (!listener.ok()) {
169
+ return absl_status_to_grpc_error(listener.status());
170
+ }
171
+ *server = new grpc_tcp_server(std::move(*listener));
172
+ return GRPC_ERROR_NONE;
173
+ }
174
+
175
+ void tcp_server_start(grpc_tcp_server* server,
176
+ const std::vector<grpc_pollset*>* /* pollsets */,
177
+ grpc_tcp_server_cb on_accept_cb, void* cb_arg) {
178
+ server->on_accept_internal = on_accept_cb;
179
+ server->on_accept_internal_arg = cb_arg;
180
+ // The iomgr API does not handle situations where the server cannot start, so
181
+ // a crash may be preferable for now.
182
+ GPR_ASSERT(server->listener->Start().ok());
183
+ }
184
+
185
+ grpc_error* tcp_server_add_port(grpc_tcp_server* s,
186
+ const grpc_resolved_address* addr,
187
+ int* out_port) {
188
+ EventEngine::ResolvedAddress ra(reinterpret_cast<const sockaddr*>(addr->addr),
189
+ addr->len);
190
+ auto port = s->listener->Bind(ra);
191
+ if (!port.ok()) {
192
+ return absl_status_to_grpc_error(port.status());
193
+ }
194
+ *out_port = *port;
195
+ return GRPC_ERROR_NONE;
196
+ }
197
+
198
+ grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler(
199
+ grpc_tcp_server* /* s */) {
200
+ // EventEngine-iomgr does not support fds.
201
+ return nullptr;
202
+ }
203
+
204
+ unsigned tcp_server_port_fd_count(grpc_tcp_server* /* s */,
205
+ unsigned /* port_index */) {
206
+ return 0;
207
+ }
208
+
209
+ int tcp_server_port_fd(grpc_tcp_server* /* s */, unsigned /* port_index */,
210
+ unsigned /* fd_index */) {
211
+ // Note: only used internally
212
+ return -1;
213
+ }
214
+
215
+ grpc_tcp_server* tcp_server_ref(grpc_tcp_server* s) {
216
+ s->refcount.Ref(DEBUG_LOCATION, "server ref");
217
+ return s;
218
+ }
219
+
220
+ void tcp_server_shutdown_starting_add(grpc_tcp_server* s,
221
+ grpc_closure* shutdown_starting) {
222
+ grpc_core::MutexLock lock(&s->mu);
223
+ grpc_closure_list_append(&s->shutdown_starting, shutdown_starting,
224
+ GRPC_ERROR_NONE);
225
+ }
226
+
227
+ void tcp_server_unref(grpc_tcp_server* s) {
228
+ if (GPR_UNLIKELY(s->refcount.Unref(DEBUG_LOCATION, "server unref"))) {
229
+ delete s;
230
+ }
231
+ }
232
+
233
+ // No-op, all are handled on listener unref
234
+ void tcp_server_shutdown_listeners(grpc_tcp_server* /* s */) {}
235
+
236
+ } // namespace
237
+
238
+ grpc_tcp_client_vtable grpc_event_engine_tcp_client_vtable = {tcp_connect};
239
+ grpc_tcp_server_vtable grpc_event_engine_tcp_server_vtable = {
240
+ tcp_server_create, tcp_server_start,
241
+ tcp_server_add_port, tcp_server_create_fd_handler,
242
+ tcp_server_port_fd_count, tcp_server_port_fd,
243
+ tcp_server_ref, tcp_server_shutdown_starting_add,
244
+ tcp_server_unref, tcp_server_shutdown_listeners};
245
+
246
+ // Methods that are expected to exist elsewhere in the codebase.
247
+
248
+ struct grpc_fd {
249
+ int fd;
250
+ };
251
+
252
+ grpc_fd* grpc_fd_create(int /* fd */, const char* /* name */,
253
+ bool /* track_err */) {
254
+ return nullptr;
255
+ }
256
+
257
+ grpc_endpoint* grpc_tcp_client_create_from_fd(
258
+ grpc_fd* /* fd */, const grpc_channel_args* /* channel_args */,
259
+ const char* /* addr_str */) {
260
+ return nullptr;
261
+ }
262
+
263
+ #endif // GRPC_USE_EVENT_ENGINE