diff options
author | Loïc Hoguin <[email protected]> | 2023-06-05 10:52:07 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2023-06-05 10:54:02 +0200 |
commit | 48eefebff2d0412bf6fe8a53182ef88a443b293f (patch) | |
tree | dfe1b7942e2b3654be30de374d25db6e646d0c63 /test/gun_test.erl | |
parent | db0655def7d113f5aa168a1653df5d62245d3502 (diff) | |
download | gun-48eefebff2d0412bf6fe8a53182ef88a443b293f.tar.gz gun-48eefebff2d0412bf6fe8a53182ef88a443b293f.tar.bz2 gun-48eefebff2d0412bf6fe8a53182ef88a443b293f.zip |
Fix crash when TLS connection closes very early
And ensure that we don't infinite loop when retries are
enabled, by decrementing the retry count instead of using
a new one.
Also check for ssl:negotiated_protocol {error,closed}
which was possible but was not documented in OTP before
this change.
Thanks @voluntas for the help.
Diffstat (limited to 'test/gun_test.erl')
-rw-r--r-- | test/gun_test.erl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/gun_test.erl b/test/gun_test.erl index 5142898..18fcfbf 100644 --- a/test/gun_test.erl +++ b/test/gun_test.erl @@ -33,7 +33,7 @@ init_origin(Transport) -> init_origin(Transport, http). init_origin(Transport, Protocol) -> - init_origin(Transport, Protocol, fun loop_origin/3). + init_origin(Transport, Protocol, fun loop_origin/4). init_origin(Transport, Protocol, Fun) -> Pid = spawn_link(?MODULE, init_origin, [self(), Transport, Protocol, Fun]), @@ -55,7 +55,7 @@ init_origin(Parent, Transport, Protocol, Fun) _ -> ok end, Parent ! {self(), handshake_completed}, - Fun(Parent, ClientSocket, gen_tcp); + Fun(Parent, ListenSocket, ClientSocket, gen_tcp); init_origin(Parent, tls, Protocol, Fun) -> Opts0 = ct_helper:get_certs_from_ets(), Opts1 = case Protocol of @@ -77,7 +77,7 @@ init_origin(Parent, tls, Protocol, Fun) -> ok end, Parent ! {self(), handshake_completed}, - Fun(Parent, ClientSocket, ssl). + Fun(Parent, ListenSocket, ClientSocket, ssl). http2_handshake(Socket, Transport) -> %% Send a valid preface. @@ -96,11 +96,11 @@ http2_handshake(Socket, Transport) -> {ok, <<0:24, 4:8, 1:8, 0:32>>} = Transport:recv(Socket, 9, 5000), ok. -loop_origin(Parent, ClientSocket, ClientTransport) -> +loop_origin(Parent, ListenSocket, ClientSocket, ClientTransport) -> case ClientTransport:recv(ClientSocket, 0, 5000) of {ok, Data} -> Parent ! {self(), Data}, - loop_origin(Parent, ClientSocket, ClientTransport); + loop_origin(Parent, ListenSocket, ClientSocket, ClientTransport); {error, closed} -> ok end. |