aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorj.uhlig <[email protected]>2018-05-03 15:38:46 +0200
committerLoïc Hoguin <[email protected]>2019-04-29 14:39:20 +0200
commit7cbc7fed32940a4aa7beedec9cac23376a19a8c0 (patch)
tree0cbab7739b16681188096491d27562ecd4f2b03e /src
parentdabf62792c2af08c4c6d36177546695356c33b3a (diff)
downloadranch-7cbc7fed32940a4aa7beedec9cac23376a19a8c0.tar.gz
ranch-7cbc7fed32940a4aa7beedec9cac23376a19a8c0.tar.bz2
ranch-7cbc7fed32940a4aa7beedec9cac23376a19a8c0.zip
Remove socket option
Diffstat (limited to 'src')
-rw-r--r--src/ranch.erl26
-rw-r--r--src/ranch_acceptors_sup.erl29
2 files changed, 16 insertions, 39 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index 814e928..33a8256 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -56,8 +56,7 @@
| {connection_type, worker | supervisor}
| {max_connections, max_conns()}
| {num_acceptors, pos_integer()}
- | {shutdown, timeout() | brutal_kill}
- | {socket, any()}.
+ | {shutdown, timeout() | brutal_kill}.
-export_type([opt/0]).
-type opts() :: any() | #{
@@ -67,7 +66,6 @@
logger => module(),
num_acceptors => pos_integer(),
shutdown => timeout() | brutal_kill,
- socket => any(),
socket_opts => any()
}.
-export_type([opts/0]).
@@ -85,24 +83,8 @@ start_listener(Ref, Transport, TransOpts0, Protocol, ProtoOpts)
false ->
{error, badarg};
true ->
- Res = supervisor:start_child(ranch_sup, child_spec(Ref,
- Transport, TransOpts, Protocol, ProtoOpts)),
- Socket = maps:get(socket, TransOpts, undefined),
- case Res of
- {ok, Pid} when Socket =/= undefined ->
- %% Give ownership of the socket to ranch_acceptors_sup
- %% to make sure the socket stays open as long as the
- %% listener is alive. If the socket closes however there
- %% will be no way to recover because we don't know how
- %% to open it again.
- Children = supervisor:which_children(Pid),
- {_, AcceptorsSup, _, _}
- = lists:keyfind(ranch_acceptors_sup, 1, Children),
- Transport:controlling_process(Socket, AcceptorsSup);
- _ ->
- ok
- end,
- maybe_started(Res)
+ maybe_started(supervisor:start_child(ranch_sup, child_spec(Ref,
+ Transport, TransOpts, Protocol, ProtoOpts)))
end.
-spec start_listener(ref(), non_neg_integer(), module(), opts(), module(), any())
@@ -131,7 +113,7 @@ normalize_opts(List0) when is_list(List0) ->
false ->
{Map2, List2}
end
- end, {Map1, List1}, [connection_type, max_connections, num_acceptors, shutdown, socket]),
+ end, {Map1, List1}, [connection_type, max_connections, num_acceptors, shutdown]),
if
Map =:= #{} ->
ok;
diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl
index 73dc9ea..cdb633b 100644
--- a/src/ranch_acceptors_sup.erl
+++ b/src/ranch_acceptors_sup.erl
@@ -28,23 +28,18 @@ init([Ref, Transport]) ->
TransOpts = ranch_server:get_transport_options(Ref),
NumAcceptors = maps:get(num_acceptors, TransOpts, 10),
Logger = maps:get(logger, TransOpts, error_logger),
- LSocket = case maps:get(socket, TransOpts, undefined) of
- undefined ->
- SocketOpts = maps:get(socket_opts, TransOpts, []),
- %% We temporarily put the logger in the process dictionary
- %% so that it can be used from ranch:filter_options. The
- %% interface as it currently is does not allow passing it
- %% down otherwise.
- put(logger, Logger),
- case Transport:listen(SocketOpts) of
- {ok, Socket} ->
- erase(logger),
- Socket;
- {error, Reason} ->
- listen_error(Ref, Transport, SocketOpts, Reason, Logger)
- end;
- Socket ->
- Socket
+ SocketOpts = maps:get(socket_opts, TransOpts, []),
+ %% We temporarily put the logger in the process dictionary
+ %% so that it can be used from ranch:filter_options. The
+ %% interface as it currently is does not allow passing it
+ %% down otherwise.
+ put(logger, Logger),
+ LSocket = case Transport:listen(SocketOpts) of
+ {ok, Socket} ->
+ erase(logger),
+ Socket;
+ {error, Reason} ->
+ listen_error(Ref, Transport, SocketOpts, Reason, Logger)
end,
{ok, Addr} = Transport:sockname(LSocket),
ranch_server:set_addr(Ref, Addr),