From 6d8b249e54c849948f6d4cdb021cb44340ec289f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 13 May 2019 10:30:26 +0200 Subject: Add the passive messages to ranch_transport:messages/0 --- doc/src/manual/ranch_transport.asciidoc | 9 ++++++--- src/ranch_ssl.erl | 2 +- src/ranch_tcp.erl | 2 +- src/ranch_transport.erl | 2 +- test/active_echo_protocol.erl | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/src/manual/ranch_transport.asciidoc b/doc/src/manual/ranch_transport.asciidoc index 50c0b0a..b7ec6d2 100644 --- a/doc/src/manual/ranch_transport.asciidoc +++ b/doc/src/manual/ranch_transport.asciidoc @@ -115,9 +115,10 @@ means a random available port number will be chosen. [source,erlang] ---- messages() - -> {OK :: atom(), - Closed :: atom(), - Error :: atom()} + -> {OK :: atom(), + Closed :: atom(), + Error :: atom(), + Passive :: atom()} ---- Return the tuple keys for the messages sent by the socket. @@ -284,6 +285,8 @@ The exact type will vary depending on the transport module. == Changelog +* *2.0*: The callback `messages/0` return value was updated to + include the passive message for `{active, N}`. * *1.6*: The `socket()` type was added for documentation purposes. * *1.6*: The type of the sendfile filename was extended. diff --git a/src/ranch_ssl.erl b/src/ranch_ssl.erl index 2b246f7..8dc808d 100644 --- a/src/ranch_ssl.erl +++ b/src/ranch_ssl.erl @@ -89,7 +89,7 @@ name() -> ssl. secure() -> true. -messages() -> {ssl, ssl_closed, ssl_error}. +messages() -> {ssl, ssl_closed, ssl_error, ssl_passive}. -spec listen(opts()) -> {ok, ssl:sslsocket()} | {error, atom()}. listen(Opts) -> diff --git a/src/ranch_tcp.erl b/src/ranch_tcp.erl index 129202d..0fa06d1 100644 --- a/src/ranch_tcp.erl +++ b/src/ranch_tcp.erl @@ -76,7 +76,7 @@ name() -> tcp. secure() -> false. -messages() -> {tcp, tcp_closed, tcp_error}. +messages() -> {tcp, tcp_closed, tcp_error, tcp_passive}. -spec listen(opts()) -> {ok, inet:socket()} | {error, atom()}. listen(Opts) -> diff --git a/src/ranch_transport.erl b/src/ranch_transport.erl index 486c6d6..c968868 100644 --- a/src/ranch_transport.erl +++ b/src/ranch_transport.erl @@ -26,7 +26,7 @@ -callback name() -> atom(). -callback secure() -> boolean(). --callback messages() -> {OK::atom(), Closed::atom(), Error::atom()}. +-callback messages() -> {OK::atom(), Closed::atom(), Error::atom(), Passive::atom()}. -callback listen(opts()) -> {ok, socket()} | {error, atom()}. -callback accept(socket(), timeout()) -> {ok, socket()} | {error, closed | timeout | atom()}. diff --git a/test/active_echo_protocol.erl b/test/active_echo_protocol.erl index 3c3ab0d..6ae47a6 100644 --- a/test/active_echo_protocol.erl +++ b/test/active_echo_protocol.erl @@ -13,7 +13,7 @@ init(Ref, Transport, _Opts = []) -> loop(Socket, Transport). loop(Socket, Transport) -> - {OK, Closed, Error} = Transport:messages(), + {OK, Closed, Error, _Passive} = Transport:messages(), Transport:setopts(Socket, [{active, once}]), receive {OK, Socket, Data} -> -- cgit v1.2.3