aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-08-17 18:18:07 +0200
committerLoïc Hoguin <[email protected]>2015-08-17 18:51:55 +0200
commitd440a2c1d26e4f0770a66279de151806b1ad5ac2 (patch)
tree774bbcf04a147e10284454a05aa8daecf04d3ec2
parentf5f480c5750b76b662430b62ef85ebceea5aadc6 (diff)
downloadranch-d440a2c1d26e4f0770a66279de151806b1ad5ac2.tar.gz
ranch-d440a2c1d26e4f0770a66279de151806b1ad5ac2.tar.bz2
ranch-d440a2c1d26e4f0770a66279de151806b1ad5ac2.zip
Don't pass Ranch-specific options down to transports
Should fix Dialyzer issues. The options are now also documented in the Ranch module, and there's new ranch:opt(), ranch_tcp:opt() and ranch_ssl:opt() for use in third party code.
-rw-r--r--manual/ranch.md11
-rw-r--r--manual/ranch_ssl.md8
-rw-r--r--manual/ranch_tcp.md8
-rw-r--r--src/ranch.erl7
-rw-r--r--src/ranch_acceptors_sup.erl7
-rw-r--r--src/ranch_ssl.erl7
-rw-r--r--src/ranch_tcp.erl7
7 files changed, 46 insertions, 9 deletions
diff --git a/manual/ranch.md b/manual/ranch.md
index cf4ebe5..52c792e 100644
--- a/manual/ranch.md
+++ b/manual/ranch.md
@@ -17,6 +17,17 @@ Types
> also be removed from this count explicitly by the user
> code.
+### opt() = {ack_timeout, timeout()}
+ | {connection_type, worker | supervisor}
+ | {max_connections, max_conns()}
+ | {shutdown, timeout() | brutal_kill}
+ | {socket, any()}
+
+> Ranch-specific transport options.
+>
+> These options are not passed on to the transports.
+> They are used by Ranch while setting up the listeners.
+
### ref() = any()
> Unique name used to refer to a listener.
diff --git a/manual/ranch_ssl.md b/manual/ranch_ssl.md
index af271a5..e8a41ec 100644
--- a/manual/ranch_ssl.md
+++ b/manual/ranch_ssl.md
@@ -6,7 +6,7 @@ The `ranch_ssl` module implements an SSL Ranch transport.
Types
-----
-### opts() = [{backlog, non_neg_integer()}
+### opt() = {backlog, non_neg_integer()}
| {cacertfile, string()}
| {cacerts, [Der::binary()]}
| {cert, Der::binary()}
@@ -32,7 +32,7 @@ Types
| {send_timeout_close, boolean()}
| {verify, ssl:verify_type()}
| {verify_fun, {fun(), InitialUserState::term()}},
- | {versions, [atom()]}].
+ | {versions, [atom()]}
> Listen options.
>
@@ -40,6 +40,10 @@ Types
> be set on the socket, but only the options that should be
> set independently of protocol implementation.
+### opts() = [opt()]
+
+> Listen options.
+
Option descriptions
-------------------
diff --git a/manual/ranch_tcp.md b/manual/ranch_tcp.md
index 0e27e11..2967392 100644
--- a/manual/ranch_tcp.md
+++ b/manual/ranch_tcp.md
@@ -11,14 +11,14 @@ the threads stuck indefinitely.
Types
-----
-### opts() = [{backlog, non_neg_integer()}
+### opt() = {backlog, non_neg_integer()}
| {ip, inet:ip_address()}
| {linger, {boolean(), non_neg_integer()}}
| {nodelay, boolean()}
| {port, inet:port_number()}
| {raw, non_neg_integer(), non_neg_integer(), non_neg_integer() | binary()}
| {send_timeout, timeout()}
- | {send_timeout_close, boolean()}]
+ | {send_timeout_close, boolean()}
> Listen options.
>
@@ -26,6 +26,10 @@ Types
> be set on the socket, but only the options that should be
> set independently of protocol implementation.
+### opts() = [opt()]
+
+> Listen options.
+
Option descriptions
-------------------
diff --git a/src/ranch.erl b/src/ranch.erl
index 087d032..fc9bad3 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -31,6 +31,13 @@
-type max_conns() :: non_neg_integer() | infinity.
-export_type([max_conns/0]).
+-type opt() :: {ack_timeout, timeout()}
+ | {connection_type, worker | supervisor}
+ | {max_connections, max_conns()}
+ | {shutdown, timeout() | brutal_kill}
+ | {socket, any()}.
+-export_type([opt/0]).
+
-type ref() :: any().
-export_type([ref/0]).
diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl
index 51b0129..b8c82df 100644
--- a/src/ranch_acceptors_sup.erl
+++ b/src/ranch_acceptors_sup.erl
@@ -27,7 +27,12 @@ init([Ref, NbAcceptors, Transport, TransOpts]) ->
ConnsSup = ranch_server:get_connections_sup(Ref),
LSocket = case proplists:get_value(socket, TransOpts) of
undefined ->
- {ok, Socket} = Transport:listen(TransOpts),
+ TransOpts2 = proplists:delete(ack_timeout,
+ proplists:delete(connection_type,
+ proplists:delete(max_connections,
+ proplists:delete(shutdown,
+ proplists:delete(socket, TransOpts))))),
+ {ok, Socket} = Transport:listen(TransOpts2),
Socket;
Socket ->
Socket
diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl
index a353c97..acfe38d 100644
--- a/src/ranch_ssl.erl
+++ b/src/ranch_ssl.erl
@@ -35,7 +35,7 @@
-export([shutdown/2]).
-export([close/1]).
--type opts() :: [{backlog, non_neg_integer()}
+-type opt() :: {backlog, non_neg_integer()}
| {cacertfile, string()}
| {cacerts, [Der::binary()]}
| {cert, Der::binary()}
@@ -64,7 +64,10 @@
| {send_timeout_close, boolean()}
| {verify, ssl:verify_type()}
| {verify_fun, {fun(), InitialUserState::term()}}
- | {versions, [atom()]}].
+ | {versions, [atom()]}.
+-export_type([opt/0]).
+
+-type opts() :: [opt()].
-export_type([opts/0]).
name() -> ssl.
diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl
index e3bcf81..51b10ba 100644
--- a/src/ranch_tcp.erl
+++ b/src/ranch_tcp.erl
@@ -35,7 +35,7 @@
-export([shutdown/2]).
-export([close/1]).
--type opts() :: [{backlog, non_neg_integer()}
+-type opt() :: {backlog, non_neg_integer()}
| {ip, inet:ip_address()}
| {linger, {boolean(), non_neg_integer()}}
| {nodelay, boolean()}
@@ -43,7 +43,10 @@
| {raw, non_neg_integer(), non_neg_integer(),
non_neg_integer() | binary()}
| {send_timeout, timeout()}
- | {send_timeout_close, boolean()}].
+ | {send_timeout_close, boolean()}.
+-export_type([opt/0]).
+
+-type opts() :: [opt()].
-export_type([opts/0]).
name() -> tcp.