grpc 1.24.0 → 1.25.0.pre1

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 (504) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +306 -243
  3. data/etc/roots.pem +0 -100
  4. data/include/grpc/grpc_security.h +44 -18
  5. data/include/grpc/impl/codegen/grpc_types.h +15 -0
  6. data/include/grpc/impl/codegen/port_platform.h +27 -11
  7. data/include/grpc/impl/codegen/sync_generic.h +1 -1
  8. data/src/boringssl/err_data.c +695 -650
  9. data/src/core/ext/filters/client_channel/client_channel.cc +257 -179
  10. data/src/core/ext/filters/client_channel/client_channel.h +24 -0
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
  12. data/src/core/ext/filters/client_channel/client_channel_factory.h +1 -5
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +18 -45
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +5 -13
  15. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy.cc +2 -3
  17. data/src/core/ext/filters/client_channel/lb_policy.h +65 -55
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -14
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +113 -36
  20. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -19
  21. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +36 -13
  22. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +3 -10
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +814 -1589
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +2 -5
  25. data/src/core/ext/filters/client_channel/lb_policy_factory.h +3 -6
  26. data/src/core/ext/filters/client_channel/resolver.cc +1 -2
  27. data/src/core/ext/filters/client_channel/resolver.h +8 -16
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +25 -8
  29. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +46 -12
  30. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +10 -17
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +7 -8
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +111 -44
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +22 -14
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
  37. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +29 -10
  38. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +27 -36
  39. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +7 -10
  40. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +60 -16
  41. data/src/core/ext/filters/client_channel/resolver_factory.h +4 -8
  42. data/src/core/ext/filters/client_channel/resolver_registry.cc +1 -1
  43. data/src/core/ext/filters/client_channel/resolver_registry.h +1 -1
  44. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -10
  45. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +7 -8
  46. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -1
  47. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -5
  48. data/src/core/ext/filters/client_channel/retry_throttle.h +1 -4
  49. data/src/core/ext/filters/client_channel/service_config.h +8 -8
  50. data/src/core/ext/filters/client_channel/subchannel.cc +53 -86
  51. data/src/core/ext/filters/client_channel/subchannel.h +7 -9
  52. data/src/core/ext/filters/client_channel/subchannel_interface.h +9 -13
  53. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +3 -6
  54. data/src/core/ext/filters/client_channel/{lb_policy/xds/xds_load_balancer_api.cc → xds/xds_api.cc} +169 -52
  55. data/src/core/ext/filters/client_channel/xds/xds_api.h +171 -0
  56. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +450 -0
  57. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +99 -0
  58. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel.h +8 -6
  59. data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
  60. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel_secure.cc +28 -11
  61. data/src/core/ext/filters/client_channel/xds/xds_client.cc +1413 -0
  62. data/src/core/ext/filters/client_channel/xds/xds_client.h +221 -0
  63. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.cc +1 -5
  64. data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.h +3 -4
  65. data/src/core/ext/filters/deadline/deadline_filter.cc +20 -20
  66. data/src/core/ext/filters/http/client/http_client_filter.cc +15 -15
  67. data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
  68. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +12 -12
  69. data/src/core/ext/filters/max_age/max_age_filter.cc +59 -50
  70. data/src/core/ext/filters/message_size/message_size_filter.cc +18 -18
  71. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -14
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +233 -175
  73. data/src/core/ext/transport/chttp2/transport/flow_control.h +21 -24
  74. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +253 -163
  75. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +24 -12
  76. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -3
  77. data/src/core/ext/transport/chttp2/transport/internal.h +13 -15
  78. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -0
  79. data/src/core/ext/transport/inproc/inproc_transport.cc +20 -13
  80. data/src/core/lib/channel/channel_args.cc +16 -0
  81. data/src/core/lib/channel/channel_args.h +22 -0
  82. data/src/core/lib/channel/channelz.cc +5 -6
  83. data/src/core/lib/channel/channelz.h +1 -1
  84. data/src/core/lib/channel/connected_channel.cc +20 -20
  85. data/src/core/lib/channel/handshaker.h +3 -4
  86. data/src/core/lib/channel/handshaker_factory.h +1 -3
  87. data/src/core/lib/debug/trace.h +3 -2
  88. data/src/core/lib/gprpp/arena.cc +3 -3
  89. data/src/core/lib/gprpp/arena.h +2 -3
  90. data/src/core/lib/gprpp/inlined_vector.h +9 -0
  91. data/src/core/lib/gprpp/map.h +3 -501
  92. data/src/core/lib/gprpp/memory.h +45 -41
  93. data/src/core/lib/gprpp/mpscq.cc +108 -0
  94. data/src/core/lib/gprpp/mpscq.h +98 -0
  95. data/src/core/lib/gprpp/orphanable.h +6 -11
  96. data/src/core/lib/gprpp/ref_counted.h +25 -19
  97. data/src/core/lib/gprpp/set.h +33 -0
  98. data/src/core/lib/gprpp/thd.h +2 -4
  99. data/src/core/lib/http/httpcli.cc +1 -1
  100. data/src/core/lib/http/httpcli_security_connector.cc +15 -11
  101. data/src/core/lib/http/parser.cc +1 -1
  102. data/src/core/lib/iomgr/buffer_list.cc +4 -5
  103. data/src/core/lib/iomgr/buffer_list.h +5 -6
  104. data/src/core/lib/iomgr/call_combiner.cc +4 -5
  105. data/src/core/lib/iomgr/call_combiner.h +2 -2
  106. data/src/core/lib/iomgr/cfstream_handle.h +3 -5
  107. data/src/core/lib/iomgr/closure.h +8 -3
  108. data/src/core/lib/iomgr/combiner.cc +45 -82
  109. data/src/core/lib/iomgr/combiner.h +32 -8
  110. data/src/core/lib/iomgr/endpoint_cfstream.cc +5 -3
  111. data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -15
  112. data/src/core/lib/iomgr/exec_ctx.h +4 -3
  113. data/src/core/lib/iomgr/executor.cc +4 -2
  114. data/src/core/lib/iomgr/executor.h +3 -0
  115. data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -6
  116. data/src/core/lib/iomgr/executor/threadpool.cc +1 -2
  117. data/src/core/lib/iomgr/executor/threadpool.h +7 -11
  118. data/src/core/lib/iomgr/resource_quota.cc +55 -51
  119. data/src/core/lib/iomgr/resource_quota.h +13 -9
  120. data/src/core/lib/iomgr/socket_utils_common_posix.cc +13 -0
  121. data/src/core/lib/iomgr/socket_utils_posix.h +4 -0
  122. data/src/core/lib/iomgr/tcp_client_posix.cc +4 -11
  123. data/src/core/lib/iomgr/tcp_custom.cc +9 -7
  124. data/src/core/lib/iomgr/tcp_posix.cc +20 -16
  125. data/src/core/lib/iomgr/tcp_server.h +1 -4
  126. data/src/core/lib/iomgr/tcp_server_custom.cc +5 -5
  127. data/src/core/lib/iomgr/tcp_server_posix.cc +1 -1
  128. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -11
  129. data/src/core/lib/iomgr/timer_custom.cc +2 -2
  130. data/src/core/lib/iomgr/udp_server.cc +3 -2
  131. data/src/core/lib/iomgr/udp_server.h +6 -12
  132. data/src/core/lib/json/json.h +1 -1
  133. data/src/core/lib/json/json_string.cc +2 -2
  134. data/src/core/lib/profiling/basic_timers.cc +2 -2
  135. data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -2
  136. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +1 -1
  137. data/src/core/lib/security/credentials/credentials.h +4 -20
  138. data/src/core/lib/security/credentials/fake/fake_credentials.cc +4 -4
  139. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -3
  140. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +64 -0
  141. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +4 -4
  142. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +9 -7
  143. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -0
  144. data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -4
  145. data/src/core/lib/security/security_connector/security_connector.cc +1 -0
  146. data/src/core/lib/security/security_connector/security_connector.h +19 -17
  147. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +8 -5
  148. data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
  149. data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
  150. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -6
  151. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -2
  152. data/src/core/lib/security/transport/client_auth_filter.cc +17 -17
  153. data/src/core/lib/security/transport/security_handshaker.cc +29 -13
  154. data/src/core/lib/security/transport/security_handshaker.h +4 -2
  155. data/src/core/lib/security/transport/server_auth_filter.cc +14 -14
  156. data/src/core/lib/slice/slice.cc +2 -10
  157. data/src/core/lib/slice/slice_hash_table.h +4 -6
  158. data/src/core/lib/slice/slice_intern.cc +42 -39
  159. data/src/core/lib/slice/slice_internal.h +3 -3
  160. data/src/core/lib/slice/slice_utils.h +21 -4
  161. data/src/core/lib/slice/slice_weak_hash_table.h +4 -6
  162. data/src/core/lib/surface/call.cc +3 -3
  163. data/src/core/lib/surface/channel.cc +7 -0
  164. data/src/core/lib/surface/completion_queue.cc +12 -11
  165. data/src/core/lib/surface/completion_queue.h +4 -2
  166. data/src/core/lib/surface/init.cc +1 -0
  167. data/src/core/lib/surface/lame_client.cc +33 -18
  168. data/src/core/lib/surface/server.cc +77 -76
  169. data/src/core/lib/surface/version.cc +1 -1
  170. data/src/core/lib/transport/byte_stream.h +3 -7
  171. data/src/core/lib/transport/connectivity_state.cc +112 -98
  172. data/src/core/lib/transport/connectivity_state.h +100 -50
  173. data/src/core/lib/transport/static_metadata.cc +276 -288
  174. data/src/core/lib/transport/static_metadata.h +73 -76
  175. data/src/core/lib/transport/status_conversion.cc +1 -1
  176. data/src/core/lib/transport/status_metadata.cc +1 -1
  177. data/src/core/lib/transport/transport.cc +2 -2
  178. data/src/core/lib/transport/transport.h +12 -4
  179. data/src/core/lib/transport/transport_op_string.cc +14 -11
  180. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +1 -1
  181. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +1 -1
  182. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +5 -5
  183. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -2
  184. data/src/core/tsi/fake_transport_security.cc +7 -5
  185. data/src/core/tsi/grpc_shadow_boringssl.h +2918 -2627
  186. data/src/core/tsi/local_transport_security.cc +8 -6
  187. data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -3
  188. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -2
  189. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +7 -5
  190. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -6
  191. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -2
  192. data/src/core/tsi/ssl_transport_security.cc +12 -12
  193. data/src/core/tsi/ssl_transport_security.h +2 -2
  194. data/src/core/tsi/transport_security_grpc.cc +7 -0
  195. data/src/core/tsi/transport_security_grpc.h +6 -0
  196. data/src/ruby/ext/grpc/extconf.rb +1 -0
  197. data/src/ruby/ext/grpc/rb_call.c +1 -1
  198. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  199. data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
  200. data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
  201. data/src/ruby/lib/grpc/version.rb +1 -1
  202. data/src/ruby/spec/google_rpc_status_utils_spec.rb +2 -2
  203. data/third_party/boringssl/crypto/asn1/a_bool.c +18 -5
  204. data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +17 -221
  205. data/third_party/boringssl/crypto/asn1/a_dup.c +0 -24
  206. data/third_party/boringssl/crypto/asn1/a_enum.c +2 -2
  207. data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +10 -72
  208. data/third_party/boringssl/crypto/asn1/a_int.c +12 -71
  209. data/third_party/boringssl/crypto/asn1/a_mbstr.c +110 -216
  210. data/third_party/boringssl/crypto/asn1/a_object.c +16 -5
  211. data/third_party/boringssl/crypto/asn1/a_strnid.c +1 -0
  212. data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -1
  213. data/third_party/boringssl/crypto/asn1/tasn_enc.c +3 -1
  214. data/third_party/boringssl/crypto/base64/base64.c +2 -2
  215. data/third_party/boringssl/crypto/bio/bio.c +73 -9
  216. data/third_party/boringssl/crypto/bio/connect.c +4 -0
  217. data/third_party/boringssl/crypto/bio/fd.c +4 -0
  218. data/third_party/boringssl/crypto/bio/file.c +5 -2
  219. data/third_party/boringssl/crypto/bio/socket.c +4 -0
  220. data/third_party/boringssl/crypto/bio/socket_helper.c +4 -0
  221. data/third_party/boringssl/crypto/bn_extra/convert.c +11 -7
  222. data/third_party/boringssl/crypto/bytestring/ber.c +8 -4
  223. data/third_party/boringssl/crypto/bytestring/cbb.c +19 -7
  224. data/third_party/boringssl/crypto/bytestring/cbs.c +28 -15
  225. data/third_party/boringssl/crypto/bytestring/internal.h +28 -7
  226. data/third_party/boringssl/crypto/bytestring/unicode.c +155 -0
  227. data/third_party/boringssl/crypto/chacha/chacha.c +36 -19
  228. data/third_party/boringssl/crypto/chacha/internal.h +45 -0
  229. data/third_party/boringssl/crypto/cipher_extra/cipher_extra.c +29 -0
  230. data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +269 -25
  231. data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +16 -14
  232. data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +54 -38
  233. data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +133 -41
  234. data/third_party/boringssl/crypto/cipher_extra/e_tls.c +23 -15
  235. data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +24 -15
  236. data/third_party/boringssl/crypto/cmac/cmac.c +62 -25
  237. data/third_party/boringssl/crypto/conf/conf.c +7 -0
  238. data/third_party/boringssl/crypto/cpu-arm-linux.c +4 -148
  239. data/third_party/boringssl/crypto/cpu-arm-linux.h +201 -0
  240. data/third_party/boringssl/crypto/cpu-intel.c +45 -51
  241. data/third_party/boringssl/crypto/crypto.c +39 -22
  242. data/third_party/boringssl/crypto/curve25519/spake25519.c +1 -1
  243. data/third_party/boringssl/crypto/dsa/dsa.c +77 -53
  244. data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +20 -8
  245. data/third_party/boringssl/crypto/ec_extra/ec_derive.c +96 -0
  246. data/third_party/boringssl/crypto/{ecdh/ecdh.c → ecdh_extra/ecdh_extra.c} +20 -58
  247. data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -9
  248. data/third_party/boringssl/crypto/engine/engine.c +2 -1
  249. data/third_party/boringssl/crypto/err/err.c +2 -0
  250. data/third_party/boringssl/crypto/err/internal.h +2 -2
  251. data/third_party/boringssl/crypto/evp/evp.c +89 -8
  252. data/third_party/boringssl/crypto/evp/evp_asn1.c +56 -5
  253. data/third_party/boringssl/crypto/evp/evp_ctx.c +52 -14
  254. data/third_party/boringssl/crypto/evp/internal.h +18 -1
  255. data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +5 -0
  256. data/third_party/boringssl/crypto/evp/p_ec.c +51 -3
  257. data/third_party/boringssl/crypto/evp/p_ec_asn1.c +6 -7
  258. data/third_party/boringssl/crypto/evp/p_ed25519.c +36 -3
  259. data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +76 -45
  260. data/third_party/boringssl/crypto/evp/p_rsa.c +3 -1
  261. data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +5 -0
  262. data/third_party/boringssl/crypto/evp/p_x25519.c +110 -0
  263. data/third_party/boringssl/crypto/evp/p_x25519_asn1.c +249 -0
  264. data/third_party/boringssl/crypto/evp/scrypt.c +6 -2
  265. data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +34 -274
  266. data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +161 -21
  267. data/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c +111 -13
  268. data/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c +17 -21
  269. data/third_party/boringssl/crypto/fipsmodule/bcm.c +119 -7
  270. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +19 -2
  271. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +2 -2
  272. data/third_party/boringssl/crypto/fipsmodule/bn/ctx.c +93 -160
  273. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +48 -57
  274. data/third_party/boringssl/crypto/fipsmodule/bn/div_extra.c +87 -0
  275. data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +143 -211
  276. data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +0 -305
  277. data/third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c +325 -0
  278. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +168 -50
  279. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +68 -92
  280. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +7 -6
  281. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +11 -14
  282. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +358 -443
  283. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +25 -35
  284. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +20 -25
  285. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +76 -5
  286. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +14 -14
  287. data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +7 -2
  288. data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +383 -516
  289. data/third_party/boringssl/crypto/fipsmodule/cipher/e_des.c +4 -0
  290. data/third_party/boringssl/crypto/fipsmodule/cipher/internal.h +3 -4
  291. data/third_party/boringssl/crypto/fipsmodule/delocate.h +3 -2
  292. data/third_party/boringssl/crypto/fipsmodule/digest/digest.c +32 -17
  293. data/third_party/boringssl/crypto/fipsmodule/digest/md32_common.h +3 -3
  294. data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +228 -122
  295. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +34 -8
  296. data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +311 -98
  297. data/third_party/boringssl/crypto/fipsmodule/ec/felem.c +82 -0
  298. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +263 -97
  299. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +22 -59
  300. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +317 -234
  301. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +9473 -9475
  302. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +313 -109
  303. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +36 -0
  304. data/third_party/boringssl/crypto/fipsmodule/ec/scalar.c +96 -0
  305. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +126 -792
  306. data/third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c +84 -0
  307. data/third_party/boringssl/crypto/fipsmodule/ec/util.c +163 -12
  308. data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +84 -211
  309. data/third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c +122 -0
  310. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +60 -205
  311. data/third_party/boringssl/crypto/fipsmodule/fips_shared_support.c +32 -0
  312. data/third_party/boringssl/crypto/fipsmodule/is_fips.c +2 -0
  313. data/third_party/boringssl/crypto/fipsmodule/md4/md4.c +3 -1
  314. data/third_party/boringssl/crypto/fipsmodule/md5/internal.h +37 -0
  315. data/third_party/boringssl/crypto/fipsmodule/md5/md5.c +11 -8
  316. data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +35 -79
  317. data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +7 -39
  318. data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +7 -27
  319. data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +123 -309
  320. data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +189 -126
  321. data/third_party/boringssl/crypto/fipsmodule/modes/ofb.c +3 -2
  322. data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +2 -2
  323. data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +35 -0
  324. data/third_party/boringssl/crypto/fipsmodule/rand/rand.c +24 -19
  325. data/third_party/boringssl/crypto/fipsmodule/rand/urandom.c +256 -77
  326. data/third_party/boringssl/crypto/fipsmodule/rsa/padding.c +10 -7
  327. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +5 -1
  328. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +131 -14
  329. data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +83 -10
  330. data/third_party/boringssl/crypto/fipsmodule/sha/internal.h +53 -0
  331. data/third_party/boringssl/crypto/fipsmodule/sha/sha1.c +9 -13
  332. data/third_party/boringssl/crypto/fipsmodule/sha/sha256.c +18 -12
  333. data/third_party/boringssl/crypto/fipsmodule/sha/sha512.c +95 -168
  334. data/third_party/boringssl/crypto/hrss/hrss.c +2201 -0
  335. data/third_party/boringssl/crypto/hrss/internal.h +62 -0
  336. data/third_party/boringssl/crypto/internal.h +95 -20
  337. data/third_party/boringssl/crypto/lhash/lhash.c +45 -33
  338. data/third_party/boringssl/crypto/mem.c +39 -2
  339. data/third_party/boringssl/crypto/obj/obj.c +4 -4
  340. data/third_party/boringssl/crypto/obj/obj_dat.h +6181 -875
  341. data/third_party/boringssl/crypto/pem/pem_all.c +2 -3
  342. data/third_party/boringssl/crypto/pem/pem_info.c +144 -162
  343. data/third_party/boringssl/crypto/pem/pem_lib.c +53 -52
  344. data/third_party/boringssl/crypto/pem/pem_pkey.c +13 -21
  345. data/third_party/boringssl/crypto/pkcs7/pkcs7.c +15 -22
  346. data/third_party/boringssl/crypto/pkcs7/pkcs7_x509.c +168 -16
  347. data/third_party/boringssl/crypto/pkcs8/internal.h +11 -0
  348. data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +24 -15
  349. data/third_party/boringssl/crypto/pkcs8/pkcs8.c +42 -25
  350. data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +559 -43
  351. data/third_party/boringssl/crypto/pool/internal.h +1 -1
  352. data/third_party/boringssl/crypto/pool/pool.c +21 -0
  353. data/third_party/boringssl/crypto/rand_extra/deterministic.c +8 -0
  354. data/third_party/boringssl/crypto/rand_extra/fuchsia.c +1 -14
  355. data/third_party/boringssl/crypto/refcount_lock.c +2 -2
  356. data/third_party/boringssl/crypto/rsa_extra/rsa_print.c +22 -0
  357. data/third_party/boringssl/crypto/siphash/siphash.c +80 -0
  358. data/third_party/boringssl/crypto/stack/stack.c +83 -32
  359. data/third_party/boringssl/crypto/thread_none.c +2 -2
  360. data/third_party/boringssl/crypto/thread_pthread.c +2 -2
  361. data/third_party/boringssl/crypto/thread_win.c +38 -19
  362. data/third_party/boringssl/crypto/x509/a_strex.c +22 -2
  363. data/third_party/boringssl/crypto/x509/asn1_gen.c +2 -1
  364. data/third_party/boringssl/crypto/x509/by_dir.c +7 -0
  365. data/third_party/boringssl/crypto/x509/by_file.c +12 -10
  366. data/third_party/boringssl/crypto/x509/t_crl.c +5 -8
  367. data/third_party/boringssl/crypto/x509/t_req.c +1 -3
  368. data/third_party/boringssl/crypto/x509/t_x509.c +5 -8
  369. data/third_party/boringssl/crypto/x509/x509_cmp.c +1 -1
  370. data/third_party/boringssl/crypto/x509/x509_def.c +1 -1
  371. data/third_party/boringssl/crypto/x509/x509_lu.c +114 -5
  372. data/third_party/boringssl/crypto/x509/x509_req.c +20 -0
  373. data/third_party/boringssl/crypto/x509/x509_set.c +5 -0
  374. data/third_party/boringssl/crypto/x509/x509_trs.c +1 -0
  375. data/third_party/boringssl/crypto/x509/x509_txt.c +4 -5
  376. data/third_party/boringssl/crypto/x509/x509_vfy.c +145 -138
  377. data/third_party/boringssl/crypto/x509/x509_vpm.c +2 -0
  378. data/third_party/boringssl/crypto/x509/x509cset.c +40 -0
  379. data/third_party/boringssl/crypto/x509/x509name.c +2 -3
  380. data/third_party/boringssl/crypto/x509/x_all.c +109 -210
  381. data/third_party/boringssl/crypto/x509/x_x509.c +6 -0
  382. data/third_party/boringssl/crypto/x509v3/ext_dat.h +1 -3
  383. data/third_party/boringssl/crypto/x509v3/internal.h +56 -0
  384. data/third_party/boringssl/crypto/x509v3/pcy_cache.c +2 -0
  385. data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -0
  386. data/third_party/boringssl/crypto/x509v3/pcy_tree.c +4 -2
  387. data/third_party/boringssl/crypto/x509v3/v3_akey.c +5 -2
  388. data/third_party/boringssl/crypto/x509v3/v3_alt.c +19 -13
  389. data/third_party/boringssl/crypto/x509v3/v3_conf.c +2 -1
  390. data/third_party/boringssl/crypto/x509v3/v3_cpols.c +3 -2
  391. data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -6
  392. data/third_party/boringssl/crypto/x509v3/v3_lib.c +1 -0
  393. data/third_party/boringssl/crypto/x509v3/v3_ocsp.c +68 -0
  394. data/third_party/boringssl/crypto/x509v3/v3_pci.c +2 -1
  395. data/third_party/boringssl/crypto/x509v3/v3_purp.c +47 -69
  396. data/third_party/boringssl/crypto/x509v3/v3_skey.c +5 -2
  397. data/third_party/boringssl/crypto/x509v3/v3_utl.c +69 -25
  398. data/third_party/boringssl/include/openssl/aead.h +45 -19
  399. data/third_party/boringssl/include/openssl/aes.h +32 -7
  400. data/third_party/boringssl/include/openssl/asn1.h +7 -77
  401. data/third_party/boringssl/include/openssl/base.h +120 -6
  402. data/third_party/boringssl/include/openssl/base64.h +4 -1
  403. data/third_party/boringssl/include/openssl/bio.h +112 -81
  404. data/third_party/boringssl/include/openssl/blowfish.h +3 -3
  405. data/third_party/boringssl/include/openssl/bn.h +55 -29
  406. data/third_party/boringssl/include/openssl/buf.h +2 -2
  407. data/third_party/boringssl/include/openssl/bytestring.h +54 -32
  408. data/third_party/boringssl/include/openssl/cast.h +2 -2
  409. data/third_party/boringssl/include/openssl/cipher.h +46 -16
  410. data/third_party/boringssl/include/openssl/cmac.h +6 -2
  411. data/third_party/boringssl/include/openssl/conf.h +3 -6
  412. data/third_party/boringssl/include/openssl/cpu.h +25 -9
  413. data/third_party/boringssl/include/openssl/crypto.h +32 -10
  414. data/third_party/boringssl/include/openssl/curve25519.h +4 -4
  415. data/third_party/boringssl/include/openssl/dh.h +3 -2
  416. data/third_party/boringssl/include/openssl/digest.h +21 -7
  417. data/third_party/boringssl/include/openssl/dsa.h +8 -2
  418. data/third_party/boringssl/include/openssl/e_os2.h +18 -0
  419. data/third_party/boringssl/include/openssl/ec.h +25 -21
  420. data/third_party/boringssl/include/openssl/ec_key.h +36 -8
  421. data/third_party/boringssl/include/openssl/ecdh.h +17 -0
  422. data/third_party/boringssl/include/openssl/ecdsa.h +3 -3
  423. data/third_party/boringssl/include/openssl/engine.h +4 -4
  424. data/third_party/boringssl/include/openssl/err.h +3 -0
  425. data/third_party/boringssl/include/openssl/evp.h +199 -42
  426. data/third_party/boringssl/include/openssl/hmac.h +4 -4
  427. data/third_party/boringssl/include/openssl/hrss.h +100 -0
  428. data/third_party/boringssl/include/openssl/lhash.h +131 -23
  429. data/third_party/boringssl/include/openssl/md4.h +6 -4
  430. data/third_party/boringssl/include/openssl/md5.h +6 -4
  431. data/third_party/boringssl/include/openssl/mem.h +6 -2
  432. data/third_party/boringssl/include/openssl/nid.h +3 -0
  433. data/third_party/boringssl/include/openssl/obj.h +3 -0
  434. data/third_party/boringssl/include/openssl/pem.h +102 -64
  435. data/third_party/boringssl/include/openssl/pkcs7.h +136 -3
  436. data/third_party/boringssl/include/openssl/pkcs8.h +42 -3
  437. data/third_party/boringssl/include/openssl/pool.h +13 -2
  438. data/third_party/boringssl/include/openssl/ripemd.h +5 -4
  439. data/third_party/boringssl/include/openssl/rsa.h +46 -15
  440. data/third_party/boringssl/include/openssl/sha.h +40 -28
  441. data/third_party/boringssl/include/openssl/siphash.h +37 -0
  442. data/third_party/boringssl/include/openssl/span.h +17 -9
  443. data/third_party/boringssl/include/openssl/ssl.h +766 -393
  444. data/third_party/boringssl/include/openssl/ssl3.h +4 -3
  445. data/third_party/boringssl/include/openssl/stack.h +134 -77
  446. data/third_party/boringssl/include/openssl/thread.h +1 -1
  447. data/third_party/boringssl/include/openssl/tls1.h +25 -9
  448. data/third_party/boringssl/include/openssl/type_check.h +14 -15
  449. data/third_party/boringssl/include/openssl/x509.h +28 -3
  450. data/third_party/boringssl/include/openssl/x509_vfy.h +98 -32
  451. data/third_party/boringssl/include/openssl/x509v3.h +17 -13
  452. data/third_party/boringssl/ssl/d1_both.cc +9 -18
  453. data/third_party/boringssl/ssl/d1_lib.cc +4 -3
  454. data/third_party/boringssl/ssl/d1_pkt.cc +4 -4
  455. data/third_party/boringssl/ssl/d1_srtp.cc +15 -15
  456. data/third_party/boringssl/ssl/dtls_method.cc +0 -1
  457. data/third_party/boringssl/ssl/dtls_record.cc +28 -28
  458. data/third_party/boringssl/ssl/handoff.cc +295 -91
  459. data/third_party/boringssl/ssl/handshake.cc +133 -72
  460. data/third_party/boringssl/ssl/handshake_client.cc +218 -189
  461. data/third_party/boringssl/ssl/handshake_server.cc +399 -272
  462. data/third_party/boringssl/ssl/internal.h +1413 -928
  463. data/third_party/boringssl/ssl/s3_both.cc +175 -36
  464. data/third_party/boringssl/ssl/s3_lib.cc +9 -13
  465. data/third_party/boringssl/ssl/s3_pkt.cc +63 -29
  466. data/third_party/boringssl/ssl/ssl_aead_ctx.cc +55 -35
  467. data/third_party/boringssl/ssl/ssl_asn1.cc +57 -73
  468. data/third_party/boringssl/ssl/ssl_buffer.cc +13 -12
  469. data/third_party/boringssl/ssl/ssl_cert.cc +313 -210
  470. data/third_party/boringssl/ssl/ssl_cipher.cc +159 -221
  471. data/third_party/boringssl/ssl/ssl_file.cc +2 -0
  472. data/third_party/boringssl/ssl/ssl_key_share.cc +164 -19
  473. data/third_party/boringssl/ssl/ssl_lib.cc +847 -555
  474. data/third_party/boringssl/ssl/ssl_privkey.cc +441 -111
  475. data/third_party/boringssl/ssl/ssl_session.cc +230 -178
  476. data/third_party/boringssl/ssl/ssl_transcript.cc +21 -142
  477. data/third_party/boringssl/ssl/ssl_versions.cc +88 -93
  478. data/third_party/boringssl/ssl/ssl_x509.cc +279 -218
  479. data/third_party/boringssl/ssl/t1_enc.cc +5 -96
  480. data/third_party/boringssl/ssl/t1_lib.cc +931 -678
  481. data/third_party/boringssl/ssl/tls13_both.cc +251 -121
  482. data/third_party/boringssl/ssl/tls13_client.cc +129 -73
  483. data/third_party/boringssl/ssl/tls13_enc.cc +350 -282
  484. data/third_party/boringssl/ssl/tls13_server.cc +259 -192
  485. data/third_party/boringssl/ssl/tls_method.cc +26 -21
  486. data/third_party/boringssl/ssl/tls_record.cc +42 -47
  487. data/third_party/boringssl/third_party/fiat/curve25519.c +261 -1324
  488. data/third_party/boringssl/third_party/fiat/curve25519_32.h +911 -0
  489. data/third_party/boringssl/third_party/fiat/curve25519_64.h +559 -0
  490. data/third_party/boringssl/third_party/fiat/p256.c +238 -999
  491. data/third_party/boringssl/third_party/fiat/p256_32.h +3226 -0
  492. data/third_party/boringssl/third_party/fiat/p256_64.h +1217 -0
  493. data/third_party/upb/upb/port_def.inc +1 -1
  494. data/third_party/upb/upb/table.c +2 -1
  495. metadata +71 -43
  496. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +0 -127
  497. data/src/core/lib/gpr/mpscq.cc +0 -117
  498. data/src/core/lib/gpr/mpscq.h +0 -88
  499. data/src/core/lib/gprpp/abstract.h +0 -47
  500. data/src/core/lib/gprpp/pair.h +0 -38
  501. data/third_party/boringssl/crypto/cipher_extra/e_ssl3.c +0 -460
  502. data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +0 -256
  503. data/third_party/boringssl/include/openssl/lhash_macros.h +0 -174
  504. data/third_party/boringssl/ssl/custom_extensions.cc +0 -265
