mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Correctly detect cowboy_tls process
This commit is contained in:
parent
20cf68e2b7
commit
150cde970b
2 changed files with 16 additions and 8 deletions
|
@ -21,21 +21,21 @@
|
|||
%% Listeners initialization.
|
||||
|
||||
init_http(Ref, ProtoOpts, Config) ->
|
||||
{ok, _} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
|
||||
{ok, Pid} = cowboy:start_clear(Ref, [{port, 0}], ProtoOpts),
|
||||
Port = ranch:get_port(Ref),
|
||||
[{ref, Ref}, {type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config].
|
||||
[{supervisor, Pid}, {ref, Ref}, {type, tcp}, {protocol, http}, {port, Port}, {opts, []}|Config].
|
||||
|
||||
init_https(Ref, ProtoOpts, Config) ->
|
||||
Opts = ct_helper:get_certs_from_ets(),
|
||||
{ok, _} = cowboy:start_tls(Ref, Opts ++ [{port, 0}, {verify, verify_none}], ProtoOpts),
|
||||
{ok, Pid} = cowboy:start_tls(Ref, Opts ++ [{port, 0}, {verify, verify_none}], ProtoOpts),
|
||||
Port = ranch:get_port(Ref),
|
||||
[{ref, Ref}, {type, ssl}, {protocol, http}, {port, Port}, {opts, Opts}|Config].
|
||||
[{supervisor, Pid}, {ref, Ref}, {type, ssl}, {protocol, http}, {port, Port}, {opts, Opts}|Config].
|
||||
|
||||
init_http2(Ref, ProtoOpts, Config) ->
|
||||
Opts = ct_helper:get_certs_from_ets(),
|
||||
{ok, _} = cowboy:start_tls(Ref, Opts ++ [{port, 0}, {verify, verify_none}], ProtoOpts),
|
||||
{ok, Pid} = cowboy:start_tls(Ref, Opts ++ [{port, 0}, {verify, verify_none}], ProtoOpts),
|
||||
Port = ranch:get_port(Ref),
|
||||
[{ref, Ref}, {type, ssl}, {protocol, http2}, {port, Port}, {opts, Opts}|Config].
|
||||
[{supervisor, Pid}, {ref, Ref}, {type, ssl}, {protocol, http2}, {port, Port}, {opts, Opts}|Config].
|
||||
|
||||
%% Common group of listeners used by most suites.
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ fail_gracefully_on_disconnect(Config) ->
|
|||
doc("Probing a port does not generate a crash"),
|
||||
{ok, Socket} = gen_tcp:connect("localhost", config(port, Config),
|
||||
[binary, {active, false}, {packet, raw}]),
|
||||
timer:sleep(100),
|
||||
Pid = ct_helper:get_remote_pid_tcp(Socket),
|
||||
timer:sleep(50),
|
||||
Pid = do_get_sockets_pid(Config, Socket, config(type, Config)),
|
||||
Ref = erlang:monitor(process, Pid),
|
||||
gen_tcp:close(Socket),
|
||||
receive
|
||||
|
@ -255,3 +255,11 @@ do_recv_101(Client) ->
|
|||
"\r\n"
|
||||
>>} = raw_recv(Client, 71, 1000),
|
||||
ok.
|
||||
|
||||
do_get_sockets_pid(_Config, Socket, tcp) ->
|
||||
ct_helper:get_remote_pid_tcp(Socket);
|
||||
do_get_sockets_pid(Config, _Socket, ssl) ->
|
||||
Sup = config(supervisor, Config),
|
||||
{_, RanchConns, _, _} = lists:keyfind(ranch_conns_sup, 1, supervisor:which_children(Sup)),
|
||||
{_, CowboyTls, _, _} = lists:keyfind(cowboy_tls, 1, supervisor:which_children(RanchConns)),
|
||||
CowboyTls.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue