aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--src/ranch_acceptors_sup.erl1
-rw-r--r--src/ranch_app.erl2
-rw-r--r--src/ranch_conns_sup.erl2
-rw-r--r--src/ranch_conns_sup_sup.erl2
-rw-r--r--src/ranch_embedded_sup.erl2
-rw-r--r--src/ranch_listener_sup.erl2
-rw-r--r--src/ranch_server.erl6
-rw-r--r--src/ranch_server_proxy.erl6
-rw-r--r--src/ranch_ssl.erl3
-rw-r--r--src/ranch_sup.erl1
-rw-r--r--src/ranch_tcp.erl3
12 files changed, 31 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 321f0ae..a1a6ff9 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,7 @@ endif
# Compile options.
+ERLC_OPTS += +warn_missing_spec +warn_untyped_record
TEST_ERLC_OPTS += +'{parse_transform, eunit_autoexport}'
# Dialyze the tests.
diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl
index 729dea8..e08c2ec 100644
--- a/src/ranch_acceptors_sup.erl
+++ b/src/ranch_acceptors_sup.erl
@@ -23,6 +23,7 @@
start_link(Ref, NumAcceptors, Transport) ->
supervisor:start_link(?MODULE, [Ref, NumAcceptors, Transport]).
+-spec init([term()]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init([Ref, NumAcceptors, Transport]) ->
TransOpts = ranch_server:get_transport_options(Ref),
Logger = maps:get(logger, TransOpts, logger),
diff --git a/src/ranch_app.erl b/src/ranch_app.erl
index 8ac470e..e65db48 100644
--- a/src/ranch_app.erl
+++ b/src/ranch_app.erl
@@ -19,10 +19,12 @@
-export([stop/1]).
-export([profile_output/0]).
+-spec start(application:start_type(), term()) -> {ok, pid()} | {error, term()}.
start(_, _) ->
_ = consider_profiling(),
ranch_sup:start_link().
+-spec stop(term()) -> ok.
stop(_) ->
ok.
diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl
index 9307878..a585e3f 100644
--- a/src/ranch_conns_sup.erl
+++ b/src/ranch_conns_sup.erl
@@ -306,6 +306,7 @@ wait_children(NbChildren) ->
ok
end.
+-spec system_continue(_, _, any()) -> no_return().
system_continue(_, _, {State, CurConns, NbChildren, Sleepers}) ->
loop(State, CurConns, NbChildren, Sleepers).
@@ -313,6 +314,7 @@ system_continue(_, _, {State, CurConns, NbChildren, Sleepers}) ->
system_terminate(Reason, _, _, {State, _, NbChildren, _}) ->
terminate(State, Reason, NbChildren).
+-spec system_code_change(any(), _, _, _) -> {ok, any()}.
system_code_change(Misc, _, _, _) ->
{ok, Misc}.
diff --git a/src/ranch_conns_sup_sup.erl b/src/ranch_conns_sup_sup.erl
index d9fc11d..4b1dd47 100644
--- a/src/ranch_conns_sup_sup.erl
+++ b/src/ranch_conns_sup_sup.erl
@@ -26,6 +26,8 @@ start_link(Ref, NumConnsSups, Transport, Protocol) ->
Ref, NumConnsSups, Transport, Protocol
}).
+-spec init({ranch:ref(), pos_integer(), module(), module()})
+ -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init({Ref, NumConnsSups, Transport, Protocol}) ->
ChildSpecs = [#{
id => {ranch_conns_sup, N},
diff --git a/src/ranch_embedded_sup.erl b/src/ranch_embedded_sup.erl
index aa157e0..ba5b46d 100644
--- a/src/ranch_embedded_sup.erl
+++ b/src/ranch_embedded_sup.erl
@@ -24,6 +24,8 @@
start_link(Ref, Transport, TransOpts, Protocol, ProtoOpts) ->
supervisor:start_link(?MODULE, {Ref, Transport, TransOpts, Protocol, ProtoOpts}).
+-spec init({ranch:ref(), module(), any(), module(), any()})
+ -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init({Ref, Transport, TransOpts, Protocol, ProtoOpts}) ->
Proxy = #{id => ranch_server_proxy,
start => {ranch_server_proxy, start_link, []},
diff --git a/src/ranch_listener_sup.erl b/src/ranch_listener_sup.erl
index 312b6fc..f4d8ebc 100644
--- a/src/ranch_listener_sup.erl
+++ b/src/ranch_listener_sup.erl
@@ -30,6 +30,8 @@ start_link(Ref, Transport, TransOpts, Protocol, ProtoOpts) ->
Ref, NumAcceptors, NumConnsSups, Transport, Protocol
}).
+-spec init({ranch:ref(), pos_integer(), pos_integer(), module(), module()})
+ -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init({Ref, NumAcceptors, NumConnsSups, Transport, Protocol}) ->
ok = ranch_server:set_listener_sup(Ref, self()),
ChildSpecs = [
diff --git a/src/ranch_server.erl b/src/ranch_server.erl
index 8433178..ae68e99 100644
--- a/src/ranch_server.erl
+++ b/src/ranch_server.erl
@@ -169,6 +169,7 @@ count_connections(Ref) ->
%% gen_server.
+-spec init([]) -> {ok, #state{}}.
init([]) ->
ConnMonitors = [{{erlang:monitor(process, Pid), Pid}, {conns_sup, Ref, Id}} ||
[Ref, Id, Pid] <- ets:match(?TAB, {{conns_sup, '$1', '$2'}, '$3'})],
@@ -176,6 +177,7 @@ init([]) ->
[Ref, Pid] <- ets:match(?TAB, {{listener_sup, '$1'}, '$2'})],
{ok, #state{monitors=ConnMonitors++ListenerMonitors}}.
+-spec handle_call(term(), {pid(), reference()}, #state{}) -> {reply, ok | ignore, #state{}}.
handle_call({set_new_listener_opts, Ref, MaxConns, TransOpts, ProtoOpts, StartArgs}, _, State) ->
ets:insert_new(?TAB, {{max_conns, Ref}, MaxConns}),
ets:insert_new(?TAB, {{trans_opts, Ref}, TransOpts}),
@@ -205,9 +207,11 @@ handle_call({set_proto_opts, Ref, Opts}, _, State) ->
handle_call(_Request, _From, State) ->
{reply, ignore, State}.
+-spec handle_cast(_, #state{}) -> {noreply, #state{}}.
handle_cast(_Request, State) ->
{noreply, State}.
+-spec handle_info(term(), #state{}) -> {noreply, #state{}}.
handle_info({'DOWN', MonitorRef, process, Pid, Reason},
State=#state{monitors=Monitors}) ->
{_, TypeRef} = lists:keyfind({MonitorRef, Pid}, 1, Monitors),
@@ -227,9 +231,11 @@ handle_info({'DOWN', MonitorRef, process, Pid, Reason},
handle_info(_Info, State) ->
{noreply, State}.
+-spec terminate(_, #state{}) -> ok.
terminate(_Reason, _State) ->
ok.
+-spec code_change(term() | {down, term()}, #state{}, term()) -> {ok, term()}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
diff --git a/src/ranch_server_proxy.erl b/src/ranch_server_proxy.erl
index 949ac33..b03b5bb 100644
--- a/src/ranch_server_proxy.erl
+++ b/src/ranch_server_proxy.erl
@@ -23,9 +23,11 @@
-export([handle_info/2]).
-export([code_change/3]).
+-spec start_link() -> {ok, pid()} | {error, term()}.
start_link() ->
gen_server:start_link(?MODULE, [], []).
+-spec init([]) -> {ok, pid()} | {stop, term()}.
init([]) ->
case wait_ranch_server(50) of
{ok, Monitor} ->
@@ -34,17 +36,21 @@ init([]) ->
{stop, Reason}
end.
+-spec handle_call(_, _, reference()) -> {noreply, reference(), hibernate}.
handle_call(_, _, Monitor) ->
{noreply, Monitor, hibernate}.
+-spec handle_cast(_, reference()) -> {noreply, reference(), hibernate}.
handle_cast(_, Monitor) ->
{noreply, Monitor, hibernate}.
+-spec handle_info(term(), reference()) -> {noreply, reference(), hibernate} | {stop, term(), reference()}.
handle_info({'DOWN', Monitor, process, _, Reason}, Monitor) ->
{stop, Reason, Monitor};
handle_info(_, Monitor) ->
{noreply, Monitor, hibernate}.
+-spec code_change(term() | {down, term()}, reference(), term()) -> {ok, reference()}.
code_change(_, Monitor, _) ->
{ok, Monitor}.
diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl
index cf876fe..b6ca50b 100644
--- a/src/ranch_ssl.erl
+++ b/src/ranch_ssl.erl
@@ -90,12 +90,14 @@
-type opts() :: [opt()].
-export_type([opts/0]).
+-spec name() -> ssl.
name() -> ssl.
-spec secure() -> boolean().
secure() ->
true.
+-spec messages() -> {ssl, ssl_closed, ssl_error, ssl_passive}.
messages() -> {ssl, ssl_closed, ssl_error, ssl_passive}.
-spec listen(ranch:transport_opts(opts())) -> {ok, ssl:sslsocket()} | {error, atom()}.
@@ -125,6 +127,7 @@ do_listen(SocketOpts0, Logger) ->
%% 'binary' and 'list' are disallowed but they are handled
%% specifically as they do not have 2-tuple equivalents.
+-spec disallowed_listen_options() -> [atom()].
disallowed_listen_options() ->
[alpn_advertised_protocols, client_preferred_next_protocols,
fallback, server_name_indication, srp_identity
diff --git a/src/ranch_sup.erl b/src/ranch_sup.erl
index 1d100db..64137a2 100644
--- a/src/ranch_sup.erl
+++ b/src/ranch_sup.erl
@@ -22,6 +22,7 @@
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+-spec init([]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init([]) ->
Intensity = case application:get_env(ranch_sup_intensity) of
{ok, Value1} -> Value1;
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl
index 3a6e4d9..3b4e4c3 100644
--- a/src/ranch_tcp.erl
+++ b/src/ranch_tcp.erl
@@ -70,12 +70,14 @@
-type opts() :: [opt()].
-export_type([opts/0]).
+-spec name() -> tcp.
name() -> tcp.
-spec secure() -> boolean().
secure() ->
false.
+-spec messages() -> {tcp, tcp_closed, tcp_error, tcp_passive}.
messages() -> {tcp, tcp_closed, tcp_error, tcp_passive}.
-spec listen(ranch:transport_opts(opts())) -> {ok, inet:socket()} | {error, atom()}.
@@ -94,6 +96,7 @@ listen(TransOpts) ->
%% 'binary' and 'list' are disallowed but they are handled
%% specifically as they do not have 2-tuple equivalents.
+-spec disallowed_listen_options() -> [atom()].
disallowed_listen_options() ->
[active, header, mode, packet, packet_size, line_delimiter, reuseaddr].