grpc 1.37.1 → 1.39.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 (636) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +96 -59
  3. data/include/grpc/event_engine/README.md +38 -0
  4. data/include/grpc/event_engine/endpoint_config.h +48 -0
  5. data/include/grpc/event_engine/event_engine.h +334 -0
  6. data/include/grpc/event_engine/port.h +41 -0
  7. data/include/grpc/event_engine/slice_allocator.h +91 -0
  8. data/include/grpc/grpc.h +11 -4
  9. data/include/grpc/grpc_security.h +32 -0
  10. data/include/grpc/grpc_security_constants.h +15 -0
  11. data/include/grpc/impl/codegen/grpc_types.h +28 -13
  12. data/include/grpc/impl/codegen/port_platform.h +22 -0
  13. data/include/grpc/module.modulemap +14 -14
  14. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -3
  15. data/src/core/ext/filters/client_channel/channel_connectivity.cc +177 -202
  16. data/src/core/ext/filters/client_channel/client_channel.cc +630 -3103
  17. data/src/core/ext/filters/client_channel/client_channel.h +489 -55
  18. data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
  19. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -1
  20. data/src/core/ext/filters/client_channel/config_selector.h +1 -1
  21. data/src/core/ext/filters/client_channel/connector.h +1 -1
  22. data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -10
  23. data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
  24. data/src/core/ext/filters/client_channel/health/health_check_client.cc +28 -27
  25. data/src/core/ext/filters/client_channel/health/health_check_client.h +30 -29
  26. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +24 -21
  27. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -6
  29. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +46 -43
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -5
  33. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +14 -12
  34. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
  35. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  36. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -4
  37. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
  38. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +15 -15
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +46 -54
  40. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +23 -23
  41. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +31 -46
  42. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +146 -155
  43. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
  44. data/src/core/ext/filters/client_channel/lb_policy.h +4 -4
  45. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  46. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -4
  47. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  48. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -18
  49. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
  50. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  51. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +3 -3
  52. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  53. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +14 -14
  54. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +33 -24
  55. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
  56. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  59. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +18 -12
  60. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +20 -28
  61. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -5
  62. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +20 -13
  63. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  64. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +60 -32
  65. data/src/core/ext/filters/client_channel/resolver.h +2 -2
  66. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +32 -239
  67. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +20 -49
  68. data/src/core/ext/filters/client_channel/retry_filter.cc +2449 -0
  69. data/src/core/ext/filters/client_channel/retry_filter.h +30 -0
  70. data/src/core/ext/filters/client_channel/retry_service_config.cc +306 -0
  71. data/src/core/ext/filters/client_channel/retry_service_config.h +96 -0
  72. data/src/core/ext/filters/client_channel/server_address.cc +1 -1
  73. data/src/core/ext/filters/client_channel/service_config.cc +15 -14
  74. data/src/core/ext/filters/client_channel/service_config.h +7 -6
  75. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +5 -4
  76. data/src/core/ext/filters/client_channel/service_config_parser.cc +6 -6
  77. data/src/core/ext/filters/client_channel/service_config_parser.h +7 -4
  78. data/src/core/ext/filters/client_channel/subchannel.cc +17 -16
  79. data/src/core/ext/filters/client_channel/subchannel.h +7 -6
  80. data/src/core/ext/filters/client_idle/client_idle_filter.cc +17 -16
  81. data/src/core/ext/filters/deadline/deadline_filter.cc +10 -10
  82. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +25 -18
  83. data/src/core/ext/filters/fault_injection/service_config_parser.cc +5 -5
  84. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  85. data/src/core/ext/filters/http/client/http_client_filter.cc +28 -21
  86. data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
  87. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +23 -22
  88. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +21 -21
  89. data/src/core/ext/filters/http/server/http_server_filter.cc +27 -23
  90. data/src/core/ext/filters/max_age/max_age_filter.cc +12 -10
  91. data/src/core/ext/filters/message_size/message_size_filter.cc +14 -11
  92. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  93. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -3
  94. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +7 -7
  95. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +7 -7
  96. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +2 -2
  97. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +3 -2
  98. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -3
  99. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +44 -45
  100. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -2
  101. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -4
  102. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +5 -4
  103. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -4
  104. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +139 -120
  105. data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -5
  106. data/src/core/ext/transport/chttp2/transport/context_list.h +4 -4
  107. data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
  108. data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -8
  109. data/src/core/ext/transport/chttp2/transport/frame_data.cc +8 -8
  110. data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -10
  111. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +7 -8
  112. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +6 -6
  113. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +7 -8
  114. data/src/core/ext/transport/chttp2/transport/frame_ping.h +7 -6
  115. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +7 -7
  116. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +6 -6
  117. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -5
  118. data/src/core/ext/transport/chttp2/transport/frame_settings.h +6 -6
  119. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -6
  120. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +4 -6
  121. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +237 -208
  122. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -10
  123. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +4 -3
  124. data/src/core/ext/transport/chttp2/transport/hpack_table.h +4 -4
  125. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
  126. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -2
  127. data/src/core/ext/transport/chttp2/transport/internal.h +32 -27
  128. data/src/core/ext/transport/chttp2/transport/parsing.cc +65 -58
  129. data/src/core/ext/transport/chttp2/transport/writing.cc +7 -3
  130. data/src/core/ext/transport/inproc/inproc_transport.cc +72 -60
  131. data/src/core/ext/xds/certificate_provider_factory.h +1 -1
  132. data/src/core/ext/xds/certificate_provider_store.h +3 -3
  133. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +3 -3
  134. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +2 -2
  135. data/src/core/ext/xds/xds_api.cc +348 -199
  136. data/src/core/ext/xds/xds_api.h +21 -12
  137. data/src/core/ext/xds/xds_bootstrap.cc +97 -159
  138. data/src/core/ext/xds/xds_bootstrap.h +19 -24
  139. data/src/core/ext/xds/xds_certificate_provider.cc +4 -4
  140. data/src/core/ext/xds/xds_certificate_provider.h +4 -4
  141. data/src/core/ext/xds/xds_channel_args.h +5 -2
  142. data/src/core/ext/xds/xds_client.cc +310 -178
  143. data/src/core/ext/xds/xds_client.h +41 -27
  144. data/src/core/ext/xds/xds_client_stats.h +3 -2
  145. data/src/core/ext/xds/xds_server_config_fetcher.cc +34 -20
  146. data/src/core/lib/{iomgr → address_utils}/parse_address.cc +17 -17
  147. data/src/core/lib/{iomgr → address_utils}/parse_address.h +7 -7
  148. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.cc +16 -20
  149. data/src/core/lib/{iomgr → address_utils}/sockaddr_utils.h +16 -11
  150. data/src/core/lib/channel/channel_stack.cc +10 -9
  151. data/src/core/lib/channel/channel_stack.h +10 -9
  152. data/src/core/lib/channel/channel_stack_builder.cc +2 -2
  153. data/src/core/lib/channel/channel_stack_builder.h +1 -1
  154. data/src/core/lib/channel/channelz.cc +21 -13
  155. data/src/core/lib/channel/channelz.h +3 -0
  156. data/src/core/lib/channel/connected_channel.cc +4 -4
  157. data/src/core/lib/channel/handshaker.cc +7 -6
  158. data/src/core/lib/channel/handshaker.h +5 -5
  159. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  160. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  161. data/src/core/lib/event_engine/event_engine.cc +50 -0
  162. data/src/core/lib/event_engine/slice_allocator.cc +89 -0
  163. data/src/core/lib/event_engine/sockaddr.cc +40 -0
  164. data/src/core/lib/event_engine/sockaddr.h +44 -0
  165. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  166. data/src/core/lib/gprpp/ref_counted.h +28 -14
  167. data/src/core/lib/gprpp/status_helper.cc +407 -0
  168. data/src/core/lib/gprpp/status_helper.h +183 -0
  169. data/src/core/lib/http/httpcli.cc +11 -11
  170. data/src/core/lib/http/httpcli_security_connector.cc +11 -7
  171. data/src/core/lib/http/parser.cc +16 -16
  172. data/src/core/lib/http/parser.h +4 -4
  173. data/src/core/lib/iomgr/buffer_list.cc +7 -9
  174. data/src/core/lib/iomgr/buffer_list.h +4 -5
  175. data/src/core/lib/iomgr/call_combiner.cc +15 -12
  176. data/src/core/lib/iomgr/call_combiner.h +12 -14
  177. data/src/core/lib/iomgr/cfstream_handle.cc +3 -3
  178. data/src/core/lib/iomgr/cfstream_handle.h +1 -1
  179. data/src/core/lib/iomgr/closure.h +7 -6
  180. data/src/core/lib/iomgr/combiner.cc +14 -12
  181. data/src/core/lib/iomgr/combiner.h +2 -2
  182. data/src/core/lib/iomgr/endpoint.cc +1 -1
  183. data/src/core/lib/iomgr/endpoint.h +2 -2
  184. data/src/core/lib/iomgr/endpoint_cfstream.cc +11 -13
  185. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  186. data/src/core/lib/iomgr/endpoint_pair_windows.cc +1 -1
  187. data/src/core/lib/iomgr/error.cc +168 -61
  188. data/src/core/lib/iomgr/error.h +217 -106
  189. data/src/core/lib/iomgr/error_cfstream.cc +3 -2
  190. data/src/core/lib/iomgr/error_cfstream.h +2 -2
  191. data/src/core/lib/iomgr/error_internal.h +5 -1
  192. data/src/core/lib/iomgr/ev_apple.cc +5 -5
  193. data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -19
  194. data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -45
  195. data/src/core/lib/iomgr/ev_poll_posix.cc +26 -23
  196. data/src/core/lib/iomgr/ev_posix.cc +9 -8
  197. data/src/core/lib/iomgr/ev_posix.h +9 -9
  198. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  199. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  200. data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
  201. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  202. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  203. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  204. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  205. data/src/core/lib/iomgr/event_engine/pollset.h +25 -0
  206. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  207. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  208. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  209. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  210. data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
  211. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  212. data/src/core/lib/iomgr/exec_ctx.cc +12 -4
  213. data/src/core/lib/iomgr/exec_ctx.h +4 -5
  214. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  215. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  216. data/src/core/lib/iomgr/executor.cc +8 -8
  217. data/src/core/lib/iomgr/executor.h +2 -2
  218. data/src/core/lib/iomgr/iomgr.cc +2 -2
  219. data/src/core/lib/iomgr/iomgr.h +1 -1
  220. data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
  221. data/src/core/lib/iomgr/iomgr_internal.cc +2 -2
  222. data/src/core/lib/iomgr/iomgr_internal.h +3 -3
  223. data/src/core/lib/iomgr/iomgr_posix.cc +3 -1
  224. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +42 -12
  225. data/src/core/lib/iomgr/iomgr_windows.cc +1 -1
  226. data/src/core/lib/iomgr/load_file.cc +4 -4
  227. data/src/core/lib/iomgr/load_file.h +2 -2
  228. data/src/core/lib/iomgr/lockfree_event.cc +5 -5
  229. data/src/core/lib/iomgr/lockfree_event.h +1 -1
  230. data/src/core/lib/iomgr/pollset.cc +5 -5
  231. data/src/core/lib/iomgr/pollset.h +9 -9
  232. data/src/core/lib/iomgr/pollset_custom.cc +7 -7
  233. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  234. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  235. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  236. data/src/core/lib/iomgr/pollset_windows.cc +5 -5
  237. data/src/core/lib/iomgr/port.h +7 -5
  238. data/src/core/lib/iomgr/python_util.h +1 -1
  239. data/src/core/lib/iomgr/resolve_address.cc +8 -4
  240. data/src/core/lib/iomgr/resolve_address.h +12 -6
  241. data/src/core/lib/iomgr/resolve_address_custom.cc +10 -9
  242. data/src/core/lib/iomgr/resolve_address_custom.h +3 -3
  243. data/src/core/lib/iomgr/resolve_address_posix.cc +3 -3
  244. data/src/core/lib/iomgr/resolve_address_windows.cc +4 -4
  245. data/src/core/lib/iomgr/resource_quota.cc +11 -10
  246. data/src/core/lib/iomgr/sockaddr.h +1 -0
  247. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  248. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  249. data/src/core/lib/iomgr/socket_utils_common_posix.cc +24 -22
  250. data/src/core/lib/iomgr/socket_utils_posix.h +20 -20
  251. data/src/core/lib/iomgr/tcp_client_cfstream.cc +4 -4
  252. data/src/core/lib/iomgr/tcp_client_custom.cc +5 -6
  253. data/src/core/lib/iomgr/tcp_client_posix.cc +22 -19
  254. data/src/core/lib/iomgr/tcp_client_posix.h +3 -4
  255. data/src/core/lib/iomgr/tcp_client_windows.cc +5 -5
  256. data/src/core/lib/iomgr/tcp_custom.cc +14 -16
  257. data/src/core/lib/iomgr/tcp_custom.h +13 -12
  258. data/src/core/lib/iomgr/tcp_posix.cc +78 -73
  259. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  260. data/src/core/lib/iomgr/tcp_server.cc +6 -6
  261. data/src/core/lib/iomgr/tcp_server.h +12 -11
  262. data/src/core/lib/iomgr/tcp_server_custom.cc +26 -25
  263. data/src/core/lib/iomgr/tcp_server_posix.cc +28 -21
  264. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -12
  265. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +21 -18
  266. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +9 -9
  267. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
  268. data/src/core/lib/iomgr/tcp_server_windows.cc +26 -25
  269. data/src/core/lib/iomgr/tcp_uv.cc +25 -23
  270. data/src/core/lib/iomgr/tcp_windows.cc +13 -13
  271. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  272. data/src/core/lib/iomgr/timer.h +6 -1
  273. data/src/core/lib/iomgr/timer_custom.cc +2 -1
  274. data/src/core/lib/iomgr/timer_custom.h +1 -1
  275. data/src/core/lib/iomgr/timer_generic.cc +6 -6
  276. data/src/core/lib/iomgr/udp_server.cc +21 -20
  277. data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -3
  278. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -2
  279. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +10 -7
  280. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -3
  281. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +4 -4
  282. data/src/core/lib/iomgr/wakeup_fd_posix.cc +3 -3
  283. data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -6
  284. data/src/core/lib/iomgr/work_serializer.h +17 -1
  285. data/src/core/lib/json/json.h +1 -1
  286. data/src/core/lib/json/json_reader.cc +4 -4
  287. data/src/core/lib/matchers/matchers.cc +39 -39
  288. data/src/core/lib/matchers/matchers.h +28 -28
  289. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  290. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  291. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  292. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  293. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  294. data/src/core/lib/security/credentials/composite/composite_credentials.cc +4 -4
  295. data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
  296. data/src/core/lib/security/credentials/credentials.h +2 -2
  297. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +17 -13
  298. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -11
  299. data/src/core/lib/security/credentials/external/aws_request_signer.cc +2 -1
  300. data/src/core/lib/security/credentials/external/aws_request_signer.h +1 -1
  301. data/src/core/lib/security/credentials/external/external_account_credentials.cc +15 -12
  302. data/src/core/lib/security/credentials/external/external_account_credentials.h +9 -8
  303. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +5 -4
  304. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -3
  305. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +8 -8
  306. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +9 -7
  307. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -2
  308. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -2
  309. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +12 -10
  310. data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -2
  311. data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -2
  312. data/src/core/lib/security/credentials/jwt/json_token.cc +2 -2
  313. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +3 -3
  314. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -2
  315. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +7 -5
  316. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +21 -19
  317. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -5
  318. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +5 -5
  319. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -2
  320. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +8 -7
  321. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +9 -9
  322. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +19 -13
  323. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +4 -0
  324. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  325. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  326. data/src/core/lib/security/credentials/xds/xds_credentials.cc +3 -3
  327. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -3
  328. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -3
  329. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +2 -2
  330. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +12 -2
  331. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +1 -1
  332. data/src/core/lib/security/security_connector/local/local_security_connector.cc +22 -9
  333. data/src/core/lib/security/security_connector/security_connector.h +9 -4
  334. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +16 -6
  335. data/src/core/lib/security/security_connector/ssl_utils.cc +27 -4
  336. data/src/core/lib/security/security_connector/ssl_utils.h +4 -4
  337. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +56 -60
  338. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +66 -48
  339. data/src/core/lib/security/transport/client_auth_filter.cc +18 -10
  340. data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
  341. data/src/core/lib/security/transport/security_handshaker.cc +33 -32
  342. data/src/core/lib/security/transport/server_auth_filter.cc +19 -13
  343. data/src/core/lib/security/transport/tsi_error.cc +2 -1
  344. data/src/core/lib/security/transport/tsi_error.h +2 -1
  345. data/src/core/lib/security/util/json_util.cc +2 -2
  346. data/src/core/lib/security/util/json_util.h +1 -1
  347. data/src/core/lib/surface/call.cc +67 -46
  348. data/src/core/lib/surface/call.h +13 -2
  349. data/src/core/lib/surface/channel.cc +6 -6
  350. data/src/core/lib/surface/channel.h +3 -2
  351. data/src/core/lib/surface/channel_ping.cc +1 -1
  352. data/src/core/lib/surface/completion_queue.cc +68 -69
  353. data/src/core/lib/surface/completion_queue.h +3 -2
  354. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  355. data/src/core/lib/surface/init.cc +1 -3
  356. data/src/core/lib/surface/init.h +10 -1
  357. data/src/core/lib/surface/lame_client.cc +11 -11
  358. data/src/core/lib/surface/lame_client.h +1 -1
  359. data/src/core/lib/surface/server.cc +28 -22
  360. data/src/core/lib/surface/server.h +16 -15
  361. data/src/core/lib/surface/validate_metadata.cc +7 -7
  362. data/src/core/lib/surface/validate_metadata.h +3 -2
  363. data/src/core/lib/surface/version.cc +4 -2
  364. data/src/core/lib/transport/byte_stream.cc +5 -5
  365. data/src/core/lib/transport/byte_stream.h +8 -8
  366. data/src/core/lib/transport/connectivity_state.cc +1 -1
  367. data/src/core/lib/transport/error_utils.cc +21 -10
  368. data/src/core/lib/transport/error_utils.h +11 -5
  369. data/src/core/lib/transport/metadata_batch.cc +37 -37
  370. data/src/core/lib/transport/metadata_batch.h +19 -18
  371. data/src/core/lib/transport/transport.cc +4 -3
  372. data/src/core/lib/transport/transport.h +6 -4
  373. data/src/core/lib/transport/transport_op_string.cc +6 -6
  374. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  375. data/src/core/tsi/alts/crypt/gsec.h +6 -0
  376. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +5 -4
  377. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +7 -6
  378. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +2 -1
  379. data/src/core/tsi/ssl_transport_security.cc +32 -14
  380. data/src/core/tsi/ssl_transport_security.h +3 -4
  381. data/src/ruby/bin/math_services_pb.rb +1 -1
  382. data/src/ruby/ext/grpc/extconf.rb +2 -0
  383. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  384. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +11 -2
  385. data/src/ruby/lib/grpc/version.rb +1 -1
  386. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +1 -1
  387. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +6 -6
  388. data/third_party/abseil-cpp/absl/algorithm/container.h +3 -3
  389. data/third_party/abseil-cpp/absl/base/attributes.h +24 -4
  390. data/third_party/abseil-cpp/absl/base/call_once.h +2 -9
  391. data/third_party/abseil-cpp/absl/base/config.h +37 -9
  392. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +24 -10
  393. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +4 -1
  394. data/third_party/abseil-cpp/absl/base/internal/endian.h +61 -0
  395. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +2 -3
  396. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +34 -32
  397. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +16 -6
  398. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +11 -2
  399. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +14 -5
  400. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +2 -2
  401. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +3 -3
  402. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +2 -2
  403. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +11 -11
  404. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +5 -5
  405. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +1 -1
  406. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +5 -2
  407. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +43 -42
  408. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +111 -7
  409. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +0 -76
  410. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -3
  411. data/third_party/abseil-cpp/absl/base/log_severity.h +4 -4
  412. data/third_party/abseil-cpp/absl/base/macros.h +11 -0
  413. data/third_party/abseil-cpp/absl/base/optimization.h +10 -7
  414. data/third_party/abseil-cpp/absl/base/options.h +1 -1
  415. data/third_party/abseil-cpp/absl/base/port.h +0 -1
  416. data/third_party/abseil-cpp/absl/base/thread_annotations.h +1 -1
  417. data/third_party/abseil-cpp/absl/container/fixed_array.h +2 -2
  418. data/third_party/abseil-cpp/absl/container/inlined_vector.h +5 -3
  419. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +1 -1
  420. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +5 -1
  421. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +2 -1
  422. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +2 -1
  423. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +141 -66
  424. data/third_party/abseil-cpp/absl/container/internal/layout.h +4 -4
  425. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +14 -1
  426. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +136 -136
  427. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +16 -12
  428. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +5 -2
  429. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +3 -12
  430. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +6 -1
  431. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +3 -5
  432. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +2 -2
  433. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +2 -2
  434. data/third_party/abseil-cpp/absl/hash/internal/city.cc +15 -12
  435. data/third_party/abseil-cpp/absl/hash/internal/city.h +1 -19
  436. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +25 -10
  437. data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -37
  438. data/third_party/abseil-cpp/absl/hash/internal/wyhash.cc +111 -0
  439. data/third_party/abseil-cpp/absl/hash/internal/wyhash.h +48 -0
  440. data/third_party/abseil-cpp/absl/meta/type_traits.h +16 -2
  441. data/third_party/abseil-cpp/absl/numeric/bits.h +177 -0
  442. data/third_party/abseil-cpp/absl/numeric/int128.cc +3 -3
  443. data/third_party/abseil-cpp/absl/numeric/internal/bits.h +358 -0
  444. data/third_party/abseil-cpp/absl/numeric/internal/representation.h +55 -0
  445. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
  446. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -7
  447. data/third_party/abseil-cpp/absl/status/status.cc +29 -22
  448. data/third_party/abseil-cpp/absl/status/status.h +81 -20
  449. data/third_party/abseil-cpp/absl/status/statusor.h +3 -3
  450. data/third_party/abseil-cpp/absl/strings/charconv.cc +5 -5
  451. data/third_party/abseil-cpp/absl/strings/cord.cc +326 -371
  452. data/third_party/abseil-cpp/absl/strings/cord.h +182 -64
  453. data/third_party/abseil-cpp/absl/strings/escaping.cc +4 -4
  454. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +6 -6
  455. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +83 -0
  456. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +387 -17
  457. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +146 -0
  458. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +897 -0
  459. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +589 -0
  460. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring_reader.h +114 -0
  461. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +14 -0
  462. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +14 -0
  463. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +15 -1
  464. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +19 -4
  465. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +14 -0
  466. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +36 -18
  467. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +14 -0
  468. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +14 -0
  469. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -0
  470. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +15 -40
  471. data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +64 -0
  472. data/third_party/abseil-cpp/absl/strings/match.cc +6 -3
  473. data/third_party/abseil-cpp/absl/strings/match.h +16 -6
  474. data/third_party/abseil-cpp/absl/strings/numbers.cc +132 -4
  475. data/third_party/abseil-cpp/absl/strings/numbers.h +10 -10
  476. data/third_party/abseil-cpp/absl/strings/str_join.h +1 -1
  477. data/third_party/abseil-cpp/absl/strings/str_split.h +38 -4
  478. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +154 -0
  479. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -1
  480. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +2 -2
  481. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +4 -4
  482. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +1 -65
  483. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -6
  484. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +71 -59
  485. data/third_party/abseil-cpp/absl/synchronization/mutex.h +79 -62
  486. data/third_party/abseil-cpp/absl/time/clock.cc +146 -130
  487. data/third_party/abseil-cpp/absl/time/clock.h +2 -2
  488. data/third_party/abseil-cpp/absl/time/duration.cc +3 -2
  489. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +7 -11
  490. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +7 -1
  491. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +4 -4
  492. data/third_party/abseil-cpp/absl/time/time.cc +4 -3
  493. data/third_party/abseil-cpp/absl/time/time.h +26 -24
  494. data/third_party/abseil-cpp/absl/types/internal/variant.h +1 -1
  495. data/third_party/abseil-cpp/absl/types/variant.h +9 -4
  496. data/third_party/boringssl-with-bazel/err_data.c +483 -461
  497. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
  498. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +9 -7
  499. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +18 -8
  500. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -2
  501. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +5 -0
  502. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -1
  503. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +1 -1
  504. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  505. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +1 -88
  506. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -3
  507. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +119 -273
  508. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  509. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  510. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +87 -80
  511. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  512. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  513. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +1 -1
  514. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  515. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +11 -3
  516. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +25 -2
  517. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  518. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +10 -2
  519. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -160
  520. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +4 -0
  521. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +0 -1
  522. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +0 -4
  523. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +104 -93
  524. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +39 -0
  525. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +52 -65
  526. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +52 -66
  527. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +33 -22
  528. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +9 -8
  529. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +9 -8
  530. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +17 -13
  531. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +1 -22
  532. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +2 -1
  533. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  534. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  535. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +26 -7
  536. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  537. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  538. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +79 -0
  539. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +14 -9
  540. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +61 -75
  541. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +80 -103
  542. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +40 -49
  543. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +367 -315
  544. data/third_party/boringssl-with-bazel/src/crypto/internal.h +65 -0
  545. data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -0
  546. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +3 -3
  547. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +5 -3
  548. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +95 -48
  549. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  550. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +1 -1
  551. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  552. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +0 -28
  553. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +120 -11
  554. data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +2 -0
  555. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  556. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +19 -25
  557. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +3 -2
  558. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +42 -89
  559. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +9 -16
  560. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  561. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  562. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  563. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  564. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  565. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +21 -17
  566. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  567. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +7 -25
  568. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -0
  569. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +25 -22
  570. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  571. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  572. data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +2 -0
  573. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  574. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  575. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -4
  576. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  577. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -0
  578. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  579. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -4
  580. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  581. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +120 -41
  582. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +47 -7
  583. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  584. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  585. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +0 -8
  586. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +24 -4
  587. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  588. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +5 -2
  589. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +33 -0
  590. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +3 -2
  591. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +20 -49
  592. data/third_party/boringssl-with-bazel/src/{crypto/x509/x509_r2x.c → include/openssl/evp_errors.h} +41 -58
  593. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  594. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +24 -5
  595. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +25 -7
  596. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +9 -1
  597. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +2 -2
  598. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  599. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +283 -85
  600. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +13 -19
  601. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +445 -152
  602. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  603. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +2 -1
  604. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +7 -2
  605. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  606. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +1133 -0
  607. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +298 -22
  608. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +66 -30
  609. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  610. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +154 -24
  611. data/third_party/boringssl-with-bazel/src/ssl/internal.h +414 -135
  612. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +9 -3
  613. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  614. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  615. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -6
  616. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +23 -26
  617. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +51 -60
  618. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  619. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  620. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  621. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  622. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  623. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +664 -702
  624. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +65 -7
  625. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  626. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  627. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +213 -118
  628. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +4 -2
  629. metadata +94 -46
  630. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +0 -88
  631. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +0 -88
  632. data/third_party/abseil-cpp/absl/base/internal/bits.h +0 -219
  633. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +0 -249
  634. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +0 -29
  635. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -246
  636. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -31,22 +31,23 @@
