From b400e34386ec0dc3f290da6c4671d7d0621d2fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Jul 2018 10:57:05 +0200 Subject: Better distinguish between Ranch and socket options A map should now be used when specifying transport options that contain more than just socket options. It is still possible to pass a list of socket options directly as a convenience. The ack_timeout is renamed to handshake_timeout when specified as a map. This corresponds to the new function ranch:handshake/1,2 that will be favored in Ranch 2.0. Specifying Ranch-specific options via the proplist will no longer be possible starting from Ranch 2.0. --- src/ranch_conns_sup.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ranch_conns_sup.erl') diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl index 72de2d7..ddf9a20 100644 --- a/src/ranch_conns_sup.erl +++ b/src/ranch_conns_sup.erl @@ -39,7 +39,7 @@ transport = undefined :: module(), protocol = undefined :: module(), opts :: any(), - ack_timeout :: timeout(), + handshake_timeout :: timeout(), max_conns = undefined :: ranch:max_conns() }). @@ -99,14 +99,14 @@ init(Parent, Ref, Transport, Protocol) -> ok = ranch_server:set_connections_sup(Ref, self()), MaxConns = ranch_server:get_max_connections(Ref), TransOpts = ranch_server:get_transport_options(Ref), - ConnType = proplists:get_value(connection_type, TransOpts, worker), - Shutdown = proplists:get_value(shutdown, TransOpts, 5000), - AckTimeout = proplists:get_value(ack_timeout, TransOpts, 5000), + ConnType = maps:get(connection_type, TransOpts, worker), + Shutdown = maps:get(shutdown, TransOpts, 5000), + HandshakeTimeout = maps:get(handshake_timeout, TransOpts, 5000), ProtoOpts = ranch_server:get_protocol_options(Ref), ok = proc_lib:init_ack(Parent, {ok, self()}), loop(#state{parent=Parent, ref=Ref, conn_type=ConnType, shutdown=Shutdown, transport=Transport, protocol=Protocol, - opts=ProtoOpts, ack_timeout=AckTimeout, max_conns=MaxConns}, 0, 0, []). + opts=ProtoOpts, handshake_timeout=HandshakeTimeout, max_conns=MaxConns}, 0, 0, []). loop(State=#state{parent=Parent, ref=Ref, conn_type=ConnType, transport=Transport, protocol=Protocol, opts=Opts, @@ -219,11 +219,11 @@ loop(State=#state{parent=Parent, ref=Ref, conn_type=ConnType, loop(State, CurConns, NbChildren, Sleepers) end. -handshake(State=#state{ref=Ref, transport=Transport, ack_timeout=AckTimeout, max_conns=MaxConns}, - CurConns, NbChildren, Sleepers, To, Socket, SupPid, ProtocolPid) -> +handshake(State=#state{ref=Ref, transport=Transport, handshake_timeout=HandshakeTimeout, + max_conns=MaxConns}, CurConns, NbChildren, Sleepers, To, Socket, SupPid, ProtocolPid) -> case Transport:controlling_process(Socket, ProtocolPid) of ok -> - ProtocolPid ! {handshake, Ref, Transport, Socket, AckTimeout}, + ProtocolPid ! {handshake, Ref, Transport, Socket, HandshakeTimeout}, put(SupPid, active), CurConns2 = CurConns + 1, if CurConns2 < MaxConns -> -- cgit v1.2.3