0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Explicitly close the socket in some tests for speed ups

The socket staying open meant that the graceful shut down
of the Cowboy listeners were waiting for the connections
to be closed gracefully (or a timeout). Closing explicitly
where it makes sense ensures we don't unnecessarily wait.

This commit removes a full minute in the run time of all
Cowboy test suites (minus examples).
This commit is contained in:
Loïc Hoguin 2023-12-18 18:11:10 +01:00
parent 2558ba65ad
commit 627a4508b5
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
5 changed files with 51 additions and 21 deletions

View file

@ -1374,7 +1374,8 @@ max_frame_size_allow_exactly_custom(Config0) ->
{ok, << Len2:24, 1:8, _:40 >>} = gen_tcp:recv(Socket, 9, 6000),
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000)
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
gen_tcp:close(Socket)
after
cowboy:stop_listener(?FUNCTION_NAME)
end.
@ -2742,7 +2743,8 @@ settings_initial_window_size(Config0) ->
{ok, << Len2:24, 1:8, _:40 >>} = gen_tcp:recv(Socket, 9, 6000),
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 65535 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000)
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
gen_tcp:close(Socket)
after
cowboy:stop_listener(?FUNCTION_NAME)
end.
@ -2833,7 +2835,8 @@ settings_initial_window_size_before_ack(Config0) ->
{ok, << Len2:24, 1:8, _:40 >>} = gen_tcp:recv(Socket, 9, 6000),
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of more than 0 bytes of data.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000)
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
gen_tcp:close(Socket)
after
cowboy:stop_listener(?FUNCTION_NAME)
end.
@ -2866,7 +2869,8 @@ settings_max_frame_size(Config0) ->
{ok, << Len2:24, 1:8, _:40 >>} = gen_tcp:recv(Socket, 9, 6000),
{ok, _} = gen_tcp:recv(Socket, Len2, 6000),
%% No errors follow due to our sending of a 25000 bytes frame.
{error, timeout} = gen_tcp:recv(Socket, 0, 1000)
{error, timeout} = gen_tcp:recv(Socket, 0, 1000),
gen_tcp:close(Socket)
after
cowboy:stop_listener(?FUNCTION_NAME)
end.