aws-crt 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/aws-crt-ffi/CMakeLists.txt +49 -41
- data/aws-crt-ffi/crt/aws-c-auth/CMakeLists.txt +0 -10
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +4 -4
- data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +1 -14
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +206 -68
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +5 -0
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_cached.c +6 -6
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_default_chain.c +16 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_ecs.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_process.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_sts_web_identity.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_x509.c +10 -7
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +35 -26
- data/aws-crt-ffi/crt/aws-c-auth/source/signable_chunk.c +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_ecs_tests.c +3 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_process_tests.c +65 -16
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_tests.c +125 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +68 -46
- data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +8 -3
- data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +9 -0
- data/aws-crt-ffi/crt/aws-c-cal/builder.json +11 -3
- data/aws-crt-ffi/crt/aws-c-cal/cmake/aws-c-cal-config.cmake +14 -5
- data/aws-crt-ffi/crt/aws-c-cal/source/darwin/securityframework_ecc.c +6 -6
- data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +12 -12
- data/aws-crt-ffi/crt/aws-c-cal/tests/test_case_helper.h +14 -14
- data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +21 -1
- data/aws-crt-ffi/crt/aws-c-common/README.md +8 -0
- data/aws-crt-ffi/crt/aws-c-common/cmake/AwsCFlags.cmake +20 -5
- data/aws-crt-ffi/crt/aws-c-common/cmake/AwsFeatureTests.cmake +7 -1
- data/aws-crt-ffi/crt/aws-c-common/format-check.sh +1 -1
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +14 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/config.h.in +1 -0
- data/aws-crt-ffi/crt/{aws-c-auth/include/aws/auth → aws-c-common/include/aws/common}/external/cJSON.h +82 -74
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/json.h +335 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/logging.h +1 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/math.inl +2 -2
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/json_impl.h +22 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +2 -0
- data/aws-crt-ffi/crt/aws-c-common/source/byte_buf.c +36 -0
- data/aws-crt-ffi/crt/aws-c-common/source/common.c +5 -2
- data/aws-crt-ffi/crt/aws-c-common/source/external/cJSON.c +3113 -0
- data/aws-crt-ffi/crt/aws-c-common/source/file.c +9 -0
- data/aws-crt-ffi/crt/aws-c-common/source/json.c +348 -0
- data/aws-crt-ffi/crt/aws-c-common/source/logging.c +7 -2
- data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +8 -0
- data/aws-crt-ffi/crt/aws-c-common/source/ref_count.c +3 -1
- data/aws-crt-ffi/crt/aws-c-common/source/windows/file.c +47 -0
- data/aws-crt-ffi/crt/aws-c-common/source/windows/system_info.c +2 -1
- data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +5 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/byte_buf_test.c +69 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/json_test.c +134 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/memtrace_test.c +6 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/README.md +18 -35
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream.h +21 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_client.h +14 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_server.h +13 -0
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/private/event_stream_rpc_priv.h +7 -7
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream.c +257 -141
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_channel_handler.c +1 -1
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_client.c +31 -8
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_server.c +63 -10
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/CMakeLists.txt +2 -0
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_client_connection_test.c +157 -106
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_server_connection_test.c +168 -1
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/message_deserializer_test.c +4 -2
- data/aws-crt-ffi/crt/aws-c-http/CMakeLists.txt +1 -0
- data/aws-crt-ffi/crt/aws-c-http/README.md +8 -0
- data/aws-crt-ffi/crt/aws-c-http/bin/elasticurl/main.c +1 -1
- data/aws-crt-ffi/crt/aws-c-http/builder.json +4 -3
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +8 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection_manager.h +45 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http2_stream_manager.h +63 -12
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +2 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_connection.h +20 -2
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_frames.h +1 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_stream.h +42 -13
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http2_stream_manager_impl.h +17 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http_impl.h +3 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/random_access_set.h +10 -3
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +3 -17
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +108 -4
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/statistics.h +22 -0
- data/aws-crt-ffi/crt/aws-c-http/source/connection.c +8 -3
- data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -3
- data/aws-crt-ffi/crt/aws-c-http/source/connection_monitor.c +32 -14
- data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +14 -0
- data/aws-crt-ffi/crt/aws-c-http/source/h1_encoder.c +7 -4
- data/aws-crt-ffi/crt/aws-c-http/source/h2_connection.c +161 -45
- data/aws-crt-ffi/crt/aws-c-http/source/h2_decoder.c +37 -8
- data/aws-crt-ffi/crt/aws-c-http/source/h2_frames.c +13 -1
- data/aws-crt-ffi/crt/aws-c-http/source/h2_stream.c +345 -87
- data/aws-crt-ffi/crt/aws-c-http/source/hpack.c +3 -0
- data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
- data/aws-crt-ffi/crt/aws-c-http/source/http2_stream_manager.c +266 -39
- data/aws-crt-ffi/crt/aws-c-http/source/random_access_set.c +9 -3
- data/aws-crt-ffi/crt/aws-c-http/source/request_response.c +80 -20
- data/aws-crt-ffi/crt/aws-c-http/source/statistics.c +11 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +28 -1
- data/aws-crt-ffi/crt/aws-c-http/tests/fuzz/fuzz_h2_decoder_correct.c +5 -3
- data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.c +133 -29
- data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.h +6 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/README.md +40 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/non_tls_server.py +56 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/server.py +329 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +1 -1
- data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_monitor.c +2 -2
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +47 -34
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_encoder.c +4 -4
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_server.c +15 -12
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_client.c +582 -25
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_encoder.c +3 -3
- data/aws-crt-ffi/crt/aws-c-http/tests/test_localhost_integ.c +530 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +459 -67
- data/aws-crt-ffi/crt/aws-c-io/CMakeLists.txt +4 -0
- data/aws-crt-ffi/crt/aws-c-io/builder.json +3 -2
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/channel.h +21 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/io.h +3 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/socket.h +6 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/stream.h +35 -5
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +211 -15
- data/aws-crt-ffi/crt/aws-c-io/source/channel.c +56 -30
- data/aws-crt-ffi/crt/aws-c-io/source/darwin/secure_transport_tls_channel_handler.c +0 -24
- data/aws-crt-ffi/crt/aws-c-io/source/io.c +9 -0
- data/aws-crt-ffi/crt/aws-c-io/source/{pkcs11.c → pkcs11_lib.c} +162 -22
- data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_private.h +18 -20
- data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +221 -0
- data/aws-crt-ffi/crt/aws-c-io/source/posix/socket.c +135 -81
- data/aws-crt-ffi/crt/aws-c-io/source/retry_strategy.c +12 -8
- data/aws-crt-ffi/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c +252 -215
- data/aws-crt-ffi/crt/aws-c-io/source/stream.c +65 -82
- data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +188 -57
- data/aws-crt-ffi/crt/aws-c-io/source/windows/iocp/socket.c +271 -256
- data/aws-crt-ffi/crt/aws-c-io/tests/CMakeLists.txt +21 -12
- data/aws-crt-ffi/crt/aws-c-io/tests/channel_test.c +32 -4
- data/aws-crt-ffi/crt/aws-c-io/tests/io_lib_test.c +37 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/pkcs11_test.c +412 -93
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.crt +15 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.key +5 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p12 +0 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p8 +5 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/generateCerts.sh +24 -15
- data/aws-crt-ffi/crt/aws-c-io/tests/socket_test.c +72 -1
- data/aws-crt-ffi/crt/s2n/CMakeLists.txt +6 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/Cargo.toml +1 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/generate/src/main.rs +105 -82
- data/aws-crt-ffi/crt/s2n/bindings/rust/generate.sh +1 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +1 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/build.rs +84 -30
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/lib.rs +4 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +21 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem +14 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/key.pem +8 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/client.rs +45 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/server.rs +60 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/src/lib.rs +150 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/tests/handshake.rs +51 -0
- data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +98 -77
- data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.h +10 -7
- data/aws-crt-ffi/crt/s2n/crypto/s2n_openssl.h +2 -0
- data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +1 -1
- data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +1 -0
- data/aws-crt-ffi/crt/s2n/s2n.mk +7 -0
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/repository.py +233 -0
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup-proof.py +8 -7
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup.py +17 -18
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/util.py +41 -23
- data/aws-crt-ffi/crt/s2n/tests/fuzz/LD_PRELOAD/global_overrides.c +3 -3
- data/aws-crt-ffi/crt/s2n/tests/integration/s2n_client_endpoint_handshake_test.py +2 -2
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/Makefile +13 -42
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/README.md +6 -1
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/common.py +118 -53
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/configuration.py +108 -88
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +6 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/constants.py +6 -4
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/fixtures.py +21 -12
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/global_flags.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/processes.py +62 -19
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/providers.py +304 -48
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_client_authentication.py +20 -11
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_cross_compatibility.py +41 -17
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_dynamic_record_sizes.py +6 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_early_data.py +105 -48
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_external_psk.py +160 -76
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_fragmentation.py +59 -26
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_happy_path.py +42 -28
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_hello_retry_requests.py +33 -13
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_key_update.py +29 -11
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_ocsp.py +138 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_pq_handshake.py +103 -36
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_session_resumption.py +52 -25
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_signature_algorithms.py +47 -21
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sni_match.py +13 -9
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sslyze.py +88 -17
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +71 -22
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_well_known_endpoints.py +4 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/tox.ini +1 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/utils.py +50 -15
- data/aws-crt-ffi/crt/s2n/tests/litani/CHANGELOG +131 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/CONTRIBUTING.md +16 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/README.md +36 -14
- data/aws-crt-ffi/crt/s2n/tests/litani/THIRD-PARTY +205 -41
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/bin/build-html-doc +7 -7
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/configure +27 -23
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-add-job.scdoc +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-dump-run.scdoc +7 -5
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-transform-jobs.scdoc +248 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani.scdoc +2 -2
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/templates/index.jinja.html +4 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/README +12 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/original-run.sh +52 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/run-all.py +71 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/README +13 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-1.sh +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-2.sh +35 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-3.sh +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-all.py +60 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/README.md +10 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/assumptions.html +42 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/file.dat +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/histogram.dat +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-1.sh +41 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-2.sh +47 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-3.sh +41 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-all.py +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib-table.py +40 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.plt +5 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.py +32 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin-output.py +40 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.plt +5 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.py +30 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/fib-table.jinja.html +45 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/sin-output.jinja.html +30 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/add_job.py +55 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/graph.py +2 -2
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani.py +6 -1
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani_report.py +18 -21
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/ninja.py +2 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/run_printer.py +26 -7
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/transform_jobs.py +84 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/litani +28 -33
- data/aws-crt-ffi/crt/s2n/tests/litani/script/release +220 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/templates/dashboard.jinja.html +78 -15
- data/aws-crt-ffi/crt/s2n/tests/litani/templates/pipeline.jinja.html +21 -5
- data/aws-crt-ffi/crt/s2n/tests/litani/test/README +15 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/run +56 -33
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/custom_stages.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/cwd.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/dump_run.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/graph_line_break.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/html_node.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/job_id_env.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/multiproc_dump_run.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize_graph.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ignored.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ok.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pipeline_order.py +53 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize_graph.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/single_pool.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_multi_shell.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_shell.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ignored.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ok.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_delete_job.py +54 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_modify_job.py +46 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_no_change_job.py +44 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/zero_pool.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/run +82 -12
- data/aws-crt-ffi/crt/s2n/tests/s2n_test.h +58 -33
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_key_schedule_testlib.c +18 -6
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_pq_kat_test_utils.c +4 -4
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_testlib.h +2 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_retry_test.c +66 -2
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_drbg_test.c +34 -14
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +28 -5
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +6 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_override_openssl_random_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_random_test.c +60 -41
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_broken_pipe_test.c +2 -2
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_handshake_early_data_test.c +3 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_hybrid_shared_secret_test.c +9 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +31 -130
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +2 -4
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_pq_handshake_test.c +11 -6
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_rfc8448_test.c +19 -21
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +109 -60
- data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +1 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +29 -24
- data/aws-crt-ffi/crt/s2n/tls/s2n_connection.h +5 -5
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_hashes.h +1 -7
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_transcript.c +0 -44
- data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +0 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +1 -2
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +84 -44
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +3 -9
- data/aws-crt-ffi/crt/s2n/utils/s2n_blob.h +15 -8
- data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +2 -6
- data/aws-crt-ffi/crt/s2n/utils/s2n_random.c +9 -9
- data/aws-crt-ffi/src/input_stream.c +32 -15
- data/ext/compile.rb +13 -5
- data/lib/aws-crt/platforms.rb +14 -5
- data/lib/aws-crt/string_blob.rb +3 -3
- metadata +61 -7
- data/aws-crt-ffi/crt/aws-c-auth/source/external/cJSON.c +0 -2987
- data/aws-crt-ffi/crt/aws-c-auth/tests/external/cJSON.c +0 -2986
- data/aws-crt-ffi/crt/aws-c-io/tests/error_test.c +0 -20
@@ -13,6 +13,8 @@
|
|
13
13
|
#include <aws/common/logging.h>
|
14
14
|
#include <aws/common/string.h>
|
15
15
|
|
16
|
+
#include <inttypes.h>
|
17
|
+
|
16
18
|
/* #TODO split hpack encoder/decoder into different types */
|
17
19
|
|
18
20
|
/* #TODO test empty strings */
|
@@ -238,6 +240,7 @@ struct aws_hpack_context {
|
|
238
240
|
size_t size;
|
239
241
|
size_t max_size;
|
240
242
|
|
243
|
+
/* TODO: check the new (RFC 9113 - 4.3.1) to make sure we did it right */
|
241
244
|
/* SETTINGS_HEADER_TABLE_SIZE from http2 */
|
242
245
|
size_t protocol_max_size_setting;
|
243
246
|
/* aws_http_header * -> size_t */
|
@@ -318,6 +318,9 @@ static void s_headers_init(struct aws_allocator *alloc) {
|
|
318
318
|
s_header_enum_to_str[AWS_HTTP_HEADER_RETRY_AFTER] = aws_byte_cursor_from_c_str("retry-after");
|
319
319
|
s_header_enum_to_str[AWS_HTTP_HEADER_VARY] = aws_byte_cursor_from_c_str("vary");
|
320
320
|
s_header_enum_to_str[AWS_HTTP_HEADER_WARNING] = aws_byte_cursor_from_c_str("warning");
|
321
|
+
s_header_enum_to_str[AWS_HTTP_HEADER_UPGRADE] = aws_byte_cursor_from_c_str("upgrade");
|
322
|
+
s_header_enum_to_str[AWS_HTTP_HEADER_KEEP_ALIVE] = aws_byte_cursor_from_c_str("keep-alive");
|
323
|
+
s_header_enum_to_str[AWS_HTTP_HEADER_PROXY_CONNECTION] = aws_byte_cursor_from_c_str("proxy-connection");
|
321
324
|
|
322
325
|
s_init_str_to_enum_hash_table(
|
323
326
|
&s_header_str_to_enum,
|
@@ -4,6 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include <aws/common/array_list.h>
|
7
|
+
#include <aws/common/clock.h>
|
7
8
|
#include <aws/common/hash_table.h>
|
8
9
|
#include <aws/common/logging.h>
|
9
10
|
#include <aws/http/connection.h>
|
@@ -16,6 +17,7 @@
|
|
16
17
|
#include <aws/http/http2_stream_manager.h>
|
17
18
|
#include <aws/http/private/http2_stream_manager_impl.h>
|
18
19
|
#include <aws/http/private/request_response_impl.h>
|
20
|
+
#include <aws/http/status_code.h>
|
19
21
|
|
20
22
|
#include <inttypes.h>
|
21
23
|
|
@@ -30,6 +32,9 @@
|
|
30
32
|
AWS_LOGF_##level(AWS_LS_HTTP_STREAM_MANAGER, "id=%p: " text, (void *)(stream_manager), __VA_ARGS__)
|
31
33
|
#define STREAM_MANAGER_LOG(level, stream_manager, text) STREAM_MANAGER_LOGF(level, stream_manager, "%s", text)
|
32
34
|
|
35
|
+
/* 3 seconds */
|
36
|
+
static const size_t s_default_ping_timeout_ms = 3000;
|
37
|
+
|
33
38
|
static void s_stream_manager_start_destroy(struct aws_http2_stream_manager *stream_manager);
|
34
39
|
static void s_aws_http2_stream_manager_build_transaction_synced(struct aws_http2_stream_management_transaction *work);
|
35
40
|
static void s_aws_http2_stream_manager_execute_transaction(struct aws_http2_stream_management_transaction *work);
|
@@ -98,7 +103,6 @@ static void s_sm_count_increase_synced(
|
|
98
103
|
for (size_t i = 0; i < num; i++) {
|
99
104
|
aws_ref_count_acquire(&stream_manager->internal_ref_count);
|
100
105
|
}
|
101
|
-
s_sm_log_stats_synced(stream_manager);
|
102
106
|
}
|
103
107
|
|
104
108
|
static void s_sm_count_decrease_synced(
|
@@ -109,15 +113,12 @@ static void s_sm_count_decrease_synced(
|
|
109
113
|
for (size_t i = 0; i < num; i++) {
|
110
114
|
aws_ref_count_release(&stream_manager->internal_ref_count);
|
111
115
|
}
|
112
|
-
s_sm_log_stats_synced(stream_manager);
|
113
116
|
}
|
114
117
|
|
115
118
|
static void s_aws_stream_management_transaction_init(
|
116
119
|
struct aws_http2_stream_management_transaction *work,
|
117
120
|
struct aws_http2_stream_manager *stream_manager) {
|
118
121
|
AWS_ZERO_STRUCT(*work);
|
119
|
-
|
120
|
-
STREAM_MANAGER_LOGF(TRACE, stream_manager, "work:%p inits", (void *)work);
|
121
122
|
aws_linked_list_init(&work->pending_make_requests);
|
122
123
|
work->stream_manager = stream_manager;
|
123
124
|
work->allocator = stream_manager->allocator;
|
@@ -126,7 +127,6 @@ static void s_aws_stream_management_transaction_init(
|
|
126
127
|
|
127
128
|
static void s_aws_stream_management_transaction_clean_up(struct aws_http2_stream_management_transaction *work) {
|
128
129
|
(void)work;
|
129
|
-
STREAM_MANAGER_LOGF(TRACE, work->stream_manager, "work:%p clean up", (void *)work);
|
130
130
|
AWS_ASSERT(aws_linked_list_empty(&work->pending_make_requests));
|
131
131
|
aws_ref_count_release(&work->stream_manager->internal_ref_count);
|
132
132
|
}
|
@@ -142,11 +142,12 @@ static struct aws_h2_sm_connection *s_get_best_sm_connection_from_set(struct aws
|
|
142
142
|
sm_connection_a->num_streams_assigned > sm_connection_b->num_streams_assigned ? sm_connection_b
|
143
143
|
: sm_connection_a;
|
144
144
|
return errored == AWS_ERROR_SUCCESS ? chosen_connection : NULL;
|
145
|
+
(void)errored;
|
145
146
|
}
|
146
147
|
|
147
148
|
/* helper function for building the transaction: Try to assign connection for a pending stream acquisition */
|
148
149
|
/* *_synced should only be called with LOCK HELD or from another synced function */
|
149
|
-
static void
|
150
|
+
static void s_sm_try_assign_connection_to_pending_stream_acquisition_synced(
|
150
151
|
struct aws_http2_stream_manager *stream_manager,
|
151
152
|
struct aws_h2_sm_pending_stream_acquisition *pending_stream_acquisition) {
|
152
153
|
|
@@ -163,7 +164,7 @@ static void s_sm_try_assign_connection_to_pending_stream_acquisition(
|
|
163
164
|
chosen_connection->num_streams_assigned++;
|
164
165
|
|
165
166
|
STREAM_MANAGER_LOGF(
|
166
|
-
|
167
|
+
DEBUG,
|
167
168
|
stream_manager,
|
168
169
|
"Picking connection:%p for acquisition:%p. Streams assigned to the connection=%" PRIu32 "",
|
169
170
|
(void *)chosen_connection->connection,
|
@@ -215,7 +216,7 @@ static void s_sm_try_assign_connection_to_pending_stream_acquisition(
|
|
215
216
|
chosen_connection->num_streams_assigned++;
|
216
217
|
|
217
218
|
STREAM_MANAGER_LOGF(
|
218
|
-
|
219
|
+
DEBUG,
|
219
220
|
stream_manager,
|
220
221
|
"Picking connection:%p for acquisition:%p. Streams assigned to the connection=%" PRIu32 "",
|
221
222
|
(void *)chosen_connection->connection,
|
@@ -239,6 +240,7 @@ static void s_sm_try_assign_connection_to_pending_stream_acquisition(
|
|
239
240
|
}
|
240
241
|
}
|
241
242
|
AWS_ASSERT(errored == 0 && "random access set went wrong");
|
243
|
+
(void)errored;
|
242
244
|
}
|
243
245
|
|
244
246
|
/* NOTE: never invoke with lock held */
|
@@ -312,14 +314,14 @@ static void s_check_new_connections_needed_synced(struct aws_http2_stream_manage
|
|
312
314
|
ideal_new_connection_count,
|
313
315
|
stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_CONNECTIONS_ACQUIRING]);
|
314
316
|
/* The real number we can have is the min of how many more we can still have and how many we need */
|
315
|
-
size_t
|
317
|
+
size_t new_connections_available =
|
316
318
|
stream_manager->max_connections - stream_manager->synced_data.holding_connections_count -
|
317
319
|
stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_CONNECTIONS_ACQUIRING];
|
318
|
-
work->new_connections = aws_min_size(
|
320
|
+
work->new_connections = aws_min_size(new_connections_available, work->new_connections);
|
319
321
|
/* Update the number of connections we acquiring */
|
320
322
|
s_sm_count_increase_synced(stream_manager, AWS_SMCT_CONNECTIONS_ACQUIRING, work->new_connections);
|
321
323
|
STREAM_MANAGER_LOGF(
|
322
|
-
|
324
|
+
DEBUG,
|
323
325
|
stream_manager,
|
324
326
|
"number of acquisition that waiting for connections to use=%zu. connection acquiring=%zu, connection held=%zu, "
|
325
327
|
"max connection=%zu",
|
@@ -347,12 +349,12 @@ static void s_aws_http2_stream_manager_build_transaction_synced(struct aws_http2
|
|
347
349
|
aws_linked_list_pop_front(&stream_manager->synced_data.pending_stream_acquisitions);
|
348
350
|
struct aws_h2_sm_pending_stream_acquisition *pending_stream_acquisition =
|
349
351
|
AWS_CONTAINER_OF(node, struct aws_h2_sm_pending_stream_acquisition, node);
|
350
|
-
|
352
|
+
s_sm_try_assign_connection_to_pending_stream_acquisition_synced(stream_manager, pending_stream_acquisition);
|
351
353
|
if (pending_stream_acquisition->sm_connection == NULL) {
|
352
354
|
/* Cannot find any connection, push it back to the front and break the loop */
|
353
355
|
aws_linked_list_push_front(&stream_manager->synced_data.pending_stream_acquisitions, node);
|
354
356
|
STREAM_MANAGER_LOGF(
|
355
|
-
|
357
|
+
DEBUG,
|
356
358
|
stream_manager,
|
357
359
|
"acquisition:%p cannot find any connection to use.",
|
358
360
|
(void *)pending_stream_acquisition);
|
@@ -390,6 +392,111 @@ static void s_aws_http2_stream_manager_build_transaction_synced(struct aws_http2
|
|
390
392
|
stream_manager->synced_data.finish_pending_stream_acquisitions_task_scheduled = true;
|
391
393
|
}
|
392
394
|
}
|
395
|
+
s_sm_log_stats_synced(stream_manager);
|
396
|
+
}
|
397
|
+
|
398
|
+
static void s_on_ping_complete(
|
399
|
+
struct aws_http_connection *http2_connection,
|
400
|
+
uint64_t round_trip_time_ns,
|
401
|
+
int error_code,
|
402
|
+
void *user_data) {
|
403
|
+
|
404
|
+
(void)http2_connection;
|
405
|
+
struct aws_h2_sm_connection *sm_connection = user_data;
|
406
|
+
if (error_code) {
|
407
|
+
goto done;
|
408
|
+
}
|
409
|
+
if (!sm_connection->connection) {
|
410
|
+
goto done;
|
411
|
+
}
|
412
|
+
AWS_ASSERT(aws_channel_thread_is_callers_thread(aws_http_connection_get_channel(sm_connection->connection)));
|
413
|
+
STREAM_MANAGER_LOGF(
|
414
|
+
TRACE,
|
415
|
+
sm_connection->stream_manager,
|
416
|
+
"PING ACK received for connection: %p. Round trip time in ns is: %" PRIu64 ".",
|
417
|
+
(void *)sm_connection->connection,
|
418
|
+
round_trip_time_ns);
|
419
|
+
sm_connection->thread_data.ping_received = true;
|
420
|
+
|
421
|
+
done:
|
422
|
+
/* Release refcount held for ping complete */
|
423
|
+
aws_ref_count_release(&sm_connection->ref_count);
|
424
|
+
}
|
425
|
+
|
426
|
+
static void s_connection_ping_timeout_task(struct aws_channel_task *task, void *arg, enum aws_task_status status) {
|
427
|
+
(void)task;
|
428
|
+
(void)status;
|
429
|
+
struct aws_h2_sm_connection *sm_connection = arg;
|
430
|
+
if (status != AWS_TASK_STATUS_RUN_READY) {
|
431
|
+
goto done;
|
432
|
+
}
|
433
|
+
if (!sm_connection->connection) {
|
434
|
+
/* The connection has been released before timeout happens, just release the refcount */
|
435
|
+
goto done;
|
436
|
+
}
|
437
|
+
AWS_ASSERT(aws_channel_thread_is_callers_thread(aws_http_connection_get_channel(sm_connection->connection)));
|
438
|
+
if (!sm_connection->thread_data.ping_received) {
|
439
|
+
/* Timeout happened */
|
440
|
+
STREAM_MANAGER_LOGF(
|
441
|
+
ERROR,
|
442
|
+
sm_connection->stream_manager,
|
443
|
+
"ping timeout detected for connection: %p, closing connection.",
|
444
|
+
(void *)sm_connection->connection);
|
445
|
+
|
446
|
+
aws_http_connection_close(sm_connection->connection);
|
447
|
+
} else {
|
448
|
+
struct aws_channel *channel = aws_http_connection_get_channel(sm_connection->connection);
|
449
|
+
/* acquire a refcount for next set of tasks to run */
|
450
|
+
aws_ref_count_acquire(&sm_connection->ref_count);
|
451
|
+
aws_channel_schedule_task_future(
|
452
|
+
channel, &sm_connection->ping_task, sm_connection->thread_data.next_ping_task_time);
|
453
|
+
}
|
454
|
+
done:
|
455
|
+
/* Release refcount for current set of tasks */
|
456
|
+
aws_ref_count_release(&sm_connection->ref_count);
|
457
|
+
}
|
458
|
+
|
459
|
+
static void s_connection_ping_task(struct aws_channel_task *task, void *arg, enum aws_task_status status) {
|
460
|
+
(void)task;
|
461
|
+
(void)status;
|
462
|
+
struct aws_h2_sm_connection *sm_connection = arg;
|
463
|
+
if (status != AWS_TASK_STATUS_RUN_READY) {
|
464
|
+
aws_ref_count_release(&sm_connection->ref_count);
|
465
|
+
return;
|
466
|
+
}
|
467
|
+
if (!sm_connection->connection) {
|
468
|
+
/* The connection has been released before ping task, just release the refcount */
|
469
|
+
aws_ref_count_release(&sm_connection->ref_count);
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
AWS_ASSERT(aws_channel_thread_is_callers_thread(aws_http_connection_get_channel(sm_connection->connection)));
|
473
|
+
|
474
|
+
STREAM_MANAGER_LOGF(
|
475
|
+
TRACE, sm_connection->stream_manager, "Sending PING for connection: %p.", (void *)sm_connection->connection);
|
476
|
+
aws_http2_connection_ping(sm_connection->connection, NULL, s_on_ping_complete, sm_connection);
|
477
|
+
/* Acquire refcount for PING complete to be invoked. */
|
478
|
+
aws_ref_count_acquire(&sm_connection->ref_count);
|
479
|
+
sm_connection->thread_data.ping_received = false;
|
480
|
+
|
481
|
+
/* schedule timeout task */
|
482
|
+
struct aws_channel *channel = aws_http_connection_get_channel(sm_connection->connection);
|
483
|
+
uint64_t current_time = 0;
|
484
|
+
aws_channel_current_clock_time(channel, ¤t_time);
|
485
|
+
sm_connection->thread_data.next_ping_task_time =
|
486
|
+
current_time + sm_connection->stream_manager->connection_ping_period_ns;
|
487
|
+
uint64_t timeout_time = current_time + sm_connection->stream_manager->connection_ping_timeout_ns;
|
488
|
+
aws_channel_task_init(
|
489
|
+
&sm_connection->ping_timeout_task,
|
490
|
+
s_connection_ping_timeout_task,
|
491
|
+
sm_connection,
|
492
|
+
"Stream manager connection ping timeout task");
|
493
|
+
/* keep the refcount for timeout task to run */
|
494
|
+
aws_channel_schedule_task_future(channel, &sm_connection->ping_timeout_task, timeout_time);
|
495
|
+
}
|
496
|
+
|
497
|
+
static void s_sm_connection_destroy(void *user_data) {
|
498
|
+
struct aws_h2_sm_connection *sm_connection = user_data;
|
499
|
+
aws_mem_release(sm_connection->allocator, sm_connection);
|
393
500
|
}
|
394
501
|
|
395
502
|
static struct aws_h2_sm_connection *s_sm_connection_new(
|
@@ -397,6 +504,7 @@ static struct aws_h2_sm_connection *s_sm_connection_new(
|
|
397
504
|
struct aws_http_connection *connection) {
|
398
505
|
struct aws_h2_sm_connection *sm_connection =
|
399
506
|
aws_mem_calloc(stream_manager->allocator, 1, sizeof(struct aws_h2_sm_connection));
|
507
|
+
sm_connection->allocator = stream_manager->allocator;
|
400
508
|
/* Max concurrent stream reached, we need to update the max for the sm_connection */
|
401
509
|
struct aws_http2_setting out_settings[AWS_HTTP2_SETTINGS_COUNT];
|
402
510
|
/* The setting id equals to the index plus one. */
|
@@ -407,16 +515,33 @@ static struct aws_h2_sm_connection *s_sm_connection_new(
|
|
407
515
|
sm_connection->connection = connection;
|
408
516
|
sm_connection->stream_manager = stream_manager;
|
409
517
|
sm_connection->state = AWS_H2SMCST_IDEAL;
|
518
|
+
aws_ref_count_init(&sm_connection->ref_count, sm_connection, s_sm_connection_destroy);
|
519
|
+
if (stream_manager->connection_ping_period_ns) {
|
520
|
+
struct aws_channel *channel = aws_http_connection_get_channel(connection);
|
521
|
+
uint64_t schedule_time = 0;
|
522
|
+
aws_channel_current_clock_time(channel, &schedule_time);
|
523
|
+
schedule_time += stream_manager->connection_ping_period_ns;
|
524
|
+
aws_channel_task_init(
|
525
|
+
&sm_connection->ping_task, s_connection_ping_task, sm_connection, "Stream manager connection ping task");
|
526
|
+
/* Keep a refcount on sm_connection for the task to run. */
|
527
|
+
aws_ref_count_acquire(&sm_connection->ref_count);
|
528
|
+
aws_channel_schedule_task_future(channel, &sm_connection->ping_task, schedule_time);
|
529
|
+
}
|
410
530
|
return sm_connection;
|
411
531
|
}
|
412
532
|
|
413
|
-
void
|
533
|
+
static void s_sm_connection_release_connection(struct aws_h2_sm_connection *sm_connection) {
|
414
534
|
AWS_ASSERT(sm_connection->num_streams_assigned == 0);
|
415
535
|
if (sm_connection->connection) {
|
416
|
-
|
536
|
+
/* Should only be invoked from the connection thread. */
|
537
|
+
AWS_ASSERT(aws_channel_thread_is_callers_thread(aws_http_connection_get_channel(sm_connection->connection)));
|
538
|
+
int error = aws_http_connection_manager_release_connection(
|
417
539
|
sm_connection->stream_manager->connection_manager, sm_connection->connection);
|
540
|
+
AWS_ASSERT(!error);
|
541
|
+
(void)error;
|
542
|
+
sm_connection->connection = NULL;
|
418
543
|
}
|
419
|
-
|
544
|
+
aws_ref_count_release(&sm_connection->ref_count);
|
420
545
|
}
|
421
546
|
|
422
547
|
static void s_sm_on_connection_acquired_failed_synced(
|
@@ -445,6 +570,7 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
445
570
|
STREAM_MANAGER_LOGF(TRACE, stream_manager, "connection=%p acquired from connection manager", (void *)connection);
|
446
571
|
int re_error = 0;
|
447
572
|
int stream_fail_error_code = AWS_ERROR_SUCCESS;
|
573
|
+
bool should_release_connection = false;
|
448
574
|
struct aws_linked_list stream_acquisitions_to_fail;
|
449
575
|
aws_linked_list_init(&stream_acquisitions_to_fail);
|
450
576
|
s_aws_stream_management_transaction_init(&work, stream_manager);
|
@@ -453,7 +579,7 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
453
579
|
s_sm_count_decrease_synced(stream_manager, AWS_SMCT_CONNECTIONS_ACQUIRING, 1);
|
454
580
|
if (error_code || !connection) {
|
455
581
|
STREAM_MANAGER_LOGF(
|
456
|
-
|
582
|
+
ERROR,
|
457
583
|
stream_manager,
|
458
584
|
"connection acquired from connection manager failed, with error: %d(%s)",
|
459
585
|
error_code,
|
@@ -466,7 +592,7 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
466
592
|
stream_manager,
|
467
593
|
"Unexpected HTTP version acquired, release the connection=%p acquired immediately",
|
468
594
|
(void *)connection);
|
469
|
-
|
595
|
+
should_release_connection = true;
|
470
596
|
s_sm_on_connection_acquired_failed_synced(stream_manager, &stream_acquisitions_to_fail);
|
471
597
|
stream_fail_error_code = AWS_ERROR_HTTP_STREAM_MANAGER_UNEXPECTED_HTTP_VERSION;
|
472
598
|
} else if (stream_manager->synced_data.state != AWS_H2SMST_READY) {
|
@@ -476,7 +602,7 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
476
602
|
"shutting down, release the connection=%p acquired immediately",
|
477
603
|
(void *)connection);
|
478
604
|
/* Release the acquired connection */
|
479
|
-
|
605
|
+
should_release_connection = true;
|
480
606
|
} else if (stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_PENDING_ACQUISITION] == 0) {
|
481
607
|
STREAM_MANAGER_LOGF(
|
482
608
|
DEBUG,
|
@@ -484,7 +610,7 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
484
610
|
"No pending acquisition, release the connection=%p acquired immediately",
|
485
611
|
(void *)connection);
|
486
612
|
/* Release the acquired connection */
|
487
|
-
|
613
|
+
should_release_connection = true;
|
488
614
|
} else {
|
489
615
|
struct aws_h2_sm_connection *sm_connection = s_sm_connection_new(stream_manager, connection);
|
490
616
|
bool added = false;
|
@@ -497,7 +623,14 @@ static void s_sm_on_connection_acquired(struct aws_http_connection *connection,
|
|
497
623
|
s_unlock_synced_data(stream_manager);
|
498
624
|
} /* END CRITICAL SECTION */
|
499
625
|
|
626
|
+
if (should_release_connection) {
|
627
|
+
STREAM_MANAGER_LOGF(DEBUG, stream_manager, "Releasing connection: %p", (void *)connection);
|
628
|
+
re_error |= aws_http_connection_manager_release_connection(stream_manager->connection_manager, connection);
|
629
|
+
}
|
630
|
+
|
500
631
|
AWS_ASSERT(!re_error && "connection acquired callback fails with programming errors");
|
632
|
+
(void)re_error;
|
633
|
+
|
501
634
|
/* Fail acquisitions if any */
|
502
635
|
s_finish_pending_stream_acquisitions_list_helper(
|
503
636
|
stream_manager, &stream_acquisitions_to_fail, stream_fail_error_code);
|
@@ -511,10 +644,40 @@ static int s_on_incoming_headers(
|
|
511
644
|
size_t num_headers,
|
512
645
|
void *user_data) {
|
513
646
|
struct aws_h2_sm_pending_stream_acquisition *pending_stream_acquisition = user_data;
|
647
|
+
struct aws_h2_sm_connection *sm_connection = pending_stream_acquisition->sm_connection;
|
648
|
+
struct aws_http2_stream_manager *stream_manager = sm_connection->stream_manager;
|
649
|
+
|
514
650
|
if (pending_stream_acquisition->options.on_response_headers) {
|
515
651
|
return pending_stream_acquisition->options.on_response_headers(
|
516
652
|
stream, header_block, header_array, num_headers, pending_stream_acquisition->options.user_data);
|
517
653
|
}
|
654
|
+
if (stream_manager->close_connection_on_server_error) {
|
655
|
+
/* Check status code if stream completed successfully. */
|
656
|
+
int status_code = 0;
|
657
|
+
aws_http_stream_get_incoming_response_status(stream, &status_code);
|
658
|
+
AWS_ASSERT(status_code != 0); /* The get status should not fail */
|
659
|
+
switch (status_code) {
|
660
|
+
case AWS_HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR:
|
661
|
+
case AWS_HTTP_STATUS_CODE_502_BAD_GATEWAY:
|
662
|
+
case AWS_HTTP_STATUS_CODE_503_SERVICE_UNAVAILABLE:
|
663
|
+
case AWS_HTTP_STATUS_CODE_504_GATEWAY_TIMEOUT:
|
664
|
+
/* For those error code if the retry happens, it should not use the same connection. */
|
665
|
+
if (!sm_connection->thread_data.stopped_new_requests) {
|
666
|
+
STREAM_MANAGER_LOGF(
|
667
|
+
DEBUG,
|
668
|
+
stream_manager,
|
669
|
+
"no longer using connection: %p due to receiving %d server error status code for stream: %p",
|
670
|
+
(void *)sm_connection->connection,
|
671
|
+
status_code,
|
672
|
+
(void *)stream);
|
673
|
+
aws_http_connection_stop_new_requests(sm_connection->connection);
|
674
|
+
sm_connection->thread_data.stopped_new_requests = true;
|
675
|
+
}
|
676
|
+
break;
|
677
|
+
default:
|
678
|
+
break;
|
679
|
+
}
|
680
|
+
}
|
518
681
|
return AWS_OP_SUCCESS;
|
519
682
|
}
|
520
683
|
|
@@ -539,7 +702,7 @@ static int s_on_incoming_body(struct aws_http_stream *stream, const struct aws_b
|
|
539
702
|
return AWS_OP_SUCCESS;
|
540
703
|
}
|
541
704
|
|
542
|
-
/* Helper invoked when underlying connections is still
|
705
|
+
/* Helper invoked when underlying connections is still available and the num stream assigned has been updated */
|
543
706
|
static void s_update_sm_connection_set_on_stream_finishes_synced(
|
544
707
|
struct aws_h2_sm_connection *sm_connection,
|
545
708
|
struct aws_http2_stream_manager *stream_manager) {
|
@@ -593,6 +756,7 @@ static void s_update_sm_connection_set_on_stream_finishes_synced(
|
|
593
756
|
re_error |= !added;
|
594
757
|
}
|
595
758
|
AWS_ASSERT(re_error == AWS_OP_SUCCESS);
|
759
|
+
(void)re_error;
|
596
760
|
}
|
597
761
|
|
598
762
|
static void s_sm_connection_on_scheduled_stream_finishes(
|
@@ -621,7 +785,11 @@ static void s_sm_connection_on_scheduled_stream_finishes(
|
|
621
785
|
aws_random_access_set_remove(&stream_manager->synced_data.ideal_available_set, sm_connection);
|
622
786
|
work.sm_connection_to_release = sm_connection;
|
623
787
|
--stream_manager->synced_data.holding_connections_count;
|
624
|
-
|
788
|
+
/* After we release one connection back, we should check if we need more connections */
|
789
|
+
if (stream_manager->synced_data.state == AWS_H2SMST_READY &&
|
790
|
+
stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_PENDING_ACQUISITION]) {
|
791
|
+
s_check_new_connections_needed_synced(&work);
|
792
|
+
}
|
625
793
|
}
|
626
794
|
s_unlock_synced_data(stream_manager);
|
627
795
|
} /* END CRITICAL SECTION */
|
@@ -696,9 +864,11 @@ static void s_make_request_task(struct aws_channel_task *task, void *arg, enum a
|
|
696
864
|
.on_complete = s_on_stream_complete,
|
697
865
|
.user_data = pending_stream_acquisition,
|
698
866
|
};
|
867
|
+
/* TODO: we could put the pending acquisition back to the list if the connection is not available for new request.
|
868
|
+
*/
|
869
|
+
|
699
870
|
struct aws_http_stream *stream = aws_http_connection_make_request(sm_connection->connection, &request_options);
|
700
871
|
if (!stream) {
|
701
|
-
/* TODO: we could put the pending acquisition back to the list instead. */
|
702
872
|
error_code = aws_last_error();
|
703
873
|
STREAM_MANAGER_LOGF(
|
704
874
|
ERROR,
|
@@ -745,7 +915,6 @@ error:
|
|
745
915
|
static void s_aws_http2_stream_manager_execute_transaction(struct aws_http2_stream_management_transaction *work) {
|
746
916
|
|
747
917
|
struct aws_http2_stream_manager *stream_manager = work->stream_manager;
|
748
|
-
STREAM_MANAGER_LOGF(TRACE, stream_manager, "work:%p executes", (void *)work);
|
749
918
|
|
750
919
|
/* Step1: Release connection */
|
751
920
|
if (work->sm_connection_to_release) {
|
@@ -755,12 +924,12 @@ static void s_aws_http2_stream_manager_execute_transaction(struct aws_http2_stre
|
|
755
924
|
stream_manager,
|
756
925
|
"Release connection:%p back to connection manager as no outstanding streams",
|
757
926
|
(void *)work->sm_connection_to_release->connection);
|
758
|
-
|
927
|
+
s_sm_connection_release_connection(work->sm_connection_to_release);
|
759
928
|
}
|
760
929
|
|
761
930
|
/* Step2: Make request. The work should know what connection for the request to be made. */
|
762
931
|
while (!aws_linked_list_empty(&work->pending_make_requests)) {
|
763
|
-
/* The completions can also fail as the connection can be
|
932
|
+
/* The completions can also fail as the connection can be unavailable after the decision made. We just fail
|
764
933
|
* the acquisition */
|
765
934
|
struct aws_linked_list_node *node = aws_linked_list_pop_front(&work->pending_make_requests);
|
766
935
|
struct aws_h2_sm_pending_stream_acquisition *pending_stream_acquisition =
|
@@ -777,7 +946,6 @@ static void s_aws_http2_stream_manager_execute_transaction(struct aws_http2_stre
|
|
777
946
|
(void *)pending_stream_acquisition,
|
778
947
|
(void *)pending_stream_acquisition->sm_connection->connection);
|
779
948
|
/**
|
780
|
-
* TODO: Maybe a task per connection instead.
|
781
949
|
* schedule a task from the connection's event loop to make request, so that:
|
782
950
|
* - We can activate the stream for user and then invoked the callback
|
783
951
|
* - The callback will happen asynced even the stream failed to be created
|
@@ -795,7 +963,7 @@ static void s_aws_http2_stream_manager_execute_transaction(struct aws_http2_stre
|
|
795
963
|
|
796
964
|
/* Step 3: Acquire connections if needed */
|
797
965
|
if (work->new_connections) {
|
798
|
-
STREAM_MANAGER_LOGF(
|
966
|
+
STREAM_MANAGER_LOGF(DEBUG, stream_manager, "acquiring %zu new connections", work->new_connections);
|
799
967
|
}
|
800
968
|
for (size_t i = 0; i < work->new_connections; ++i) {
|
801
969
|
aws_http_connection_manager_acquire_connection(
|
@@ -876,11 +1044,22 @@ void s_stream_manager_on_zero_external_ref(struct aws_http2_stream_manager *stre
|
|
876
1044
|
struct aws_http2_stream_manager *aws_http2_stream_manager_new(
|
877
1045
|
struct aws_allocator *allocator,
|
878
1046
|
struct aws_http2_stream_manager_options *options) {
|
879
|
-
AWS_PRECONDITION(allocator);
|
880
1047
|
|
1048
|
+
AWS_PRECONDITION(allocator);
|
1049
|
+
/* The other options are validated by the aws_http_connection_manager_new */
|
1050
|
+
if (!options->http2_prior_knowledge && !options->tls_connection_options) {
|
1051
|
+
AWS_LOGF_ERROR(
|
1052
|
+
AWS_LS_HTTP_CONNECTION_MANAGER,
|
1053
|
+
"Invalid options - Prior knowledge must be used for cleartext HTTP/2 connections."
|
1054
|
+
" Upgrade from HTTP/1.1 is not supported.");
|
1055
|
+
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
|
1056
|
+
return NULL;
|
1057
|
+
}
|
881
1058
|
struct aws_http2_stream_manager *stream_manager =
|
882
1059
|
aws_mem_calloc(allocator, 1, sizeof(struct aws_http2_stream_manager));
|
883
1060
|
stream_manager->allocator = allocator;
|
1061
|
+
aws_linked_list_init(&stream_manager->synced_data.pending_stream_acquisitions);
|
1062
|
+
|
884
1063
|
if (aws_mutex_init(&stream_manager->synced_data.lock)) {
|
885
1064
|
goto on_error;
|
886
1065
|
}
|
@@ -911,18 +1090,32 @@ struct aws_http2_stream_manager *aws_http2_stream_manager_new(
|
|
911
1090
|
stream_manager,
|
912
1091
|
(aws_simple_completion_callback *)s_stream_manager_start_destroy);
|
913
1092
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
1093
|
+
if (options->connection_ping_period_ms) {
|
1094
|
+
stream_manager->connection_ping_period_ns =
|
1095
|
+
aws_timestamp_convert(options->connection_ping_period_ms, AWS_TIMESTAMP_MILLIS, AWS_TIMESTAMP_NANOS, NULL);
|
1096
|
+
size_t connection_ping_timeout_ms =
|
1097
|
+
options->connection_ping_timeout_ms ? options->connection_ping_timeout_ms : s_default_ping_timeout_ms;
|
1098
|
+
stream_manager->connection_ping_timeout_ns =
|
1099
|
+
aws_timestamp_convert(connection_ping_timeout_ms, AWS_TIMESTAMP_MILLIS, AWS_TIMESTAMP_NANOS, NULL);
|
1100
|
+
if (stream_manager->connection_ping_period_ns < stream_manager->connection_ping_timeout_ns) {
|
1101
|
+
STREAM_MANAGER_LOGF(
|
1102
|
+
WARN,
|
1103
|
+
stream_manager,
|
1104
|
+
"connection_ping_period_ms: %zu is shorter than connection_ping_timeout_ms: %zu. Clapping "
|
1105
|
+
"connection_ping_timeout_ms to %zu",
|
1106
|
+
options->connection_ping_period_ms,
|
1107
|
+
connection_ping_timeout_ms,
|
1108
|
+
options->connection_ping_period_ms);
|
1109
|
+
stream_manager->connection_ping_timeout_ns = stream_manager->connection_ping_period_ns;
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
|
920
1113
|
stream_manager->bootstrap = aws_client_bootstrap_acquire(options->bootstrap);
|
921
1114
|
struct aws_http_connection_manager_options cm_options = {
|
922
1115
|
.bootstrap = options->bootstrap,
|
923
1116
|
.socket_options = options->socket_options,
|
924
1117
|
.tls_connection_options = options->tls_connection_options,
|
925
|
-
.
|
1118
|
+
.http2_prior_knowledge = options->http2_prior_knowledge,
|
926
1119
|
.host = options->host,
|
927
1120
|
.port = options->port,
|
928
1121
|
.enable_read_back_pressure = options->enable_read_back_pressure,
|
@@ -932,8 +1125,10 @@ struct aws_http2_stream_manager *aws_http2_stream_manager_new(
|
|
932
1125
|
.max_connections = options->max_connections,
|
933
1126
|
.shutdown_complete_user_data = stream_manager,
|
934
1127
|
.shutdown_complete_callback = s_stream_manager_on_cm_shutdown_complete,
|
935
|
-
.initial_settings_array = options->
|
936
|
-
.num_initial_settings = options->
|
1128
|
+
.initial_settings_array = options->initial_settings_array,
|
1129
|
+
.num_initial_settings = options->num_initial_settings,
|
1130
|
+
.max_closed_streams = options->max_closed_streams,
|
1131
|
+
.http2_conn_manual_window_management = options->conn_manual_window_management,
|
937
1132
|
};
|
938
1133
|
/* aws_http_connection_manager_new needs to be the last thing that can fail */
|
939
1134
|
stream_manager->connection_manager = aws_http_connection_manager_new(allocator, &cm_options);
|
@@ -950,7 +1145,8 @@ struct aws_http2_stream_manager *aws_http2_stream_manager_new(
|
|
950
1145
|
stream_manager->max_concurrent_streams_per_connection =
|
951
1146
|
options->max_concurrent_streams_per_connection ? options->max_concurrent_streams_per_connection : UINT32_MAX;
|
952
1147
|
stream_manager->max_connections = options->max_connections;
|
953
|
-
|
1148
|
+
stream_manager->close_connection_on_server_error = options->close_connection_on_server_error;
|
1149
|
+
|
954
1150
|
return stream_manager;
|
955
1151
|
on_error:
|
956
1152
|
s_stream_manager_destroy_final(stream_manager);
|
@@ -999,3 +1195,34 @@ void aws_http2_stream_manager_acquire_stream(
|
|
999
1195
|
} /* END CRITICAL SECTION */
|
1000
1196
|
s_aws_http2_stream_manager_execute_transaction(&work);
|
1001
1197
|
}
|
1198
|
+
|
1199
|
+
static size_t s_get_available_streams_num_from_connection_set(const struct aws_random_access_set *set) {
|
1200
|
+
size_t all_available_streams_num = 0;
|
1201
|
+
size_t ideal_connection_num = aws_random_access_set_get_size(set);
|
1202
|
+
for (size_t i = 0; i < ideal_connection_num; i++) {
|
1203
|
+
struct aws_h2_sm_connection *sm_connection = NULL;
|
1204
|
+
AWS_FATAL_ASSERT(aws_random_access_set_random_get_ptr_index(set, (void **)&sm_connection, i) == AWS_OP_SUCCESS);
|
1205
|
+
uint32_t available_streams = sm_connection->max_concurrent_streams - sm_connection->num_streams_assigned;
|
1206
|
+
all_available_streams_num += (size_t)available_streams;
|
1207
|
+
}
|
1208
|
+
return all_available_streams_num;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
void aws_http2_stream_manager_fetch_metrics(
|
1212
|
+
const struct aws_http2_stream_manager *stream_manager,
|
1213
|
+
struct aws_http_manager_metrics *out_metrics) {
|
1214
|
+
AWS_PRECONDITION(stream_manager);
|
1215
|
+
AWS_PRECONDITION(out_metrics);
|
1216
|
+
{ /* BEGIN CRITICAL SECTION */
|
1217
|
+
s_lock_synced_data((struct aws_http2_stream_manager *)(void *)stream_manager);
|
1218
|
+
size_t all_available_streams_num = 0;
|
1219
|
+
all_available_streams_num +=
|
1220
|
+
s_get_available_streams_num_from_connection_set(&stream_manager->synced_data.ideal_available_set);
|
1221
|
+
all_available_streams_num +=
|
1222
|
+
s_get_available_streams_num_from_connection_set(&stream_manager->synced_data.nonideal_available_set);
|
1223
|
+
out_metrics->pending_concurrency_acquires =
|
1224
|
+
stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_PENDING_ACQUISITION];
|
1225
|
+
out_metrics->available_concurrency = all_available_streams_num;
|
1226
|
+
s_unlock_synced_data((struct aws_http2_stream_manager *)(void *)stream_manager);
|
1227
|
+
} /* END CRITICAL SECTION */
|
1228
|
+
}
|
@@ -150,7 +150,7 @@ int aws_random_access_set_remove(struct aws_random_access_set *set, const void *
|
|
150
150
|
return AWS_OP_SUCCESS;
|
151
151
|
}
|
152
152
|
|
153
|
-
int aws_random_access_set_random_get_ptr(struct aws_random_access_set *set, void **out) {
|
153
|
+
int aws_random_access_set_random_get_ptr(const struct aws_random_access_set *set, void **out) {
|
154
154
|
AWS_PRECONDITION(set);
|
155
155
|
AWS_PRECONDITION(out != NULL);
|
156
156
|
size_t length = aws_array_list_length(&set->impl->list);
|
@@ -166,11 +166,11 @@ int aws_random_access_set_random_get_ptr(struct aws_random_access_set *set, void
|
|
166
166
|
return aws_array_list_get_at(&set->impl->list, (void *)out, index);
|
167
167
|
}
|
168
168
|
|
169
|
-
size_t aws_random_access_set_get_size(struct aws_random_access_set *set) {
|
169
|
+
size_t aws_random_access_set_get_size(const struct aws_random_access_set *set) {
|
170
170
|
return aws_array_list_length(&set->impl->list);
|
171
171
|
}
|
172
172
|
|
173
|
-
int aws_random_access_set_exist(struct aws_random_access_set *set, const void *element, bool *exist) {
|
173
|
+
int aws_random_access_set_exist(const struct aws_random_access_set *set, const void *element, bool *exist) {
|
174
174
|
AWS_PRECONDITION(set);
|
175
175
|
AWS_PRECONDITION(element);
|
176
176
|
AWS_PRECONDITION(exist);
|
@@ -179,3 +179,9 @@ int aws_random_access_set_exist(struct aws_random_access_set *set, const void *e
|
|
179
179
|
*exist = find != NULL;
|
180
180
|
return re;
|
181
181
|
}
|
182
|
+
|
183
|
+
int aws_random_access_set_random_get_ptr_index(const struct aws_random_access_set *set, void **out, size_t index) {
|
184
|
+
AWS_PRECONDITION(set);
|
185
|
+
AWS_PRECONDITION(out != NULL);
|
186
|
+
return aws_array_list_get_at(&set->impl->list, (void *)out, index);
|
187
|
+
}
|