31
31
  //
32
32
  // MutexLock - An RAII wrapper to acquire and release a `Mutex` for exclusive/
33
33
  // write access within the current scope.
34
+ //
34
35
  // ReaderMutexLock
35
36
  // - An RAII wrapper to acquire and release a `Mutex` for shared/read
36
37
  // access within the current scope.
37
38
  //
38
39
  // WriterMutexLock
39
- // - Alias for `MutexLock` above, designed for use in distinguishing
40
- // reader and writer locks within code.
40
+ // - Effectively an alias for `MutexLock` above, designed for use in
41
+ // distinguishing reader and writer locks within code.
41
42
  //
42
43
  // In addition to simple mutex locks, this file also defines ways to perform
43
44
  // locking under certain conditions.
44
45
  //
45
- // Condition - (Preferred) Used to wait for a particular predicate that
46
- // depends on state protected by the `Mutex` to become true.
47
- // CondVar - A lower-level variant of `Condition` that relies on
48
- // application code to explicitly signal the `CondVar` when
49
- // a condition has been met.
46
+ // Condition - (Preferred) Used to wait for a particular predicate that
47
+ // depends on state protected by the `Mutex` to become true.
48
+ // CondVar - A lower-level variant of `Condition` that relies on
49
+ // application code to explicitly signal the `CondVar` when
50
+ // a condition has been met.
50
51
  //