@@ -25,7 +25,6 @@
25
25
 
26
26
  #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
27
27
  #include "src/core/lib/gpr/useful.h"
28
- #include "src/core/lib/gprpp/abstract.h"
29
28
  #include "src/core/lib/gprpp/manual_constructor.h"
30
29
  #include "src/core/lib/transport/bdp_estimator.h"
31
30
  #include "src/core/lib/transport/pid_controller.h"
@@ -153,7 +152,7 @@ class TransportFlowControlBase {
153
152
  virtual bool flow_control_enabled() const { abort(); }
154
153
 
155
154
  // Called to check if the transport needs to send a WINDOW_UPDATE frame
156
- virtual uint32_t MaybeSendUpdate(bool writing_anyway) { abort(); }
155
+ virtual uint32_t MaybeSendUpdate(bool /* writing_anyway */) { abort(); }
157
156
 
158
157
  // Using the protected members, returns and Action to be taken by the
159
158
  // tranport.
@@ -166,14 +165,14 @@ class TransportFlowControlBase {
166
165
 
167
166
  // Called to do bookkeeping when a stream owned by this transport sends
168
167
  // data on the wire
169
- virtual void StreamSentData(int64_t size) { abort(); }
168
+ virtual void StreamSentData(int64_t /* size */) { abort(); }
170
169
 
171
170
  // Called to do bookkeeping when a stream owned by this transport receives
172
171
  // data from the wire. Also does error checking for frame size.
173
- virtual grpc_error* RecvData(int64_t incoming_frame_size) { abort(); }
172
+ virtual grpc_error* RecvData(int64_t /* incoming_frame_size */) { abort(); }
174
173
 
175
174
  // Called to do bookkeeping when we receive a WINDOW_UPDATE frame.
176
- virtual void RecvUpdate(uint32_t size) { abort(); }
175
+ virtual void RecvUpdate(uint32_t /* size */) { abort(); }
177
176
 
178
177
  // Returns the BdpEstimator held by this object. Caller is responsible for
179
178
  // checking for nullptr. TODO(ncteisen): consider fully encapsulating all
@@ -189,8 +188,6 @@ class TransportFlowControlBase {
189
188
  // factor
190
189
  virtual void TestOnlyForceHugeWindow() {}
191
190
 
192
- GRPC_ABSTRACT_BASE_CLASS
193
-
194
191
  protected:
195
192
  friend class ::grpc::testing::TrickledCHTTP2;
196
193
  int64_t remote_window_ = kDefaultWindow;
@@ -210,14 +207,14 @@ class TransportFlowControlDisabled final : public TransportFlowControlBase {
210
207
  bool flow_control_enabled() const override { return false; }
211
208
 
212
209
  // Never do anything.
213
- uint32_t MaybeSendUpdate(bool writing_anyway) override { return 0; }
210
+ uint32_t MaybeSendUpdate(bool /* writing_anyway */) override { return 0; }
214
211
  FlowControlAction MakeAction() override { return FlowControlAction(); }
215
212
  FlowControlAction PeriodicUpdate() override { return FlowControlAction(); }
216
- void StreamSentData(int64_t size) override {}
217
- grpc_error* RecvData(int64_t incoming_frame_size) override {
213
+ void StreamSentData(int64_t /* size */) override {}
214
+ grpc_error* RecvData(int64_t /* incoming_frame_size */) override {
218
215
  return GRPC_ERROR_NONE;
219
216
  }
220
- void RecvUpdate(uint32_t size) override {}
217
+ void RecvUpdate(uint32_t /* size */) override {}
221
218
  };
222
219
 
223
220
  // Implementation of flow control that abides to HTTP/2 spec and attempts
@@ -350,29 +347,31 @@ class StreamFlowControlBase {
350
347
  virtual ~StreamFlowControlBase() {}
351
348
 
352
349
  // Updates an action using the protected members.
353
- virtual FlowControlAction UpdateAction(FlowControlAction action) { abort(); }
350
+ virtual FlowControlAction UpdateAction(FlowControlAction /* action */) {
351
+ abort();
352
+ }
354
353
 
355
354
  // Using the protected members, returns an Action for this stream to be
356
355
  // taken by the tranport.
357
356
  virtual FlowControlAction MakeAction() { abort(); }
358
357
 
359
358
  // Bookkeeping for when data is sent on this stream.
360
- virtual void SentData(int64_t outgoing_frame_size) { abort(); }
359
+ virtual void SentData(int64_t /* outgoing_frame_size */) { abort(); }
361
360
 
362
361
  // Bookkeeping and error checking for when data is received by this stream.
363
- virtual grpc_error* RecvData(int64_t incoming_frame_size) { abort(); }
362
+ virtual grpc_error* RecvData(int64_t /* incoming_frame_size */) { abort(); }
364
363
 
365
364
  // Called to check if this stream needs to send a WINDOW_UPDATE frame.
366
365
  virtual uint32_t MaybeSendUpdate() { abort(); }
367
366
 
368
367
  // Bookkeeping for receiving a WINDOW_UPDATE from for this stream.
369
- virtual void RecvUpdate(uint32_t size) { abort(); }
368
+ virtual void RecvUpdate(uint32_t /* size */) { abort(); }
370
369
 
371
370
  // Bookkeeping for when a call pulls bytes out of the transport. At this
372
371
  // point we consider the data 'used' and can thus let out peer know we are
373
372
  // ready for more data.
374
- virtual void IncomingByteStreamUpdate(size_t max_size_hint,
375
- size_t have_already) {
373
+ virtual void IncomingByteStreamUpdate(size_t /* max_size_hint */,
374
+ size_t /* have_already */) {
376
375
  abort();
377
376
  }
378
377
 
@@ -385,8 +384,6 @@ class StreamFlowControlBase {
385
384
  int64_t local_window_delta() { return local_window_delta_; }
386
385
  int64_t announced_window_delta() { return announced_window_delta_; }
387
386
 
388
- GRPC_ABSTRACT_BASE_CLASS
389
-
390
387
  protected:
391
388
  friend class ::grpc::testing::TrickledCHTTP2;
392
389
  int64_t remote_window_delta_ = 0;
@@ -404,14 +401,14 @@ class StreamFlowControlDisabled : public StreamFlowControlBase {
404
401
  return action;
405
402
  }
406
403
  FlowControlAction MakeAction() override { return FlowControlAction(); }
407
- void SentData(int64_t outgoing_frame_size) override {}
408
- grpc_error* RecvData(int64_t incoming_frame_size) override {
404
+ void SentData(int64_t /* outgoing_frame_size */) override {}
405
+ grpc_error* RecvData(int64_t /* incoming_frame_size */) override {
409
406
  return GRPC_ERROR_NONE;
410
407
  }
411
408
  uint32_t MaybeSendUpdate() override { return 0; }
412
- void RecvUpdate(uint32_t size) override {}
413
- void IncomingByteStreamUpdate(size_t max_size_hint,
414
- size_t have_already) override {}
409
+ void RecvUpdate(uint32_t /* size */) override {}
410
+ void IncomingByteStreamUpdate(size_t /* max_size_hint */,
411
+ size_t /* have_already */) override {}
415
412
  };
416
413
 
417
414
  // Implementation of flow control that abides to HTTP/2 spec and attempts
@@ -42,6 +42,20 @@
42
42
  #include "src/core/lib/transport/static_metadata.h"
43
43
  #include "src/core/lib/transport/timeout_encoding.h"
44
44
 
45
+ namespace {
46
+ /* (Maybe-cuckoo) hpack encoder hash table implementation.
47
+
48
+ This hashtable implementation is a subset of a proper cuckoo hash; while we
49
+ have fallback cells that a value can be hashed to if the first cell is full,
50
+ we do not attempt to iteratively rearrange entries into backup cells to get
51
+ things to fit. Instead, if both a cell and the backup cell for a value are
52
+ occupied, the older existing entry is evicted.
53
+
54
+ Note that we can disable backup-cell picking by setting
55
+ GRPC_HPACK_ENCODER_USE_CUCKOO_HASH to 0. In that case, we simply evict an
56
+ existing entry rather than try to use a backup. Hence, "maybe-cuckoo."
57
+ TODO(arjunroy): Add unit tests for hashtable implementation. */
58
+ #define GRPC_HPACK_ENCODER_USE_CUCKOO_HASH 1
45
59
  #define HASH_FRAGMENT_MASK (GRPC_CHTTP2_HPACKC_NUM_VALUES - 1)
46
60
  #define HASH_FRAGMENT_1(x) ((x)&HASH_FRAGMENT_MASK)
47
61
  #define HASH_FRAGMENT_2(x) \
@@ -51,21 +65,200 @@
51
65
  #define HASH_FRAGMENT_4(x) \
52
66
  (((x) >> (GRPC_CHTTP2_HPACKC_NUM_VALUES_BITS * 3)) & HASH_FRAGMENT_MASK)
53
67
 
68
+ /* don't consider adding anything bigger than this to the hpack table */
69
+ constexpr size_t kMaxDecoderSpaceUsage = 512;
70
+ constexpr size_t kDataFrameHeaderSize = 9;
71
+ constexpr uint8_t kMaxFilterValue = 255;
72
+
54
73
  /* if the probability of this item being seen again is < 1/x then don't add
55
74
  it to the table */
56
75
  #define ONE_ON_ADD_PROBABILITY (GRPC_CHTTP2_HPACKC_NUM_VALUES >> 1)
57
- /* don't consider adding anything bigger than this to the hpack table */
58
- #define MAX_DECODER_SPACE_USAGE 512
59
-
60
- #define DATA_FRAME_HEADER_SIZE 9
76
+ /* The hpack index we encode over the wire. Meaningful to the hpack encoder and
77
+ parser on the remote end as well as HTTP2. *Not* the same as
78
+ HpackEncoderSlotHash, which is only meaningful to the hpack encoder
79
+ implementation (HpackEncoderSlotHash is used for the hashtable implementation
80
+ when mapping from metadata to HpackEncoderIndex. */
81
+ typedef uint32_t HpackEncoderIndex;
82
+ /* Internal-table bookkeeping (*not* the hpack index). */
83
+ typedef uint32_t HpackEncoderSlotHash;
84
+
85
+ struct SliceRefComparator {
86
+ typedef grpc_slice_refcount* Type;
87
+ static grpc_slice_refcount* Null() { return nullptr; }
88
+ static bool IsNull(const grpc_slice_refcount* sref) {
89
+ return sref == nullptr;
90
+ }
91
+ static bool Equals(const grpc_slice_refcount* s1,
92
+ const grpc_slice_refcount* s2) {
93
+ return s1 == s2;
94
+ }
95
+ static void Ref(grpc_slice_refcount* sref) {
96
+ GPR_DEBUG_ASSERT(sref != nullptr);
97
+ sref->Ref();
98
+ }
99
+ static void Unref(grpc_slice_refcount* sref) {
100
+ GPR_DEBUG_ASSERT(sref != nullptr);
101
+ sref->Unref();
102
+ }
103
+ };
61
104
 
62
- static grpc_slice_refcount terminal_slice_refcount(
63
- grpc_slice_refcount::Type::STATIC);
64
- static const grpc_slice terminal_slice = {
65
- &terminal_slice_refcount, /* refcount */
66
- {{0, nullptr}} /* data.refcounted */
105
+ struct MetadataComparator {
106
+ typedef grpc_mdelem Type;
107
+ static const grpc_mdelem Null() { return {0}; }
108
+ static bool IsNull(const grpc_mdelem md) { return md.payload == 0; }
109
+ static bool Equals(const grpc_mdelem md1, const grpc_mdelem md2) {
110
+ return md1.payload == md2.payload;
111
+ }
112
+ static void Ref(grpc_mdelem md) {
113
+ GPR_DEBUG_ASSERT(md.payload != 0);
114
+ GRPC_MDELEM_REF(md);
115
+ }
116
+ static void Unref(grpc_mdelem md) {
117
+ GPR_DEBUG_ASSERT(md.payload != 0);
118
+ GRPC_MDELEM_UNREF(md);
119
+ }
67
120
  };
68
121
 
122
+ /* Index table management */
123
+ template <typename Hashtable>
124
+ static HpackEncoderIndex HpackIndex(const Hashtable* hashtable,
125
+ HpackEncoderSlotHash hash_index) {
126
+ return hashtable[hash_index].index;
127
+ }
128
+
129
+ template <typename ValueType, typename Hashtable>
130
+ static const ValueType& GetEntry(const Hashtable* hashtable,
131
+ HpackEncoderSlotHash hash_index) {
132
+ return hashtable[hash_index].value;
133
+ }
134
+
135
+ template <typename Cmp, typename Hashtable>
136
+ static bool TableEmptyAt(const Hashtable* hashtable,
137
+ HpackEncoderSlotHash hash_index) {
138
+ return Cmp::Equals(hashtable[hash_index].value, Cmp::Null());
139
+ }
140
+
141
+ template <typename Cmp, typename Hashtable, typename ValueType>
142
+ static bool Matches(const Hashtable* hashtable, const ValueType& value,
143
+ HpackEncoderSlotHash hash_index) {
144
+ return Cmp::Equals(value, hashtable[hash_index].value);
145
+ }
146
+
147
+ template <typename Hashtable>
148
+ static void UpdateIndex(Hashtable* hashtable, HpackEncoderSlotHash hash_index,
149
+ HpackEncoderIndex hpack_index) {
150
+ hashtable[hash_index].index = hpack_index;
151
+ }
152
+
153
+ template <typename Hashtable, typename ValueType>
154
+ static void SetIndex(Hashtable* hashtable, HpackEncoderSlotHash hash_index,
155
+ const ValueType& value, HpackEncoderIndex hpack_index) {
156
+ hashtable[hash_index].value = value;
157
+ UpdateIndex(hashtable, hash_index, hpack_index);
158
+ }
159
+
160
+ template <typename Cmp, typename Hashtable, typename ValueType>
161
+ static bool GetMatchingIndex(Hashtable* hashtable, const ValueType& value,
162
+ uint32_t value_hash, HpackEncoderIndex* index) {
163
+ const HpackEncoderSlotHash cuckoo_first = HASH_FRAGMENT_2(value_hash);
164
+ if (Matches<Cmp>(hashtable, value, cuckoo_first)) {
165
+ *index = HpackIndex(hashtable, cuckoo_first);
166
+ return true;
167
+ }
168
+ #if GRPC_HPACK_ENCODER_USE_CUCKOO_HASH
169
+ const HpackEncoderSlotHash cuckoo_second = HASH_FRAGMENT_3(value_hash);
170
+
171
+ if (Matches<Cmp>(hashtable, value, cuckoo_second)) {
172
+ *index = HpackIndex(hashtable, cuckoo_second);
173
+ return true;
174
+ }
175
+ #endif
176
+ return false;
177
+ }
178
+
179
+ template <typename Cmp, typename Hashtable, typename ValueType>
180
+ static ValueType ReplaceOlderIndex(Hashtable* hashtable, const ValueType& value,
181
+ HpackEncoderSlotHash hash_index_a,
182
+ HpackEncoderSlotHash hash_index_b,
183
+ HpackEncoderIndex new_index) {
184
+ const HpackEncoderIndex hpack_idx_a = hashtable[hash_index_a].index;
185
+ const HpackEncoderIndex hpack_idx_b = hashtable[hash_index_b].index;
186
+ const HpackEncoderSlotHash id =
187
+ hpack_idx_a < hpack_idx_b ? hash_index_a : hash_index_b;
188
+ ValueType old = GetEntry<typename Cmp::Type>(hashtable, id);
189
+ SetIndex(hashtable, id, value, new_index);
190
+ return old;
191
+ }
192
+
193
+ template <typename Cmp, typename Hashtable, typename ValueType>
194
+ static void UpdateAddOrEvict(Hashtable hashtable, const ValueType& value,
195
+ uint32_t value_hash, HpackEncoderIndex new_index) {
196
+ const HpackEncoderSlotHash cuckoo_first = HASH_FRAGMENT_2(value_hash);
197
+ if (Matches<Cmp>(hashtable, value, cuckoo_first)) {
198
+ UpdateIndex(hashtable, cuckoo_first, new_index);
199
+ return;
200
+ }
201
+ if (TableEmptyAt<Cmp>(hashtable, cuckoo_first)) {
202
+ Cmp::Ref(value);
203
+ SetIndex(hashtable, cuckoo_first, value, new_index);
204
+ return;
205
+ }
206
+ #if GRPC_HPACK_ENCODER_USE_CUCKOO_HASH
207
+ const HpackEncoderSlotHash cuckoo_second = HASH_FRAGMENT_3(value_hash);
208
+ if (Matches<Cmp>(hashtable, value, cuckoo_second)) {
209
+ UpdateIndex(hashtable, cuckoo_second, new_index);
210
+ return;
211
+ }
212
+ Cmp::Ref(value);
213
+ if (TableEmptyAt<Cmp>(hashtable, cuckoo_second)) {
214
+ SetIndex(hashtable, cuckoo_second, value, new_index);
215
+ return;
216
+ }
217
+ Cmp::Unref(ReplaceOlderIndex<Cmp>(hashtable, value, cuckoo_first,
218
+ cuckoo_second, new_index));
219
+ #else
220
+ ValueType old = GetEntry<typename Cmp::Type>(hashtable, cuckoo_first);
221
+ SetIndex(hashtable, cuckoo_first, value, new_index);
222
+ Cmp::Unref(old);
223
+ #endif
224
+ }
225
+
226
+ /* halve all counts because an element reached max */
227
+ static void HalveFilter(uint8_t idx, uint32_t* sum, uint8_t* elems) {
228
+ *sum = 0;
229
+ for (int i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
230
+ elems[i] /= 2;
231
+ (*sum) += elems[i];
232
+ }
233
+ }
234
+
235
+ /* increment a filter count, halve all counts if one element reaches max */
236
+ static void IncrementFilter(uint8_t idx, uint32_t* sum, uint8_t* elems) {
237
+ elems[idx]++;
238
+ if (GPR_LIKELY(elems[idx] < kMaxFilterValue)) {
239
+ (*sum)++;
240
+ } else {
241
+ HalveFilter(idx, sum, elems);
242
+ }
243
+ }
244
+
245
+ static uint32_t UpdateHashtablePopularity(
246
+ grpc_chttp2_hpack_compressor* hpack_compressor, uint32_t elem_hash) {
247
+ const uint32_t popularity_hash = HASH_FRAGMENT_1(elem_hash);
248
+ IncrementFilter(popularity_hash, &hpack_compressor->filter_elems_sum,
249
+ hpack_compressor->filter_elems);
250
+ return popularity_hash;
251
+ }
252
+
253
+ static bool CanAddToHashtable(grpc_chttp2_hpack_compressor* hpack_compressor,
254
+ uint32_t popularity_hash) {
255
+ const bool can_add =
256
+ hpack_compressor->filter_elems[popularity_hash] >=
257
+ hpack_compressor->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
258
+ return can_add;
259
+ }
260
+ } /* namespace */
261
+
69
262
  typedef struct {
70
263
  int is_first_frame;
71
264
  /* number of bytes in 'output' when we started the frame - used to calculate
@@ -73,8 +266,10 @@ typedef struct {
73
266
  size_t output_length_at_start_of_frame;
74
267
  /* index (in output) of the header for the current frame */
75
268
  size_t header_idx;
269
+ #ifndef NDEBUG
76
270
  /* have we seen a regular (non-colon-prefixed) header yet? */
77
271
  uint8_t seen_regular_header;
272
+ #endif
78
273
  /* output stream id */
79
274
  uint32_t stream_id;
80
275
  grpc_slice_buffer* output;
@@ -84,7 +279,7 @@ typedef struct {
84
279
  bool use_true_binary_metadata;
85
280
  } framer_state;
86
281
 
87
- /* fills p (which is expected to be DATA_FRAME_HEADER_SIZE bytes long)
282
+ /* fills p (which is expected to be kDataFrameHeaderSize bytes long)
88
283
  * with a data frame header */
89
284
  static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len,
90
285
  uint8_t flags) {
@@ -131,7 +326,7 @@ static void finish_frame(framer_state* st, int is_header_boundary,
131
326
  static_cast<uint8_t>(
132
327
  (is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
133
328
  (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
134
- st->stats->framing_bytes += DATA_FRAME_HEADER_SIZE;
329
+ st->stats->framing_bytes += kDataFrameHeaderSize;
135
330
  st->is_first_frame = 0;
136
331
  }
137
332
 
@@ -140,7 +335,7 @@ static void finish_frame(framer_state* st, int is_header_boundary,
140
335
  static void begin_frame(framer_state* st) {
141
336
  grpc_slice reserved;
142
337
  reserved.refcount = nullptr;
143
- reserved.data.inlined.length = DATA_FRAME_HEADER_SIZE;
338
+ reserved.data.inlined.length = kDataFrameHeaderSize;
144
339
  st->header_idx = grpc_slice_buffer_add_indexed(st->output, reserved);
145
340
  st->output_length_at_start_of_frame = st->output->length;
146
341
  }
@@ -156,21 +351,6 @@ static void ensure_space(framer_state* st, size_t need_bytes) {
156
351
  begin_frame(st);
157
352
  }
158
353
 
159
- /* increment a filter count, halve all counts if one element reaches max */
160
- static void inc_filter(uint8_t idx, uint32_t* sum, uint8_t* elems) {
161
- elems[idx]++;
162
- if (elems[idx] < 255) {
163
- (*sum)++;
164
- } else {
165
- int i;
166
- *sum = 0;
167
- for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
168
- elems[i] /= 2;
169
- (*sum) += elems[i];
170
- }
171
- }
172
- }
173
-
174
354
  static void add_header_data(framer_state* st, grpc_slice slice) {
175
355
  size_t len = GRPC_SLICE_LENGTH(slice);
176
356
  size_t remaining;
@@ -228,7 +408,6 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
228
408
  while (c->table_size + elem_size > c->max_table_size) {
229
409
  evict_entry(c);
230
410
  }
231
- // TODO(arjunroy): Are we conflating size in bytes vs. membership?
232
411
  GPR_ASSERT(c->table_elems < c->max_table_size);
233
412
  c->table_elem_size[new_index % c->cap_table_elems] =
234
413
  static_cast<uint16_t>(elem_size);
@@ -240,97 +419,37 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
240
419
 
241
420
  // Add a key to the dynamic table. Both key and value will be added to table at
242
421
  // the decoder.
243
- static void add_key_with_index(grpc_chttp2_hpack_compressor* c,
244
- grpc_mdelem elem, uint32_t new_index,
245
- uint32_t key_hash) {
246
- if (new_index == 0) {
247
- return;
248
- }
249
-
250
- /* Store the key into {entries,indices}_keys */
251
- if (grpc_slice_static_interned_equal(
252
- c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem))) {
253
- c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
254
- } else if (grpc_slice_static_interned_equal(
255
- c->entries_keys[HASH_FRAGMENT_3(key_hash)],
256
- GRPC_MDKEY(elem))) {
257
- c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
258
- } else if (c->entries_keys[HASH_FRAGMENT_2(key_hash)].refcount ==
259
- &terminal_slice_refcount) {
260
- c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
261
- grpc_slice_ref_internal(GRPC_MDKEY(elem));
262
- c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
263
- } else if (c->entries_keys[HASH_FRAGMENT_3(key_hash)].refcount ==
264
- &terminal_slice_refcount) {
265
- c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
266
- grpc_slice_ref_internal(GRPC_MDKEY(elem));
267
- c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
268
- } else if (c->indices_keys[HASH_FRAGMENT_2(key_hash)] <
269
- c->indices_keys[HASH_FRAGMENT_3(key_hash)]) {
270
- grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
271
- c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
272
- grpc_slice_ref_internal(GRPC_MDKEY(elem));
273
- c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
274
- } else {
275
- grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
276
- c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
277
- grpc_slice_ref_internal(GRPC_MDKEY(elem));
278
- c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
279
- }
422
+ static void AddKeyWithIndex(grpc_chttp2_hpack_compressor* c,
423
+ grpc_slice_refcount* key_ref, uint32_t new_index,
424
+ uint32_t key_hash) {
425
+ UpdateAddOrEvict<SliceRefComparator>(c->key_table.entries, key_ref, key_hash,
426
+ new_index);
280
427
  }
281
428
 
282
429
  /* add an element to the decoder table */
283
- static void add_elem_with_index(grpc_chttp2_hpack_compressor* c,
284
- grpc_mdelem elem, uint32_t new_index,
285
- uint32_t elem_hash, uint32_t key_hash) {
286
- if (new_index == 0) {
287
- return;
288
- }
430
+ static void AddElemWithIndex(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
431
+ uint32_t new_index, uint32_t elem_hash,
432
+ uint32_t key_hash) {
289
433
  GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
290
-
291
- /* Store this element into {entries,indices}_elem */
292
- if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)],
293
- elem)) {
294
- /* already there: update with new index */
295
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
296
- } else if (grpc_mdelem_both_interned_eq(
297
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem)) {
298
- /* already there (cuckoo): update with new index */
299
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
300
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
301
- /* not there, but a free element: add */
302
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
303
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
304
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
305
- /* not there (cuckoo), but a free element: add */
306
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
307
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
308
- } else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
309
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
310
- /* not there: replace oldest */
311
- GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
312
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
313
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
314
- } else {
315
- /* not there: replace oldest */
316
- GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
317
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
318
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
319
- }
320
-
321
- add_key_with_index(c, elem, new_index, key_hash);
434
+ UpdateAddOrEvict<MetadataComparator>(c->elem_table.entries, elem, elem_hash,
435
+ new_index);
436
+ AddKeyWithIndex(c, GRPC_MDKEY(elem).refcount, new_index, key_hash);
322
437
  }
323
438
 
324
439
  static void add_elem(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
325
440
  size_t elem_size, uint32_t elem_hash, uint32_t key_hash) {
326
441
  uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
327
- add_elem_with_index(c, elem, new_index, elem_hash, key_hash);
442
+ if (new_index != 0) {
443
+ AddElemWithIndex(c, elem, new_index, elem_hash, key_hash);
444
+ }
328
445
  }
329
446
 
330
447
  static void add_key(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
331
448
  size_t elem_size, uint32_t key_hash) {
332
449
  uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
333
- add_key_with_index(c, elem, new_index, key_hash);
450
+ if (new_index != 0) {
451
+ AddKeyWithIndex(c, GRPC_MDKEY(elem).refcount, new_index, key_hash);
452
+ }
334
453
  }
335
454
 
336
455
  static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index,
@@ -516,30 +635,19 @@ static EmitIndexedStatus maybe_emit_indexed(grpc_chttp2_hpack_compressor* c,
516
635
  ->hash()
517
636
  : reinterpret_cast<grpc_core::StaticMetadata*>(GRPC_MDELEM_DATA(elem))
518
637
  ->hash();
519
-
520
- inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems);
521
-
638
+ /* Update filter to see if we can perhaps add this elem. */
639
+ const uint32_t popularity_hash = UpdateHashtablePopularity(c, elem_hash);
522
640
  /* is this elem currently in the decoders table? */
523
- if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)],
524
- elem) &&
525
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
526
- /* HIT: complete element (first cuckoo hash) */
527
- emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]),
528
- st);
529
- return EmitIndexedStatus(elem_hash, true, false);
530
- }
531
- if (grpc_mdelem_both_interned_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
532
- elem) &&
533
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
534
- /* HIT: complete element (second cuckoo hash) */
535
- emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]),
536
- st);
641
+ HpackEncoderIndex indices_key;
642
+ if (GetMatchingIndex<MetadataComparator>(c->elem_table.entries, elem,
643
+ elem_hash, &indices_key) &&
644
+ indices_key > c->tail_remote_index) {
645
+ emit_indexed(c, dynidx(c, indices_key), st);
537
646
  return EmitIndexedStatus(elem_hash, true, false);
538
647
  }
