grpc 1.24.0 → 1.25.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.
- checksums.yaml +4 -4
- data/Makefile +306 -243
- data/etc/roots.pem +0 -100
- data/include/grpc/grpc_security.h +44 -18
- data/include/grpc/impl/codegen/grpc_types.h +15 -0
- data/include/grpc/impl/codegen/port_platform.h +27 -11
- data/include/grpc/impl/codegen/sync_generic.h +1 -1
- data/src/boringssl/err_data.c +695 -650
- data/src/core/ext/filters/client_channel/client_channel.cc +257 -179
- data/src/core/ext/filters/client_channel/client_channel.h +24 -0
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
- data/src/core/ext/filters/client_channel/client_channel_factory.h +1 -5
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +18 -45
- data/src/core/ext/filters/client_channel/health/health_check_client.h +5 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +65 -55
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -14
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +113 -36
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -19
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +36 -13
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +3 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +814 -1589
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +2 -5
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +3 -6
- data/src/core/ext/filters/client_channel/resolver.cc +1 -2
- data/src/core/ext/filters/client_channel/resolver.h +8 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +25 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +46 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +10 -17
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +7 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +111 -44
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +22 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +29 -10
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +27 -36
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +7 -10
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +60 -16
- data/src/core/ext/filters/client_channel/resolver_factory.h +4 -8
- data/src/core/ext/filters/client_channel/resolver_registry.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_registry.h +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -10
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +7 -8
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -1
- data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -5
- data/src/core/ext/filters/client_channel/retry_throttle.h +1 -4
- data/src/core/ext/filters/client_channel/service_config.h +8 -8
- data/src/core/ext/filters/client_channel/subchannel.cc +53 -86
- data/src/core/ext/filters/client_channel/subchannel.h +7 -9
- data/src/core/ext/filters/client_channel/subchannel_interface.h +9 -13
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +3 -6
- data/src/core/ext/filters/client_channel/{lb_policy/xds/xds_load_balancer_api.cc → xds/xds_api.cc} +169 -52
- data/src/core/ext/filters/client_channel/xds/xds_api.h +171 -0
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +450 -0
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +99 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel.h +8 -6
- data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel_secure.cc +28 -11
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +1413 -0
- data/src/core/ext/filters/client_channel/xds/xds_client.h +221 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.cc +1 -5
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.h +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.cc +20 -20
- data/src/core/ext/filters/http/client/http_client_filter.cc +15 -15
- data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +12 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +59 -50
- data/src/core/ext/filters/message_size/message_size_filter.cc +18 -18
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -14
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +233 -175
- data/src/core/ext/transport/chttp2/transport/flow_control.h +21 -24
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +253 -163
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +24 -12
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +13 -15
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -13
- data/src/core/lib/channel/channel_args.cc +16 -0
- data/src/core/lib/channel/channel_args.h +22 -0
- data/src/core/lib/channel/channelz.cc +5 -6
- data/src/core/lib/channel/channelz.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +20 -20
- data/src/core/lib/channel/handshaker.h +3 -4
- data/src/core/lib/channel/handshaker_factory.h +1 -3
- data/src/core/lib/debug/trace.h +3 -2
- data/src/core/lib/gprpp/arena.cc +3 -3
- data/src/core/lib/gprpp/arena.h +2 -3
- data/src/core/lib/gprpp/inlined_vector.h +9 -0
- data/src/core/lib/gprpp/map.h +3 -501
- data/src/core/lib/gprpp/memory.h +45 -41
- data/src/core/lib/gprpp/mpscq.cc +108 -0
- data/src/core/lib/gprpp/mpscq.h +98 -0
- data/src/core/lib/gprpp/orphanable.h +6 -11
- data/src/core/lib/gprpp/ref_counted.h +25 -19
- data/src/core/lib/gprpp/set.h +33 -0
- data/src/core/lib/gprpp/thd.h +2 -4
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +15 -11
- data/src/core/lib/http/parser.cc +1 -1
- data/src/core/lib/iomgr/buffer_list.cc +4 -5
- data/src/core/lib/iomgr/buffer_list.h +5 -6
- data/src/core/lib/iomgr/call_combiner.cc +4 -5
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/cfstream_handle.h +3 -5
- data/src/core/lib/iomgr/closure.h +8 -3
- data/src/core/lib/iomgr/combiner.cc +45 -82
- data/src/core/lib/iomgr/combiner.h +32 -8
- data/src/core/lib/iomgr/endpoint_cfstream.cc +5 -3
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -15
- data/src/core/lib/iomgr/ev_poll_posix.cc +3 -1
- data/src/core/lib/iomgr/exec_ctx.h +4 -3
- data/src/core/lib/iomgr/executor.cc +4 -2
- data/src/core/lib/iomgr/executor.h +3 -0
- data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -6
- data/src/core/lib/iomgr/executor/threadpool.cc +1 -2
- data/src/core/lib/iomgr/executor/threadpool.h +7 -11
- data/src/core/lib/iomgr/resource_quota.cc +55 -51
- data/src/core/lib/iomgr/resource_quota.h +13 -9
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +13 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -11
- data/src/core/lib/iomgr/tcp_custom.cc +9 -7
- data/src/core/lib/iomgr/tcp_posix.cc +20 -16
- data/src/core/lib/iomgr/tcp_server.h +1 -4
- data/src/core/lib/iomgr/tcp_server_custom.cc +5 -5
- data/src/core/lib/iomgr/tcp_server_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -11
- data/src/core/lib/iomgr/timer_custom.cc +2 -2
- data/src/core/lib/iomgr/udp_server.cc +3 -2
- data/src/core/lib/iomgr/udp_server.h +6 -12
- data/src/core/lib/json/json.h +1 -1
- data/src/core/lib/json/json_string.cc +2 -2
- data/src/core/lib/profiling/basic_timers.cc +2 -2
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -2
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +1 -1
- data/src/core/lib/security/credentials/credentials.h +4 -20
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +4 -4
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +64 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +4 -4
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +9 -7
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -0
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -4
- data/src/core/lib/security/security_connector/security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/security_connector.h +19 -17
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +8 -5
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
- data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -6
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +17 -17
- data/src/core/lib/security/transport/security_handshaker.cc +29 -13
- data/src/core/lib/security/transport/security_handshaker.h +4 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +14 -14
- data/src/core/lib/slice/slice.cc +2 -10
- data/src/core/lib/slice/slice_hash_table.h +4 -6
- data/src/core/lib/slice/slice_intern.cc +42 -39
- data/src/core/lib/slice/slice_internal.h +3 -3
- data/src/core/lib/slice/slice_utils.h +21 -4
- data/src/core/lib/slice/slice_weak_hash_table.h +4 -6
- data/src/core/lib/surface/call.cc +3 -3
- data/src/core/lib/surface/channel.cc +7 -0
- data/src/core/lib/surface/completion_queue.cc +12 -11
- data/src/core/lib/surface/completion_queue.h +4 -2
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/lame_client.cc +33 -18
- data/src/core/lib/surface/server.cc +77 -76
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/byte_stream.h +3 -7
- data/src/core/lib/transport/connectivity_state.cc +112 -98
- data/src/core/lib/transport/connectivity_state.h +100 -50
- data/src/core/lib/transport/static_metadata.cc +276 -288
- data/src/core/lib/transport/static_metadata.h +73 -76
- data/src/core/lib/transport/status_conversion.cc +1 -1
- data/src/core/lib/transport/status_metadata.cc +1 -1
- data/src/core/lib/transport/transport.cc +2 -2
- data/src/core/lib/transport/transport.h +12 -4
- data/src/core/lib/transport/transport_op_string.cc +14 -11
- data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +5 -5
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -2
- data/src/core/tsi/fake_transport_security.cc +7 -5
- data/src/core/tsi/grpc_shadow_boringssl.h +2918 -2627
- data/src/core/tsi/local_transport_security.cc +8 -6
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +7 -5
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -6
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -2
- data/src/core/tsi/ssl_transport_security.cc +12 -12
- data/src/core/tsi/ssl_transport_security.h +2 -2
- data/src/core/tsi/transport_security_grpc.cc +7 -0
- data/src/core/tsi/transport_security_grpc.h +6 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -1
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +2 -2
- data/third_party/boringssl/crypto/asn1/a_bool.c +18 -5
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +17 -221
- data/third_party/boringssl/crypto/asn1/a_dup.c +0 -24
- data/third_party/boringssl/crypto/asn1/a_enum.c +2 -2
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +10 -72
- data/third_party/boringssl/crypto/asn1/a_int.c +12 -71
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +110 -216
- data/third_party/boringssl/crypto/asn1/a_object.c +16 -5
- data/third_party/boringssl/crypto/asn1/a_strnid.c +1 -0
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -1
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +3 -1
- data/third_party/boringssl/crypto/base64/base64.c +2 -2
- data/third_party/boringssl/crypto/bio/bio.c +73 -9
- data/third_party/boringssl/crypto/bio/connect.c +4 -0
- data/third_party/boringssl/crypto/bio/fd.c +4 -0
- data/third_party/boringssl/crypto/bio/file.c +5 -2
- data/third_party/boringssl/crypto/bio/socket.c +4 -0
- data/third_party/boringssl/crypto/bio/socket_helper.c +4 -0
- data/third_party/boringssl/crypto/bn_extra/convert.c +11 -7
- data/third_party/boringssl/crypto/bytestring/ber.c +8 -4
- data/third_party/boringssl/crypto/bytestring/cbb.c +19 -7
- data/third_party/boringssl/crypto/bytestring/cbs.c +28 -15
- data/third_party/boringssl/crypto/bytestring/internal.h +28 -7
- data/third_party/boringssl/crypto/bytestring/unicode.c +155 -0
- data/third_party/boringssl/crypto/chacha/chacha.c +36 -19
- data/third_party/boringssl/crypto/chacha/internal.h +45 -0
- data/third_party/boringssl/crypto/cipher_extra/cipher_extra.c +29 -0
- data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +269 -25
- data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +16 -14
- data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +54 -38
- data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +133 -41
- data/third_party/boringssl/crypto/cipher_extra/e_tls.c +23 -15
- data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +24 -15
- data/third_party/boringssl/crypto/cmac/cmac.c +62 -25
- data/third_party/boringssl/crypto/conf/conf.c +7 -0
- data/third_party/boringssl/crypto/cpu-arm-linux.c +4 -148
- data/third_party/boringssl/crypto/cpu-arm-linux.h +201 -0
- data/third_party/boringssl/crypto/cpu-intel.c +45 -51
- data/third_party/boringssl/crypto/crypto.c +39 -22
- data/third_party/boringssl/crypto/curve25519/spake25519.c +1 -1
- data/third_party/boringssl/crypto/dsa/dsa.c +77 -53
- data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +20 -8
- data/third_party/boringssl/crypto/ec_extra/ec_derive.c +96 -0
- data/third_party/boringssl/crypto/{ecdh/ecdh.c → ecdh_extra/ecdh_extra.c} +20 -58
- data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -9
- data/third_party/boringssl/crypto/engine/engine.c +2 -1
- data/third_party/boringssl/crypto/err/err.c +2 -0
- data/third_party/boringssl/crypto/err/internal.h +2 -2
- data/third_party/boringssl/crypto/evp/evp.c +89 -8
- data/third_party/boringssl/crypto/evp/evp_asn1.c +56 -5
- data/third_party/boringssl/crypto/evp/evp_ctx.c +52 -14
- data/third_party/boringssl/crypto/evp/internal.h +18 -1
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +5 -0
- data/third_party/boringssl/crypto/evp/p_ec.c +51 -3
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +6 -7
- data/third_party/boringssl/crypto/evp/p_ed25519.c +36 -3
- data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +76 -45
- data/third_party/boringssl/crypto/evp/p_rsa.c +3 -1
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +5 -0
- data/third_party/boringssl/crypto/evp/p_x25519.c +110 -0
- data/third_party/boringssl/crypto/evp/p_x25519_asn1.c +249 -0
- data/third_party/boringssl/crypto/evp/scrypt.c +6 -2
- data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +34 -274
- data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +161 -21
- data/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c +111 -13
- data/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c +17 -21
- data/third_party/boringssl/crypto/fipsmodule/bcm.c +119 -7
- data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +19 -2
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +2 -2
- data/third_party/boringssl/crypto/fipsmodule/bn/ctx.c +93 -160
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +48 -57
- data/third_party/boringssl/crypto/fipsmodule/bn/div_extra.c +87 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +143 -211
- data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +0 -305
- data/third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c +325 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +168 -50
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +68 -92
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +7 -6
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +11 -14
- data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +358 -443
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +25 -35
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +20 -25
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +76 -5
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +14 -14
- data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +7 -2
- data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +383 -516
- data/third_party/boringssl/crypto/fipsmodule/cipher/e_des.c +4 -0
- data/third_party/boringssl/crypto/fipsmodule/cipher/internal.h +3 -4
- data/third_party/boringssl/crypto/fipsmodule/delocate.h +3 -2
- data/third_party/boringssl/crypto/fipsmodule/digest/digest.c +32 -17
- data/third_party/boringssl/crypto/fipsmodule/digest/md32_common.h +3 -3
- data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +228 -122
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +34 -8
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +311 -98
- data/third_party/boringssl/crypto/fipsmodule/ec/felem.c +82 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +263 -97
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +22 -59
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +317 -234
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +9473 -9475
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +313 -109
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +36 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/scalar.c +96 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +126 -792
- data/third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c +84 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/util.c +163 -12
- data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +84 -211
- data/third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c +122 -0
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +60 -205
- data/third_party/boringssl/crypto/fipsmodule/fips_shared_support.c +32 -0
- data/third_party/boringssl/crypto/fipsmodule/is_fips.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/md4/md4.c +3 -1
- data/third_party/boringssl/crypto/fipsmodule/md5/internal.h +37 -0
- data/third_party/boringssl/crypto/fipsmodule/md5/md5.c +11 -8
- data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +35 -79
- data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +7 -39
- data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +7 -27
- data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +123 -309
- data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +189 -126
- data/third_party/boringssl/crypto/fipsmodule/modes/ofb.c +3 -2
- data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +2 -2
- data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +35 -0
- data/third_party/boringssl/crypto/fipsmodule/rand/rand.c +24 -19
- data/third_party/boringssl/crypto/fipsmodule/rand/urandom.c +256 -77
- data/third_party/boringssl/crypto/fipsmodule/rsa/padding.c +10 -7
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +5 -1
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +131 -14
- data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +83 -10
- data/third_party/boringssl/crypto/fipsmodule/sha/internal.h +53 -0
- data/third_party/boringssl/crypto/fipsmodule/sha/sha1.c +9 -13
- data/third_party/boringssl/crypto/fipsmodule/sha/sha256.c +18 -12
- data/third_party/boringssl/crypto/fipsmodule/sha/sha512.c +95 -168
- data/third_party/boringssl/crypto/hrss/hrss.c +2201 -0
- data/third_party/boringssl/crypto/hrss/internal.h +62 -0
- data/third_party/boringssl/crypto/internal.h +95 -20
- data/third_party/boringssl/crypto/lhash/lhash.c +45 -33
- data/third_party/boringssl/crypto/mem.c +39 -2
- data/third_party/boringssl/crypto/obj/obj.c +4 -4
- data/third_party/boringssl/crypto/obj/obj_dat.h +6181 -875
- data/third_party/boringssl/crypto/pem/pem_all.c +2 -3
- data/third_party/boringssl/crypto/pem/pem_info.c +144 -162
- data/third_party/boringssl/crypto/pem/pem_lib.c +53 -52
- data/third_party/boringssl/crypto/pem/pem_pkey.c +13 -21
- data/third_party/boringssl/crypto/pkcs7/pkcs7.c +15 -22
- data/third_party/boringssl/crypto/pkcs7/pkcs7_x509.c +168 -16
- data/third_party/boringssl/crypto/pkcs8/internal.h +11 -0
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +24 -15
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +42 -25
- data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +559 -43
- data/third_party/boringssl/crypto/pool/internal.h +1 -1
- data/third_party/boringssl/crypto/pool/pool.c +21 -0
- data/third_party/boringssl/crypto/rand_extra/deterministic.c +8 -0
- data/third_party/boringssl/crypto/rand_extra/fuchsia.c +1 -14
- data/third_party/boringssl/crypto/refcount_lock.c +2 -2
- data/third_party/boringssl/crypto/rsa_extra/rsa_print.c +22 -0
- data/third_party/boringssl/crypto/siphash/siphash.c +80 -0
- data/third_party/boringssl/crypto/stack/stack.c +83 -32
- data/third_party/boringssl/crypto/thread_none.c +2 -2
- data/third_party/boringssl/crypto/thread_pthread.c +2 -2
- data/third_party/boringssl/crypto/thread_win.c +38 -19
- data/third_party/boringssl/crypto/x509/a_strex.c +22 -2
- data/third_party/boringssl/crypto/x509/asn1_gen.c +2 -1
- data/third_party/boringssl/crypto/x509/by_dir.c +7 -0
- data/third_party/boringssl/crypto/x509/by_file.c +12 -10
- data/third_party/boringssl/crypto/x509/t_crl.c +5 -8
- data/third_party/boringssl/crypto/x509/t_req.c +1 -3
- data/third_party/boringssl/crypto/x509/t_x509.c +5 -8
- data/third_party/boringssl/crypto/x509/x509_cmp.c +1 -1
- data/third_party/boringssl/crypto/x509/x509_def.c +1 -1
- data/third_party/boringssl/crypto/x509/x509_lu.c +114 -5
- data/third_party/boringssl/crypto/x509/x509_req.c +20 -0
- data/third_party/boringssl/crypto/x509/x509_set.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_trs.c +1 -0
- data/third_party/boringssl/crypto/x509/x509_txt.c +4 -5
- data/third_party/boringssl/crypto/x509/x509_vfy.c +145 -138
- data/third_party/boringssl/crypto/x509/x509_vpm.c +2 -0
- data/third_party/boringssl/crypto/x509/x509cset.c +40 -0
- data/third_party/boringssl/crypto/x509/x509name.c +2 -3
- data/third_party/boringssl/crypto/x509/x_all.c +109 -210
- data/third_party/boringssl/crypto/x509/x_x509.c +6 -0
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +1 -3
- data/third_party/boringssl/crypto/x509v3/internal.h +56 -0
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +2 -0
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -0
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +4 -2
- data/third_party/boringssl/crypto/x509v3/v3_akey.c +5 -2
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +19 -13
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +3 -2
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -6
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +1 -0
- data/third_party/boringssl/crypto/x509v3/v3_ocsp.c +68 -0
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +47 -69
- data/third_party/boringssl/crypto/x509v3/v3_skey.c +5 -2
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +69 -25
- data/third_party/boringssl/include/openssl/aead.h +45 -19
- data/third_party/boringssl/include/openssl/aes.h +32 -7
- data/third_party/boringssl/include/openssl/asn1.h +7 -77
- data/third_party/boringssl/include/openssl/base.h +120 -6
- data/third_party/boringssl/include/openssl/base64.h +4 -1
- data/third_party/boringssl/include/openssl/bio.h +112 -81
- data/third_party/boringssl/include/openssl/blowfish.h +3 -3
- data/third_party/boringssl/include/openssl/bn.h +55 -29
- data/third_party/boringssl/include/openssl/buf.h +2 -2
- data/third_party/boringssl/include/openssl/bytestring.h +54 -32
- data/third_party/boringssl/include/openssl/cast.h +2 -2
- data/third_party/boringssl/include/openssl/cipher.h +46 -16
- data/third_party/boringssl/include/openssl/cmac.h +6 -2
- data/third_party/boringssl/include/openssl/conf.h +3 -6
- data/third_party/boringssl/include/openssl/cpu.h +25 -9
- data/third_party/boringssl/include/openssl/crypto.h +32 -10
- data/third_party/boringssl/include/openssl/curve25519.h +4 -4
- data/third_party/boringssl/include/openssl/dh.h +3 -2
- data/third_party/boringssl/include/openssl/digest.h +21 -7
- data/third_party/boringssl/include/openssl/dsa.h +8 -2
- data/third_party/boringssl/include/openssl/e_os2.h +18 -0
- data/third_party/boringssl/include/openssl/ec.h +25 -21
- data/third_party/boringssl/include/openssl/ec_key.h +36 -8
- data/third_party/boringssl/include/openssl/ecdh.h +17 -0
- data/third_party/boringssl/include/openssl/ecdsa.h +3 -3
- data/third_party/boringssl/include/openssl/engine.h +4 -4
- data/third_party/boringssl/include/openssl/err.h +3 -0
- data/third_party/boringssl/include/openssl/evp.h +199 -42
- data/third_party/boringssl/include/openssl/hmac.h +4 -4
- data/third_party/boringssl/include/openssl/hrss.h +100 -0
- data/third_party/boringssl/include/openssl/lhash.h +131 -23
- data/third_party/boringssl/include/openssl/md4.h +6 -4
- data/third_party/boringssl/include/openssl/md5.h +6 -4
- data/third_party/boringssl/include/openssl/mem.h +6 -2
- data/third_party/boringssl/include/openssl/nid.h +3 -0
- data/third_party/boringssl/include/openssl/obj.h +3 -0
- data/third_party/boringssl/include/openssl/pem.h +102 -64
- data/third_party/boringssl/include/openssl/pkcs7.h +136 -3
- data/third_party/boringssl/include/openssl/pkcs8.h +42 -3
- data/third_party/boringssl/include/openssl/pool.h +13 -2
- data/third_party/boringssl/include/openssl/ripemd.h +5 -4
- data/third_party/boringssl/include/openssl/rsa.h +46 -15
- data/third_party/boringssl/include/openssl/sha.h +40 -28
- data/third_party/boringssl/include/openssl/siphash.h +37 -0
- data/third_party/boringssl/include/openssl/span.h +17 -9
- data/third_party/boringssl/include/openssl/ssl.h +766 -393
- data/third_party/boringssl/include/openssl/ssl3.h +4 -3
- data/third_party/boringssl/include/openssl/stack.h +134 -77
- data/third_party/boringssl/include/openssl/thread.h +1 -1
- data/third_party/boringssl/include/openssl/tls1.h +25 -9
- data/third_party/boringssl/include/openssl/type_check.h +14 -15
- data/third_party/boringssl/include/openssl/x509.h +28 -3
- data/third_party/boringssl/include/openssl/x509_vfy.h +98 -32
- data/third_party/boringssl/include/openssl/x509v3.h +17 -13
- data/third_party/boringssl/ssl/d1_both.cc +9 -18
- data/third_party/boringssl/ssl/d1_lib.cc +4 -3
- data/third_party/boringssl/ssl/d1_pkt.cc +4 -4
- data/third_party/boringssl/ssl/d1_srtp.cc +15 -15
- data/third_party/boringssl/ssl/dtls_method.cc +0 -1
- data/third_party/boringssl/ssl/dtls_record.cc +28 -28
- data/third_party/boringssl/ssl/handoff.cc +295 -91
- data/third_party/boringssl/ssl/handshake.cc +133 -72
- data/third_party/boringssl/ssl/handshake_client.cc +218 -189
- data/third_party/boringssl/ssl/handshake_server.cc +399 -272
- data/third_party/boringssl/ssl/internal.h +1413 -928
- data/third_party/boringssl/ssl/s3_both.cc +175 -36
- data/third_party/boringssl/ssl/s3_lib.cc +9 -13
- data/third_party/boringssl/ssl/s3_pkt.cc +63 -29
- data/third_party/boringssl/ssl/ssl_aead_ctx.cc +55 -35
- data/third_party/boringssl/ssl/ssl_asn1.cc +57 -73
- data/third_party/boringssl/ssl/ssl_buffer.cc +13 -12
- data/third_party/boringssl/ssl/ssl_cert.cc +313 -210
- data/third_party/boringssl/ssl/ssl_cipher.cc +159 -221
- data/third_party/boringssl/ssl/ssl_file.cc +2 -0
- data/third_party/boringssl/ssl/ssl_key_share.cc +164 -19
- data/third_party/boringssl/ssl/ssl_lib.cc +847 -555
- data/third_party/boringssl/ssl/ssl_privkey.cc +441 -111
- data/third_party/boringssl/ssl/ssl_session.cc +230 -178
- data/third_party/boringssl/ssl/ssl_transcript.cc +21 -142
- data/third_party/boringssl/ssl/ssl_versions.cc +88 -93
- data/third_party/boringssl/ssl/ssl_x509.cc +279 -218
- data/third_party/boringssl/ssl/t1_enc.cc +5 -96
- data/third_party/boringssl/ssl/t1_lib.cc +931 -678
- data/third_party/boringssl/ssl/tls13_both.cc +251 -121
- data/third_party/boringssl/ssl/tls13_client.cc +129 -73
- data/third_party/boringssl/ssl/tls13_enc.cc +350 -282
- data/third_party/boringssl/ssl/tls13_server.cc +259 -192
- data/third_party/boringssl/ssl/tls_method.cc +26 -21
- data/third_party/boringssl/ssl/tls_record.cc +42 -47
- data/third_party/boringssl/third_party/fiat/curve25519.c +261 -1324
- data/third_party/boringssl/third_party/fiat/curve25519_32.h +911 -0
- data/third_party/boringssl/third_party/fiat/curve25519_64.h +559 -0
- data/third_party/boringssl/third_party/fiat/p256.c +238 -999
- data/third_party/boringssl/third_party/fiat/p256_32.h +3226 -0
- data/third_party/boringssl/third_party/fiat/p256_64.h +1217 -0
- data/third_party/upb/upb/port_def.inc +1 -1
- data/third_party/upb/upb/table.c +2 -1
- metadata +72 -44
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +0 -127
- data/src/core/lib/gpr/mpscq.cc +0 -117
- data/src/core/lib/gpr/mpscq.h +0 -88
- data/src/core/lib/gprpp/abstract.h +0 -47
- data/src/core/lib/gprpp/pair.h +0 -38
- data/third_party/boringssl/crypto/cipher_extra/e_ssl3.c +0 -460
- data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +0 -256
- data/third_party/boringssl/include/openssl/lhash_macros.h +0 -174
- 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) {
|
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
|
-
/*
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
64
|
-
static const
|
65
|
-
|
66
|
-
|
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
|
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 +=
|
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 =
|
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
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
284
|
-
|
285
|
-
|
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
|
-
|
292
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
emit_indexed(c, dynidx(c,
|
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
|
-
|
541
|
-
|
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(
|
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(
|
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 <
|
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 =
|
606
|
-
|
607
|
-
if (
|
608
|
-
c->
|
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
|
664
|
-
|
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
|
-
|
675
|
-
if (
|
676
|
-
|
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->
|
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;
|