From 3ea575d8682560fc02d5583cbf2837e2f2f43e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 9 May 2019 10:43:25 +0200 Subject: Remove Socket argument from ranch_protocol:start_link --- test/active_echo_protocol.erl | 4 ++-- test/check_tcp_options.erl | 13 +++++++------ test/echo_protocol.erl | 4 ++-- test/notify_and_wait_protocol.erl | 4 ++-- test/proxy_protocol.erl | 4 ++-- test/remove_conn_and_wait_protocol.erl | 4 ++-- test/ssl_upgrade_protocol.erl | 4 ++-- test/supervisor_separate.erl | 6 +++--- test/transport_capabilities_protocol.erl | 4 ++-- test/trap_exit_protocol.erl | 4 ++-- 10 files changed, 26 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/active_echo_protocol.erl b/test/active_echo_protocol.erl index 37dd6db..3c3ab0d 100644 --- a/test/active_echo_protocol.erl +++ b/test/active_echo_protocol.erl @@ -1,10 +1,10 @@ -module(active_echo_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. diff --git a/test/check_tcp_options.erl b/test/check_tcp_options.erl index 18432ac..ecafef7 100644 --- a/test/check_tcp_options.erl +++ b/test/check_tcp_options.erl @@ -1,15 +1,16 @@ -module(check_tcp_options). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(_, Socket, _, [{pid, TestPid}|TcpOptions]) -> - {ok, RealTcpOptions} = - inet:getopts(Socket, [Key || {Key, _} <- TcpOptions]), - Pid = spawn_link(?MODULE, init, [TestPid, RealTcpOptions, TcpOptions]), +start_link(Ref, _, [{pid, TestPid}|TcpOptions]) -> + Pid = spawn_link(?MODULE, init, [Ref, TestPid, TcpOptions]), {ok, Pid}. -init(Pid, TcpOptions, TcpOptions) -> +init(Ref, Pid, TcpOptions) -> + {ok, Socket} = ranch:handshake(Ref), + {ok, RealTcpOptions} = inet:getopts(Socket, [Key || {Key, _} <- TcpOptions]), + true = TcpOptions =:= RealTcpOptions, Pid ! checked, receive after 2500 -> ok end. diff --git a/test/echo_protocol.erl b/test/echo_protocol.erl index 640f5c6..7bcf15a 100644 --- a/test/echo_protocol.erl +++ b/test/echo_protocol.erl @@ -1,10 +1,10 @@ -module(echo_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. diff --git a/test/notify_and_wait_protocol.erl b/test/notify_and_wait_protocol.erl index f0136a1..e3e857b 100644 --- a/test/notify_and_wait_protocol.erl +++ b/test/notify_and_wait_protocol.erl @@ -1,10 +1,10 @@ -module(notify_and_wait_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/2]). -start_link(_, _, _, [{msg, Msg}, {pid, TestPid}]) -> +start_link(_, _, [{msg, Msg}, {pid, TestPid}]) -> Pid = spawn_link(?MODULE, init, [Msg, TestPid]), {ok, Pid}. diff --git a/test/proxy_protocol.erl b/test/proxy_protocol.erl index 9c679e3..88eb9ff 100644 --- a/test/proxy_protocol.erl +++ b/test/proxy_protocol.erl @@ -1,10 +1,10 @@ -module(proxy_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. diff --git a/test/remove_conn_and_wait_protocol.erl b/test/remove_conn_and_wait_protocol.erl index caac41e..abb4281 100644 --- a/test/remove_conn_and_wait_protocol.erl +++ b/test/remove_conn_and_wait_protocol.erl @@ -1,10 +1,10 @@ -module(remove_conn_and_wait_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _, _, [{remove, MaybeRemove, Timeout}]) -> +start_link(Ref, _, [{remove, MaybeRemove, Timeout}]) -> Pid = spawn_link(?MODULE, init, [Ref, MaybeRemove, Timeout]), {ok, Pid}. diff --git a/test/ssl_upgrade_protocol.erl b/test/ssl_upgrade_protocol.erl index cafbe13..67aec2b 100644 --- a/test/ssl_upgrade_protocol.erl +++ b/test/ssl_upgrade_protocol.erl @@ -1,10 +1,10 @@ -module(ssl_upgrade_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. diff --git a/test/supervisor_separate.erl b/test/supervisor_separate.erl index 5f1f326..f96c7e4 100644 --- a/test/supervisor_separate.erl +++ b/test/supervisor_separate.erl @@ -2,13 +2,13 @@ -behavior(supervisor). -behavior(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/1]). -start_link(Ref, Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> {ok, SupPid} = supervisor:start_link(?MODULE, []), {ok, ConnPid} = supervisor:start_child(SupPid, - {echo_protocol, {echo_protocol, start_link, [Ref, Socket, Transport, Opts]}, + {echo_protocol, {echo_protocol, start_link, [Ref, Transport, Opts]}, temporary, 5000, worker, [echo_protocol]}), {ok, SupPid, ConnPid}. diff --git a/test/transport_capabilities_protocol.erl b/test/transport_capabilities_protocol.erl index ba5024a..5f23d39 100644 --- a/test/transport_capabilities_protocol.erl +++ b/test/transport_capabilities_protocol.erl @@ -1,10 +1,10 @@ -module(transport_capabilities_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. diff --git a/test/trap_exit_protocol.erl b/test/trap_exit_protocol.erl index 6100075..da71fb4 100644 --- a/test/trap_exit_protocol.erl +++ b/test/trap_exit_protocol.erl @@ -1,10 +1,10 @@ -module(trap_exit_protocol). -behaviour(ranch_protocol). --export([start_link/4]). +-export([start_link/3]). -export([init/3]). -start_link(Ref, _Socket, Transport, Opts) -> +start_link(Ref, Transport, Opts) -> Pid = spawn_link(?MODULE, init, [Ref, Transport, Opts]), {ok, Pid}. -- cgit v1.2.3