539
-
540
- const bool can_add = c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
541
- c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
542
- return EmitIndexedStatus(elem_hash, false, can_add);
648
+ /* Didn't hit either cuckoo index, so no emit. */
649
+ return EmitIndexedStatus(elem_hash, false,
650
+ CanAddToHashtable(c, popularity_hash));
543
651
  }
544
652
 
545
653
  static void emit_maybe_add(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
@@ -557,14 +665,15 @@ static void emit_maybe_add(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
557
665
  /* encode an mdelem */
558
666
  static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
559
667
  framer_state* st) {
668
+ const grpc_slice& elem_key = GRPC_MDKEY(elem);
560
669
  /* User-provided key len validated in grpc_validate_header_key_is_legal(). */
561
- GPR_DEBUG_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0);
670
+ GPR_DEBUG_ASSERT(GRPC_SLICE_LENGTH(elem_key) > 0);
562
671
  /* Header ordering: all reserved headers (prefixed with ':') must precede
563
672
  * regular headers. This can be a debug assert, since:
564
673
  * 1) User cannot give us ':' headers (grpc_validate_header_key_is_legal()).
565
674
  * 2) grpc filters/core should be checked during debug builds. */
566
675
  #ifndef NDEBUG
567
- if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */
676
+ if (GRPC_SLICE_START_PTR(elem_key)[0] != ':') { /* regular header */
568
677
  st->seen_regular_header = 1;
569
678
  } else {
570
679
  GPR_DEBUG_ASSERT(
@@ -575,11 +684,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
575
684
  if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
576
685
  hpack_enc_log(elem);
577
686
  }
578
-
579
687
  const bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem);
580
- const bool key_interned =
581
- elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem));
582
-
688
+ const bool key_interned = elem_interned || grpc_slice_is_interned(elem_key);
583
689
  /* Key is not interned, emit literals. */
584
690
  if (!key_interned) {
585
691
  emit_lithdr_v<EmitLitHdrVType::NO_IDX_V>(c, elem, st);
@@ -591,38 +697,24 @@ static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
591
697
  if (ret.emitted) {
592
698
  return;
593
699
  }
594
-
595
700
  /* should this elem be in the table? */
596
701
  const size_t decoder_space_usage =
597
702
  grpc_chttp2_get_size_in_hpack_table(elem, st->use_true_binary_metadata);
598
703
  const bool decoder_space_available =
599
- decoder_space_usage < MAX_DECODER_SPACE_USAGE;
704
+ decoder_space_usage < kMaxDecoderSpaceUsage;
600
705
  const bool should_add_elem =
601
706
  elem_interned && decoder_space_available && ret.can_add;
602
707
  const uint32_t elem_hash = ret.elem_hash;
603
-
604
708
  /* no hits for the elem... maybe there's a key? */
605
- const uint32_t key_hash = GRPC_MDKEY(elem).refcount->Hash(GRPC_MDKEY(elem));
606
- uint32_t indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)];
607
- if (grpc_slice_static_interned_equal(
608
- c->entries_keys[HASH_FRAGMENT_2(key_hash)], GRPC_MDKEY(elem)) &&
709
+ const uint32_t key_hash = elem_key.refcount->Hash(elem_key);
710
+ HpackEncoderIndex indices_key;
711
+ if (GetMatchingIndex<SliceRefComparator>(
712
+ c->key_table.entries, elem_key.refcount, key_hash, &indices_key) &&
609
713
  indices_key > c->tail_remote_index) {
610
- /* HIT: key (first cuckoo hash) */
611
714
  emit_maybe_add(c, elem, st, indices_key, should_add_elem,
612
715
  decoder_space_usage, elem_hash, key_hash);
613
716
  return;
614
717
  }
615
-
616
- indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)];
617
- if (grpc_slice_static_interned_equal(
618
- c->entries_keys[HASH_FRAGMENT_3(key_hash)], GRPC_MDKEY(elem)) &&
619
- indices_key > c->tail_remote_index) {
620
- /* HIT: key (second cuckoo hash) */
621
- emit_maybe_add(c, elem, st, indices_key, should_add_elem,
622
- decoder_space_usage, elem_hash, key_hash);
623
- return;
624
- }
625
-
626
718
  /* no elem, key in the table... fall back to literal emission */
