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

Change send_timeout_close test to accomodate macOS

This commit is contained in:
Loïc Hoguin 2023-12-13 17:24:48 +01:00
parent efb681d749
commit 67bd791dcc
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 28 additions and 21 deletions

View file

@ -556,19 +556,19 @@ send_timeout_close(_Config) ->
[ServerSocket] = [PidOrPort || PidOrPort <- ServerLinks, is_port(PidOrPort)],
%% Poll the socket repeatedly until it is closed by the server.
WaitClosedFun =
fun F(T, Status) when T =< 0 ->
error({status, Status});
F(T, _) ->
case prim_inet:getstatus(ServerSocket) of
fun F(T) when T =< 0 ->
error({status, prim_inet:getstatus(ServerSocket)});
F(T) ->
Snooze = 100,
case inet:sockname(ServerSocket) of
{error, _} ->
ok;
{ok, Status} ->
Snooze = 100,
timer:sleep(Snooze);
{ok, _} ->
timer:sleep(Snooze),
F(T - Snooze, Status)
F(T - Snooze)
end
end,
ok = WaitClosedFun(2000, undefined),
ok = WaitClosedFun(2000),
false = erlang:is_process_alive(StreamPid),
false = erlang:is_process_alive(ServerPid)
after