From e9b8b7a7e7115184c2273b4a376d8f76cacba8e5 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Fri, 19 May 2023 10:41:04 -0600 Subject: [PATCH 1/2] Fix set_default_connection_limit not being respected With all the default global connection pool shuffling that has happened, we missed making sure `set_default_connection_limit!` was still being respected. It was updating the global connection limit ref, but the global pools were still stuck with whatever their values were when first initialized. This PR reinitializes the global connection pools when the default connection pool limit is changed. --- src/Connections.jl | 9 ++++++++- test/client.jl | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Connections.jl b/src/Connections.jl index b48214c12..7829c50bd 100644 --- a/src/Connections.jl +++ b/src/Connections.jl @@ -45,7 +45,14 @@ function __init__() return end -set_default_connection_limit!(n) = default_connection_limit[] = n +function set_default_connection_limit!(n) + default_connection_limit[] = n + # reinitialize the global connection pools + TCP_POOL[] = CPool{Sockets.TCPSocket}(n) + MBEDTLS_POOL[] = CPool{MbedTLS.SSLContext}(n) + OPENSSL_POOL[] = CPool{OpenSSL.SSLStream}(n) + return +end """ Connection diff --git a/test/client.jl b/test/client.jl index 5ccd69e97..72df78ca6 100644 --- a/test/client.jl +++ b/test/client.jl @@ -13,6 +13,7 @@ using InteractiveUtils: @which # test we can adjust default_connection_limit HTTP.set_default_connection_limit!(12) +@test HTTP.Connections.TCP_POOL[].max == 12 @testset "@client macro" begin @eval module MyClient From ad18bcc12c6385fc824c97427c75b377bad9ac34 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Fri, 19 May 2023 10:53:56 -0600 Subject: [PATCH 2/2] Update test/client.jl Co-authored-by: Nick Robinson --- test/client.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/client.jl b/test/client.jl index 72df78ca6..4c12f9c64 100644 --- a/test/client.jl +++ b/test/client.jl @@ -12,8 +12,12 @@ using URIs using InteractiveUtils: @which # test we can adjust default_connection_limit -HTTP.set_default_connection_limit!(12) -@test HTTP.Connections.TCP_POOL[].max == 12 +for x in (10, 12) + HTTP.set_default_connection_limit!(x) + @test HTTP.Connections.TCP_POOL[].max == x + @test HTTP.Connections.MBEDTLS_POOL[].max == x + @test HTTP.Connections.OPENSSL_POOL[].max == x +end @testset "@client macro" begin @eval module MyClient