627
719
  const bool should_add_key = !elem_interned && decoder_space_available;
628
720
  if (should_add_elem || should_add_key) {
@@ -660,22 +752,18 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c) {
660
752
  c->cap_table_elems = elems_for_bytes(c->max_table_size);
661
753
  c->max_table_elems = c->cap_table_elems;
662
754
  c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
663
- c->table_elem_size = static_cast<uint16_t*>(
664
- gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems));
665
- memset(c->table_elem_size, 0,
666
- sizeof(*c->table_elem_size) * c->cap_table_elems);
667
- for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
668
- c->entries_keys[i] = terminal_slice;
669
- }
755
+ const size_t alloc_size = sizeof(*c->table_elem_size) * c->cap_table_elems;
756
+ c->table_elem_size = static_cast<uint16_t*>(gpr_malloc(alloc_size));
757
+ memset(c->table_elem_size, 0, alloc_size);
670
758
  }
671
759
 
672
760
  void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c) {
673
- int i;
674
- for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
675
- if (c->entries_keys[i].refcount != &terminal_slice_refcount) {
676
- grpc_slice_unref_internal(c->entries_keys[i]);
761
+ for (int i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
762
+ auto* const key = GetEntry<grpc_slice_refcount*>(c->key_table.entries, i);
763
+ if (key != nullptr) {
764
+ key->Unref();
677
765
  }
678
- GRPC_MDELEM_UNREF(c->entries_elems[i]);
766
+ GRPC_MDELEM_UNREF(GetEntry<grpc_mdelem>(c->elem_table.entries, i));
679
767
  }
680
768
  gpr_free(c->table_elem_size);
681
769
  }
@@ -744,7 +832,9 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c,
744
832
  validates that stream_id is not 0. So, this can be a debug assert. */
745
833
  GPR_DEBUG_ASSERT(options->stream_id != 0);
746
834
  framer_state st;
835
+ #ifndef NDEBUG
747
836
  st.seen_regular_header = 0;
837
+ #endif
748
838
  st.stream_id = options->stream_id;
749
839
  st.output = outbuf;
750
840
  st.is_first_frame = 1;