51
52
  // See below for more information on using `Condition` or `CondVar`.
52
53
  //
@@ -72,15 +73,6 @@
72
73
  #include "absl/synchronization/internal/per_thread_sem.h"
73
74
  #include "absl/time/time.h"
74
75
 
75
- // Decide if we should use the non-production implementation because
76
- // the production implementation hasn't been fully ported yet.
77
- #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX
78
- #error ABSL_INTERNAL_USE_NONPROD_MUTEX cannot be directly set
79
- #elif defined(ABSL_LOW_LEVEL_ALLOC_MISSING)
80
- #define ABSL_INTERNAL_USE_NONPROD_MUTEX 1
81
- #include "absl/synchronization/internal/mutex_nonprod.inc"
82
- #endif
83
-
84
76
  namespace absl {
85
77
  ABSL_NAMESPACE_BEGIN
86
78
 
@@ -155,7 +147,7 @@ class ABSL_LOCKABLE Mutex {
155
147
  //
156
148
  // Example usage:
157
149
  // namespace foo {
158
- // ABSL_CONST_INIT Mutex mu(absl::kConstInit);
150
+ // ABSL_CONST_INIT absl::Mutex mu(absl::kConstInit);
159
151
  // }
160
152
  explicit constexpr Mutex(absl::ConstInitType);
161
153
 
@@ -170,7 +162,7 @@ class ABSL_LOCKABLE Mutex {
170
162
  // Mutex::Unlock()
171
163
  //
172
164
  // Releases this `Mutex` and returns it from the exclusive/write state to the
173
- // free state. Caller must hold the `Mutex` exclusively.
165
+ // free state. Calling thread must hold the `Mutex` exclusively.
174
166
  void Unlock() ABSL_UNLOCK_FUNCTION();
175
167
 
176
168
  // Mutex::TryLock()
@@ -461,24 +453,13 @@ class ABSL_LOCKABLE Mutex {
461
453
  static void InternalAttemptToUseMutexInFatalSignalHandler();
462
454
 
463
455
  private:
464
- #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX
465
- friend class CondVar;
466
-
467
- synchronization_internal::MutexImpl *impl() { return impl_.get(); }
468
-
469
- synchronization_internal::SynchronizationStorage<
470
- synchronization_internal::MutexImpl>
471
- impl_;
472
- #else
473
456
  std::atomic<intptr_t> mu_; // The Mutex state.
474
457
 
475
458
  // Post()/Wait() versus associated PerThreadSem; in class for required
476
459
  // friendship with PerThreadSem.
477
- static inline void IncrementSynchSem(Mutex *mu,
478
- base_internal::PerThreadSynch *w);
479
- static inline bool DecrementSynchSem(
480
- Mutex *mu, base_internal::PerThreadSynch *w,
481
- synchronization_internal::KernelTimeout t);
460
+ static void IncrementSynchSem(Mutex *mu, base_internal::PerThreadSynch *w);
461
+ static bool DecrementSynchSem(Mutex *mu, base_internal::PerThreadSynch *w,
462
+ synchronization_internal::KernelTimeout t);
482
463
 
483
464
  // slow path acquire
484
465
  void LockSlowLoop(SynchWaitParams *waitp, int flags);
@@ -504,7 +485,6 @@ class ABSL_LOCKABLE Mutex {
504
485
  void Trans(MuHow how); // used for CondVar->Mutex transfer
505
486
  void Fer(
506
487
  base_internal::PerThreadSynch *w); // used for CondVar->Mutex transfer
507
- #endif
508
488
 
509
489
  // Catch the error of writing Mutex when intending MutexLock.
510
490
  Mutex(const volatile Mutex * /*ignored*/) {} // NOLINT(runtime/explicit)
@@ -525,22 +505,36 @@ class ABSL_LOCKABLE Mutex {
525
505
  // Example:
526
506
  //
527
507
  // Class Foo {
528
- //
508
+ // public:
529
509
  // Foo::Bar* Baz() {
530
- // MutexLock l(&lock_);
510
+ // MutexLock lock(&mu_);
531
511
  // ...
532
512
  // return bar;
533
513
  // }
534
514
  //
535
515
  // private:
536
- // Mutex lock_;
516
+ // Mutex mu_;
537
517
  // };
538
518
  class ABSL_SCOPED_LOCKABLE MutexLock {
539
519
  public:
520
+ // Constructors
521
+
522
+ // Calls `mu->Lock()` and returns when that call returns. That is, `*mu` is
523
+ // guaranteed to be locked when this object is constructed. Requires that
524
+ // `mu` be dereferenceable.
540
525
  explicit MutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu) : mu_(mu) {
541
526
  this->mu_->Lock();
542
527
  }
543
528
 
529
+ // Like above, but calls `mu->LockWhen(cond)` instead. That is, in addition to
530
+ // the above, the condition given by `cond` is also guaranteed to hold when
531
+ // this object is constructed.
532
+ explicit MutexLock(Mutex *mu, const Condition &cond)
533
+ ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
534
+ : mu_(mu) {
535
+ this->mu_->LockWhen(cond);
536
+ }
537
+
544
538
  MutexLock(const MutexLock &) = delete; // NOLINT(runtime/mutex)
545
539
  MutexLock(MutexLock&&) = delete; // NOLINT(runtime/mutex)
546
540
  MutexLock& operator=(const MutexLock&) = delete;
@@ -562,6 +556,12 @@ class ABSL_SCOPED_LOCKABLE ReaderMutexLock {
562
556
  mu->ReaderLock();
563
557
  }
564
558
 
559
+ explicit ReaderMutexLock(Mutex *mu, const Condition &cond)
560
+ ABSL_SHARED_LOCK_FUNCTION(mu)
561
+ : mu_(mu) {
562
+ mu->ReaderLockWhen(cond);
563
+ }
564
+
565
565
  ReaderMutexLock(const ReaderMutexLock&) = delete;
566
566
  ReaderMutexLock(ReaderMutexLock&&) = delete;
567
567
  ReaderMutexLock& operator=(const ReaderMutexLock&) = delete;
@@ -584,6 +584,12 @@ class ABSL_SCOPED_LOCKABLE WriterMutexLock {
584
584
  mu->WriterLock();
585
585
  }
586
586
 
587
+ explicit WriterMutexLock(Mutex *mu, const Condition &cond)
588
+ ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
589
+ : mu_(mu) {
590
+ mu->WriterLockWhen(cond);
591
+ }
592
+
587
593
  WriterMutexLock(const WriterMutexLock&) = delete;
588
594
  WriterMutexLock(WriterMutexLock&&) = delete;
589
595
  WriterMutexLock& operator=(const WriterMutexLock&) = delete;
@@ -622,16 +628,26 @@ class ABSL_SCOPED_LOCKABLE WriterMutexLock {
622
628
  // `noexcept`; until then this requirement cannot be enforced in the
623
629
  // type system.)
624
630
  //
625
- // Note: to use a `Condition`, you need only construct it and pass it within the
626
- // appropriate `Mutex' member function, such as `Mutex::Await()`.
631
+ // Note: to use a `Condition`, you need only construct it and pass it to a
632
+ // suitable `Mutex' member function, such as `Mutex::Await()`, or to the
633
+ // constructor of one of the scope guard classes.
627
634
  //
628
- // Example:
635
+ // Example using LockWhen/Unlock:
629
636
  //
630
637
  // // assume count_ is not internal reference count
631
638
  // int count_ ABSL_GUARDED_BY(mu_);
639
+ // Condition count_is_zero(+[](int *count) { return *count == 0; }, &count_);
640
+ //
641
+ // mu_.LockWhen(count_is_zero);
642
+ // // ...
643
+ // mu_.Unlock();
632
644
  //
633
- // mu_.LockWhen(Condition(+[](int* count) { return *count == 0; },
634
- // &count_));
645
+ // Example using a scope guard:
646
+ //
647
+ // {
648
+ // MutexLock lock(&mu_, count_is_zero);
649
+ // // ...
650
+ // }
635
651
  //
636
652
  // When multiple threads are waiting on exactly the same condition, make sure
637
653
  // that they are constructed with the same parameters (same pointer to function
@@ -686,10 +702,10 @@ class Condition {
686
702
  // };
687
703
  // mu_.Await(Condition(&reached));
688
704
  //
689
- // NOTE: never use "mu_.AssertHeld()" instead of "mu_.AssertReadHeld()" in the
690
- // lambda as it may be called when the mutex is being unlocked from a scope
691
- // holding only a reader lock, which will make the assertion not fulfilled and
692
- // crash the binary.
705
+ // NOTE: never use "mu_.AssertHeld()" instead of "mu_.AssertReaderHeld()" in
706
+ // the lambda as it may be called when the mutex is being unlocked from a
707
+ // scope holding only a reader lock, which will make the assertion not
708
+ // fulfilled and crash the binary.
693
709
 
694
710
  // See class comment for performance advice. In particular, if there
695
711
  // might be more than one waiter for the same condition, make sure
@@ -838,17 +854,10 @@ class CondVar {
838
854
  void EnableDebugLog(const char *name);
839
855
 
840
856
  private:
841
- #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX
842
- synchronization_internal::CondVarImpl *impl() { return impl_.get(); }
843
- synchronization_internal::SynchronizationStorage<
844
- synchronization_internal::CondVarImpl>
845
- impl_;
846
- #else
847
857
  bool WaitCommon(Mutex *mutex, synchronization_internal::KernelTimeout t);
848
858
  void Remove(base_internal::PerThreadSynch *s);
849
859
  void Wakeup(base_internal::PerThreadSynch *w);
850
860
  std::atomic<intptr_t> cv_; // Condition variable state.
851
- #endif
852
861
  CondVar(const CondVar&) = delete;
853
862
  CondVar& operator=(const CondVar&) = delete;
854
863
  };
@@ -870,6 +879,15 @@ class ABSL_SCOPED_LOCKABLE MutexLockMaybe {
870
879
  this->mu_->Lock();
871
880
  }
872
881
  }
882
+
883
+ explicit MutexLockMaybe(Mutex *mu, const Condition &cond)
884
+ ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
885
+ : mu_(mu) {
886
+ if (this->mu_ != nullptr) {
887
+ this->mu_->LockWhen(cond);
888
+ }
889
+ }
890
+
873
891
  ~MutexLockMaybe() ABSL_UNLOCK_FUNCTION() {
874
892
  if (this->mu_ != nullptr) { this->mu_->Unlock(); }
875
893
  }
@@ -892,6 +910,13 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
892
910
  : mu_(mu) {
893
911
  this->mu_->Lock();
894
912
  }
913
+
914
+ explicit ReleasableMutexLock(Mutex *mu, const Condition &cond)
915
+ ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
916
+ : mu_(mu) {
917
+ this->mu_->LockWhen(cond);
918
+ }
919
+
895
920
  ~ReleasableMutexLock() ABSL_UNLOCK_FUNCTION() {
896
921
  if (this->mu_ != nullptr) { this->mu_->Unlock(); }
897
922
  }
@@ -906,12 +931,6 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
906
931
  ReleasableMutexLock& operator=(ReleasableMutexLock&&) = delete;
907
932
  };
908
933
 
909
- #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX
910
-
911
- inline constexpr Mutex::Mutex(absl::ConstInitType) : impl_(absl::kConstInit) {}
912
-
913
- #else
914
-
915
934
  inline Mutex::Mutex() : mu_(0) {
916
935
  ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static);
917
936
  }
@@ -920,8 +939,6 @@ inline constexpr Mutex::Mutex(absl::ConstInitType) : mu_(0) {}
920
939
 
921
940
  inline CondVar::CondVar() : cv_(0) {}
922
941
 
923
- #endif // ABSL_INTERNAL_USE_NONPROD_MUTEX
924
-
925
942
  // static
926
943
  template <typename T>
927
944
  bool Condition::CastAndCallMethod(const Condition *c) {
@@ -988,7 +1005,7 @@ void RegisterMutexProfiler(void (*fn)(int64_t wait_timestamp));
988
1005
  //
989
1006
  // This has the same memory ordering concerns as RegisterMutexProfiler() above.
990
1007
  void RegisterMutexTracer(void (*fn)(const char *msg, const void *obj,
991
- int64_t wait_cycles));
1008
+ int64_t wait_cycles));
992
1009
 
993
1010
  // TODO(gfalcon): Combine RegisterMutexProfiler() and RegisterMutexTracer()
994
1011
  // into a single interface, since they are only ever called in pairs.
@@ -1059,7 +1076,7 @@ ABSL_NAMESPACE_END
1059
1076
  // By changing our extension points to be extern "C", we dodge this
1060
1077
  // check.
1061
1078
  extern "C" {
1062
- void AbslInternalMutexYield();
1079
+ void ABSL_INTERNAL_C_SYMBOL(AbslInternalMutexYield)();
1063
1080
  } // extern "C"
1064
1081
 
1065
1082
  #endif // ABSL_SYNCHRONIZATION_MUTEX_H_
@@ -15,6 +15,7 @@
15
15
  #include "absl/time/clock.h"
16
16
 
17
17
  #include "absl/base/attributes.h"
18
+ #include "absl/base/optimization.h"
18
19
 
19
20
  #ifdef _WIN32
20
21
  #include <windows.h>
@@ -74,9 +75,7 @@ ABSL_NAMESPACE_END
74
75
  #if !ABSL_USE_CYCLECLOCK_FOR_GET_CURRENT_TIME_NANOS
75
76
  namespace absl {
76
77
  ABSL_NAMESPACE_BEGIN
77
- int64_t GetCurrentTimeNanos() {
78
- return GET_CURRENT_TIME_NANOS_FROM_SYSTEM();
79
- }
78
+ int64_t GetCurrentTimeNanos() { return GET_CURRENT_TIME_NANOS_FROM_SYSTEM(); }
80
79
  ABSL_NAMESPACE_END
81
80
  } // namespace absl
82
81
  #else // Use the cyclecounter-based implementation below.
@@ -87,13 +86,6 @@ ABSL_NAMESPACE_END
87
86
  ::absl::time_internal::UnscaledCycleClockWrapperForGetCurrentTime::Now()
88
87
  #endif
89
88
 
90
- // The following counters are used only by the test code.
91
- static int64_t stats_initializations;
92
- static int64_t stats_reinitializations;
93
- static int64_t stats_calibrations;
94
- static int64_t stats_slow_paths;
95
- static int64_t stats_fast_slow_paths;
96
-
97
89
  namespace absl {
98
90
  ABSL_NAMESPACE_BEGIN
99
91
  namespace time_internal {
@@ -107,72 +99,6 @@ class UnscaledCycleClockWrapperForGetCurrentTime {
107
99
 
108
100
  // uint64_t is used in this module to provide an extra bit in multiplications
109
101
 
110
- // Return the time in ns as told by the kernel interface. Place in *cycleclock
111
- // the value of the cycleclock at about the time of the syscall.
112
- // This call represents the time base that this module synchronizes to.
113
- // Ensures that *cycleclock does not step back by up to (1 << 16) from
114
- // last_cycleclock, to discard small backward counter steps. (Larger steps are
115
- // assumed to be complete resyncs, which shouldn't happen. If they do, a full
116
- // reinitialization of the outer algorithm should occur.)
117
- static int64_t GetCurrentTimeNanosFromKernel(uint64_t last_cycleclock,
118
- uint64_t *cycleclock) {
119
- // We try to read clock values at about the same time as the kernel clock.
120
- // This value gets adjusted up or down as estimate of how long that should
121
- // take, so we can reject attempts that take unusually long.
122
- static std::atomic<uint64_t> approx_syscall_time_in_cycles{10 * 1000};
123
-
124
- uint64_t local_approx_syscall_time_in_cycles = // local copy
125
- approx_syscall_time_in_cycles.load(std::memory_order_relaxed);
126
-
127
- int64_t current_time_nanos_from_system;
128
- uint64_t before_cycles;
129
- uint64_t after_cycles;
130
- uint64_t elapsed_cycles;
131
- int loops = 0;
132
- do {
133
- before_cycles = GET_CURRENT_TIME_NANOS_CYCLECLOCK_NOW();
134
- current_time_nanos_from_system = GET_CURRENT_TIME_NANOS_FROM_SYSTEM();
135
- after_cycles = GET_CURRENT_TIME_NANOS_CYCLECLOCK_NOW();
136
- // elapsed_cycles is unsigned, so is large on overflow
137
- elapsed_cycles = after_cycles - before_cycles;
138
- if (elapsed_cycles >= local_approx_syscall_time_in_cycles &&
139
- ++loops == 20) { // clock changed frequencies? Back off.
140
- loops = 0;
141
- if (local_approx_syscall_time_in_cycles < 1000 * 1000) {
142
- local_approx_syscall_time_in_cycles =
143
- (local_approx_syscall_time_in_cycles + 1) << 1;
144
- }
145
- approx_syscall_time_in_cycles.store(
146
- local_approx_syscall_time_in_cycles,
147
- std::memory_order_relaxed);
148
- }
149
- } while (elapsed_cycles >= local_approx_syscall_time_in_cycles ||
150
- last_cycleclock - after_cycles < (static_cast<uint64_t>(1) << 16));
151
-
152
- // Number of times in a row we've seen a kernel time call take substantially
153
- // less than approx_syscall_time_in_cycles.
154
- static std::atomic<uint32_t> seen_smaller{ 0 };
155
-
156
- // Adjust approx_syscall_time_in_cycles to be within a factor of 2
157
- // of the typical time to execute one iteration of the loop above.
158
- if ((local_approx_syscall_time_in_cycles >> 1) < elapsed_cycles) {
159
- // measured time is no smaller than half current approximation
160
- seen_smaller.store(0, std::memory_order_relaxed);
161
- } else if (seen_smaller.fetch_add(1, std::memory_order_relaxed) >= 3) {
162
- // smaller delays several times in a row; reduce approximation by 12.5%
163
- const uint64_t new_approximation =
164
- local_approx_syscall_time_in_cycles -
165
- (local_approx_syscall_time_in_cycles >> 3);
166
- approx_syscall_time_in_cycles.store(new_approximation,
167
- std::memory_order_relaxed);
168
- seen_smaller.store(0, std::memory_order_relaxed);
169
- }
170
-
171
- *cycleclock = after_cycles;
172
- return current_time_nanos_from_system;
173
- }
174
-
175
-
176
102
  // ---------------------------------------------------------------------
177
103
  // An implementation of reader-write locks that use no atomic ops in the read
178
104
  // case. This is a generalization of Lamport's method for reading a multiword
@@ -224,32 +150,110 @@ static_assert(((kMinNSBetweenSamples << (kScale + 1)) >> (kScale + 1)) ==
224
150
  kMinNSBetweenSamples,
225
151
  "cannot represent kMaxBetweenSamplesNSScaled");
226
152
 
227
- // A reader-writer lock protecting the static locations below.
228
- // See SeqAcquire() and SeqRelease() above.
229
- ABSL_CONST_INIT static absl::base_internal::SpinLock lock(
230
- absl::kConstInit, base_internal::SCHEDULE_KERNEL_ONLY);
231
- ABSL_CONST_INIT static std::atomic<uint64_t> seq(0);
232
-
233
153
  // data from a sample of the kernel's time value
234
154
  struct TimeSampleAtomic {
235
- std::atomic<uint64_t> raw_ns; // raw kernel time
236
- std::atomic<uint64_t> base_ns; // our estimate of time
237
- std::atomic<uint64_t> base_cycles; // cycle counter reading
238
- std::atomic<uint64_t> nsscaled_per_cycle; // cycle period
155
+ std::atomic<uint64_t> raw_ns{0}; // raw kernel time
156
+ std::atomic<uint64_t> base_ns{0}; // our estimate of time
157
+ std::atomic<uint64_t> base_cycles{0}; // cycle counter reading
158
+ std::atomic<uint64_t> nsscaled_per_cycle{0}; // cycle period
239
159
  // cycles before we'll sample again (a scaled reciprocal of the period,
240
160
  // to avoid a division on the fast path).
241
- std::atomic<uint64_t> min_cycles_per_sample;
161
+ std::atomic<uint64_t> min_cycles_per_sample{0};
242
162
  };
243
163
  // Same again, but with non-atomic types
244
164
  struct TimeSample {
245
- uint64_t raw_ns; // raw kernel time
246
- uint64_t base_ns; // our estimate of time
247
- uint64_t base_cycles; // cycle counter reading
248
- uint64_t nsscaled_per_cycle; // cycle period
249
- uint64_t min_cycles_per_sample; // approx cycles before next sample
165
+ uint64_t raw_ns = 0; // raw kernel time
166
+ uint64_t base_ns = 0; // our estimate of time
167
+ uint64_t base_cycles = 0; // cycle counter reading
168
+ uint64_t nsscaled_per_cycle = 0; // cycle period
169
+ uint64_t min_cycles_per_sample = 0; // approx cycles before next sample
250
170
  };
251
171
 
252
- static struct TimeSampleAtomic last_sample; // the last sample; under seq
172
+ struct ABSL_CACHELINE_ALIGNED TimeState {
173
+ std::atomic<uint64_t> seq{0};
174
+ TimeSampleAtomic last_sample; // the last sample; under seq
175
+
176
+ // The following counters are used only by the test code.
177
+ int64_t stats_initializations{0};
178
+ int64_t stats_reinitializations{0};
179
+ int64_t stats_calibrations{0};
180
+ int64_t stats_slow_paths{0};
181
+ int64_t stats_fast_slow_paths{0};
182
+
183
+ uint64_t last_now_cycles ABSL_GUARDED_BY(lock){0};
184
+
185
+ // Used by GetCurrentTimeNanosFromKernel().
186
+ // We try to read clock values at about the same time as the kernel clock.
187
+ // This value gets adjusted up or down as estimate of how long that should
188
+ // take, so we can reject attempts that take unusually long.
189
+ std::atomic<uint64_t> approx_syscall_time_in_cycles{10 * 1000};
190
+ // Number of times in a row we've seen a kernel time call take substantially
191
+ // less than approx_syscall_time_in_cycles.
192
+ std::atomic<uint32_t> kernel_time_seen_smaller{0};
193
+
194
+ // A reader-writer lock protecting the static locations below.
195
+ // See SeqAcquire() and SeqRelease() above.
196
+ absl::base_internal::SpinLock lock{absl::kConstInit,
197
+ base_internal::SCHEDULE_KERNEL_ONLY};
198
+ };
199
+ ABSL_CONST_INIT static TimeState time_state{};
200
+
201
+ // Return the time in ns as told by the kernel interface. Place in *cycleclock
202
+ // the value of the cycleclock at about the time of the syscall.
203
+ // This call represents the time base that this module synchronizes to.
204
+ // Ensures that *cycleclock does not step back by up to (1 << 16) from
205
+ // last_cycleclock, to discard small backward counter steps. (Larger steps are
206
+ // assumed to be complete resyncs, which shouldn't happen. If they do, a full
207
+ // reinitialization of the outer algorithm should occur.)
208
+ static int64_t GetCurrentTimeNanosFromKernel(uint64_t last_cycleclock,
209
+ uint64_t *cycleclock)
210
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(time_state.lock) {
211
+ uint64_t local_approx_syscall_time_in_cycles = // local copy
212
+ time_state.approx_syscall_time_in_cycles.load(std::memory_order_relaxed);
213
+
214
+ int64_t current_time_nanos_from_system;
215
+ uint64_t before_cycles;
216
+ uint64_t after_cycles;
217
+ uint64_t elapsed_cycles;
218
+ int loops = 0;
219
+ do {
220
+ before_cycles = GET_CURRENT_TIME_NANOS_CYCLECLOCK_NOW();
221
+ current_time_nanos_from_system = GET_CURRENT_TIME_NANOS_FROM_SYSTEM();
222
+ after_cycles = GET_CURRENT_TIME_NANOS_CYCLECLOCK_NOW();
223
+ // elapsed_cycles is unsigned, so is large on overflow
224
+ elapsed_cycles = after_cycles - before_cycles;
225
+ if (elapsed_cycles >= local_approx_syscall_time_in_cycles &&
226
+ ++loops == 20) { // clock changed frequencies? Back off.
227
+ loops = 0;
228
+ if (local_approx_syscall_time_in_cycles < 1000 * 1000) {
229
+ local_approx_syscall_time_in_cycles =
230
+ (local_approx_syscall_time_in_cycles + 1) << 1;
231
+ }
232
+ time_state.approx_syscall_time_in_cycles.store(
233
+ local_approx_syscall_time_in_cycles, std::memory_order_relaxed);
234
+ }
235
+ } while (elapsed_cycles >= local_approx_syscall_time_in_cycles ||
236
+ last_cycleclock - after_cycles < (static_cast<uint64_t>(1) << 16));
237
+
238
+ // Adjust approx_syscall_time_in_cycles to be within a factor of 2
239
+ // of the typical time to execute one iteration of the loop above.
240
+ if ((local_approx_syscall_time_in_cycles >> 1) < elapsed_cycles) {
241
+ // measured time is no smaller than half current approximation
242
+ time_state.kernel_time_seen_smaller.store(0, std::memory_order_relaxed);
243
+ } else if (time_state.kernel_time_seen_smaller.fetch_add(
244
+ 1, std::memory_order_relaxed) >= 3) {
245
+ // smaller delays several times in a row; reduce approximation by 12.5%
246
+ const uint64_t new_approximation =
247
+ local_approx_syscall_time_in_cycles -
248
+ (local_approx_syscall_time_in_cycles >> 3);
249
+ time_state.approx_syscall_time_in_cycles.store(new_approximation,
250
+ std::memory_order_relaxed);
251
+ time_state.kernel_time_seen_smaller.store(0, std::memory_order_relaxed);
252
+ }
253
+
254
+ *cycleclock = after_cycles;
255
+ return current_time_nanos_from_system;
256
+ }
253
257
 
254
258
  static int64_t GetCurrentTimeNanosSlowPath() ABSL_ATTRIBUTE_COLD;
255
259
 
@@ -317,14 +321,15 @@ int64_t GetCurrentTimeNanos() {
317
321
  // Acquire pairs with the barrier in SeqRelease - if this load sees that
318
322
  // store, the shared-data reads necessarily see that SeqRelease's updates
319
323
  // to the same shared data.
320
- seq_read0 = seq.load(std::memory_order_acquire);
324
+ seq_read0 = time_state.seq.load(std::memory_order_acquire);
321
325
 
322
- base_ns = last_sample.base_ns.load(std::memory_order_relaxed);
323
- base_cycles = last_sample.base_cycles.load(std::memory_order_relaxed);
326
+ base_ns = time_state.last_sample.base_ns.load(std::memory_order_relaxed);
327
+ base_cycles =
328
+ time_state.last_sample.base_cycles.load(std::memory_order_relaxed);
324
329
  nsscaled_per_cycle =
325
- last_sample.nsscaled_per_cycle.load(std::memory_order_relaxed);
326
- min_cycles_per_sample =
327
- last_sample.min_cycles_per_sample.load(std::memory_order_relaxed);
330
+ time_state.last_sample.nsscaled_per_cycle.load(std::memory_order_relaxed);
331
+ min_cycles_per_sample = time_state.last_sample.min_cycles_per_sample.load(
332
+ std::memory_order_relaxed);
328
333
 
329
334
  // This acquire fence pairs with the release fence in SeqAcquire. Since it
330
335
  // is sequenced between reads of shared data and seq_read1, the reads of
@@ -335,7 +340,7 @@ int64_t GetCurrentTimeNanos() {
335
340
  // shared-data writes are effectively release ordered. Therefore if our
336
341
  // shared-data reads see any of a particular update's shared-data writes,
337
342
  // seq_read1 is guaranteed to see that update's SeqAcquire.
338
- seq_read1 = seq.load(std::memory_order_relaxed);
343
+ seq_read1 = time_state.seq.load(std::memory_order_relaxed);
339
344
 
340
345
  // Fast path. Return if min_cycles_per_sample has not yet elapsed since the
341
346
  // last sample, and we read a consistent sample. The fast path activates
@@ -348,9 +353,9 @@ int64_t GetCurrentTimeNanos() {
348
353
  // last_sample was updated). This is harmless, because delta_cycles will wrap
349
354
  // and report a time much much bigger than min_cycles_per_sample. In that case
350
355
  // we will take the slow path.
351
- uint64_t delta_cycles = now_cycles - base_cycles;
356
+ uint64_t delta_cycles;
352
357
  if (seq_read0 == seq_read1 && (seq_read0 & 1) == 0 &&
353
- delta_cycles < min_cycles_per_sample) {
358
+ (delta_cycles = now_cycles - base_cycles) < min_cycles_per_sample) {
354
359
  return base_ns + ((delta_cycles * nsscaled_per_cycle) >> kScale);
355
360
  }
356
361
  return GetCurrentTimeNanosSlowPath();
@@ -390,24 +395,25 @@ static uint64_t UpdateLastSample(
390
395
  // TODO(absl-team): Remove this attribute when our compiler is smart enough
391
396
  // to do the right thing.
392
397
  ABSL_ATTRIBUTE_NOINLINE
393
- static int64_t GetCurrentTimeNanosSlowPath() ABSL_LOCKS_EXCLUDED(lock) {
398
+ static int64_t GetCurrentTimeNanosSlowPath()
399
+ ABSL_LOCKS_EXCLUDED(time_state.lock) {
394
400
  // Serialize access to slow-path. Fast-path readers are not blocked yet, and
395
401
  // code below must not modify last_sample until the seqlock is acquired.
396
- lock.Lock();
402
+ time_state.lock.Lock();
397
403
 
398
404
  // Sample the kernel time base. This is the definition of
399
405
  // "now" if we take the slow path.
400
- static uint64_t last_now_cycles; // protected by lock
401
406
  uint64_t now_cycles;
402
- uint64_t now_ns = GetCurrentTimeNanosFromKernel(last_now_cycles, &now_cycles);
403
- last_now_cycles = now_cycles;
407
+ uint64_t now_ns =
408
+ GetCurrentTimeNanosFromKernel(time_state.last_now_cycles, &now_cycles);
409
+ time_state.last_now_cycles = now_cycles;
404
410
 
405
411
  uint64_t estimated_base_ns;
406
412
 
407
413
  // ----------
408
414
  // Read the "last_sample" values again; this time holding the write lock.
409
415
  struct TimeSample sample;
410
- ReadTimeSampleAtomic(&last_sample, &sample);
416
+ ReadTimeSampleAtomic(&time_state.last_sample, &sample);
411
417
 
412
418
  // ----------
413
419
  // Try running the fast path again; another thread may have updated the
@@ -418,13 +424,13 @@ static int64_t GetCurrentTimeNanosSlowPath() ABSL_LOCKS_EXCLUDED(lock) {
418
424
  // so that blocked readers can make progress without blocking new readers.
419
425
  estimated_base_ns = sample.base_ns +
420
426
  ((delta_cycles * sample.nsscaled_per_cycle) >> kScale);
421
- stats_fast_slow_paths++;
427
+ time_state.stats_fast_slow_paths++;
422
428
  } else {
423
429
  estimated_base_ns =
424
430
  UpdateLastSample(now_cycles, now_ns, delta_cycles, &sample);
425
431
  }
426
432
 
427
- lock.Unlock();
433
+ time_state.lock.Unlock();
428
434
 
429
435
  return estimated_base_ns;
430
436
  }
@@ -435,9 +441,10 @@ static int64_t GetCurrentTimeNanosSlowPath() ABSL_LOCKS_EXCLUDED(lock) {
435
441
  static uint64_t UpdateLastSample(uint64_t now_cycles, uint64_t now_ns,
436
442
  uint64_t delta_cycles,
437
443
  const struct TimeSample *sample)
438
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock) {
444
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(time_state.lock) {
439
445
  uint64_t estimated_base_ns = now_ns;
440
- uint64_t lock_value = SeqAcquire(&seq); // acquire seqlock to block readers
446
+ uint64_t lock_value =
447
+ SeqAcquire(&time_state.seq); // acquire seqlock to block readers
441
448
 
442
449
  // The 5s in the next if-statement limits the time for which we will trust
443
450
  // the cycle counter and our last sample to give a reasonable result.
@@ -447,12 +454,16 @@ static uint64_t UpdateLastSample(uint64_t now_cycles, uint64_t now_ns,
447
454
  sample->raw_ns + static_cast<uint64_t>(5) * 1000 * 1000 * 1000 < now_ns ||
448
455
  now_ns < sample->raw_ns || now_cycles < sample->base_cycles) {
449
456
  // record this sample, and forget any previously known slope.
450
- last_sample.raw_ns.store(now_ns, std::memory_order_relaxed);
451
- last_sample.base_ns.store(estimated_base_ns, std::memory_order_relaxed);
452
- last_sample.base_cycles.store(now_cycles, std::memory_order_relaxed);
453
- last_sample.nsscaled_per_cycle.store(0, std::memory_order_relaxed);
454
- last_sample.min_cycles_per_sample.store(0, std::memory_order_relaxed);
455
- stats_initializations++;
457
+ time_state.last_sample.raw_ns.store(now_ns, std::memory_order_relaxed);
458
+ time_state.last_sample.base_ns.store(estimated_base_ns,
459
+ std::memory_order_relaxed);
460
+ time_state.last_sample.base_cycles.store(now_cycles,
461
+ std::memory_order_relaxed);
462
+ time_state.last_sample.nsscaled_per_cycle.store(0,
463
+ std::memory_order_relaxed);
464
+ time_state.last_sample.min_cycles_per_sample.store(
465
+ 0, std::memory_order_relaxed);
466
+ time_state.stats_initializations++;
456
467
  } else if (sample->raw_ns + 500 * 1000 * 1000 < now_ns &&
457
468
  sample->base_cycles + 50 < now_cycles) {
458
469
  // Enough time has passed to compute the cycle time.
@@ -495,28 +506,32 @@ static uint64_t UpdateLastSample(uint64_t now_cycles, uint64_t now_ns,
495
506
  if (new_nsscaled_per_cycle != 0 &&
496
507
  diff_ns < 100 * 1000 * 1000 && -diff_ns < 100 * 1000 * 1000) {
497
508
  // record the cycle time measurement
498
- last_sample.nsscaled_per_cycle.store(
509
+ time_state.last_sample.nsscaled_per_cycle.store(
499
510
  new_nsscaled_per_cycle, std::memory_order_relaxed);
500
511
  uint64_t new_min_cycles_per_sample =
501
512
  SafeDivideAndScale(kMinNSBetweenSamples, new_nsscaled_per_cycle);
502
- last_sample.min_cycles_per_sample.store(
513
+ time_state.last_sample.min_cycles_per_sample.store(
503
514
  new_min_cycles_per_sample, std::memory_order_relaxed);
504
- stats_calibrations++;
515
+ time_state.stats_calibrations++;
505
516
  } else { // something went wrong; forget the slope
506
- last_sample.nsscaled_per_cycle.store(0, std::memory_order_relaxed);
507
- last_sample.min_cycles_per_sample.store(0, std::memory_order_relaxed);
517
+ time_state.last_sample.nsscaled_per_cycle.store(
518
+ 0, std::memory_order_relaxed);
519
+ time_state.last_sample.min_cycles_per_sample.store(
520
+ 0, std::memory_order_relaxed);
508
521
  estimated_base_ns = now_ns;
509
- stats_reinitializations++;
522
+ time_state.stats_reinitializations++;
510
523
  }
511
- last_sample.raw_ns.store(now_ns, std::memory_order_relaxed);
512
- last_sample.base_ns.store(estimated_base_ns, std::memory_order_relaxed);
513
- last_sample.base_cycles.store(now_cycles, std::memory_order_relaxed);
524
+ time_state.last_sample.raw_ns.store(now_ns, std::memory_order_relaxed);
525
+ time_state.last_sample.base_ns.store(estimated_base_ns,
526
+ std::memory_order_relaxed);
527
+ time_state.last_sample.base_cycles.store(now_cycles,
528
+ std::memory_order_relaxed);
514
529
  } else {
515
530
  // have a sample, but no slope; waiting for enough time for a calibration
516
- stats_slow_paths++;
531
+ time_state.stats_slow_paths++;
517
532
  }
518
533
 
519
- SeqRelease(&seq, lock_value); // release the readers
534
+ SeqRelease(&time_state.seq, lock_value); // release the readers
520
535
 
521
536
  return estimated_base_ns;
522
537
  }
@@ -558,7 +573,8 @@ ABSL_NAMESPACE_END
558
573
 
559
574
  extern "C" {
560
575
 
561
- ABSL_ATTRIBUTE_WEAK void AbslInternalSleepFor(absl::Duration duration) {
576
+ ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSleepFor)(
577
+ absl::Duration duration) {
562
578
  while (duration > absl::ZeroDuration()) {
563
579
  absl::Duration to_sleep = std::min(duration, absl::MaxSleep());
564
580
  absl::SleepOnce(to_sleep);