aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-04-16 13:59:30 +0200
committerLoïc Hoguin <[email protected]>2011-04-16 13:59:30 +0200
commit8f818d79dfe22af8a4a557c1e8676463224b9c22 (patch)
treeedc60a719bb1a4b40cc710ddbe53faadcecb0530 /src
parentd4985dd72be29f6b472d2f7514b88fa20fb061b6 (diff)
downloadcowboy-8f818d79dfe22af8a4a557c1e8676463224b9c22.tar.gz
cowboy-8f818d79dfe22af8a4a557c1e8676463224b9c22.tar.bz2
cowboy-8f818d79dfe22af8a4a557c1e8676463224b9c22.zip
Add an accept timeout for code reloading.
Thought it was already there, but I guess not. Anyway it's here now so everything is back to normal. ;)
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_acceptor.erl4
-rw-r--r--src/cowboy_ssl_transport.erl16
-rw-r--r--src/cowboy_tcp_transport.erl8
3 files changed, 15 insertions, 13 deletions
diff --git a/src/cowboy_acceptor.erl b/src/cowboy_acceptor.erl
index 0dbd9b0..ac89874 100644
--- a/src/cowboy_acceptor.erl
+++ b/src/cowboy_acceptor.erl
@@ -32,11 +32,13 @@ start_link(LSocket, Transport, Protocol, Opts, ReqsSup) ->
-spec acceptor(LSocket::socket(), Transport::module(),
Protocol::module(), Opts::term(), ReqsSup::pid()) -> no_return().
acceptor(LSocket, Transport, Protocol, Opts, ReqsSup) ->
- case Transport:accept(LSocket) of
+ case Transport:accept(LSocket, 2000) of
{ok, CSocket} ->
{ok, Pid} = supervisor:start_child(ReqsSup,
[CSocket, Transport, Protocol, Opts]),
Transport:controlling_process(CSocket, Pid);
+ {error, timeout} ->
+ ignore;
{error, _Reason} ->
%% @todo Probably do something here. If the socket was closed,
%% we may want to try and listen again on the port?
diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl
index f5c23e3..1122bfb 100644
--- a/src/cowboy_ssl_transport.erl
+++ b/src/cowboy_ssl_transport.erl
@@ -13,7 +13,7 @@
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-module(cowboy_ssl_transport).
--export([name/0, messages/0, listen/1, accept/1, recv/3, send/2, setopts/2,
+-export([name/0, messages/0, listen/1, accept/2, recv/3, send/2, setopts/2,
controlling_process/2, peername/1, close/1]). %% API.
-include("include/types.hrl").
@@ -38,12 +38,12 @@ listen(Opts) ->
{packet, raw}, {reuseaddr, true},
{certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]).
--spec accept(LSocket::sslsocket())
+-spec accept(LSocket::sslsocket(), Timeout::timeout())
-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
-accept(LSocket) ->
- case ssl:transport_accept(LSocket) of
+accept(LSocket, Timeout) ->
+ case ssl:transport_accept(LSocket, Timeout) of
{ok, CSocket} ->
- ssl_accept(CSocket);
+ ssl_accept(CSocket, Timeout);
{error, Reason} ->
{error, Reason}
end.
@@ -79,10 +79,10 @@ close(Socket) ->
%% Internal.
--spec ssl_accept(CSocket::sslsocket())
+-spec ssl_accept(CSocket::sslsocket(), Timeout::timeout())
-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
-ssl_accept(CSocket) ->
- case ssl:ssl_accept(CSocket) of
+ssl_accept(CSocket, Timeout) ->
+ case ssl:ssl_accept(CSocket, Timeout) of
ok ->
{ok, CSocket};
{error, Reason} ->
diff --git a/src/cowboy_tcp_transport.erl b/src/cowboy_tcp_transport.erl
index c1aeabc..5049b84 100644
--- a/src/cowboy_tcp_transport.erl
+++ b/src/cowboy_tcp_transport.erl
@@ -13,7 +13,7 @@
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-module(cowboy_tcp_transport).
--export([name/0, messages/0, listen/1, accept/1, recv/3, send/2, setopts/2,
+-export([name/0, messages/0, listen/1, accept/2, recv/3, send/2, setopts/2,
controlling_process/2, peername/1, close/1]). %% API.
-include("include/types.hrl").
@@ -33,10 +33,10 @@ listen(Opts) ->
gen_tcp:listen(Port, [binary, {active, false},
{packet, raw}, {reuseaddr, true}]).
--spec accept(LSocket::socket())
+-spec accept(LSocket::socket(), Timeout::timeout())
-> {ok, Socket::socket()} | {error, Reason::closed | timeout | posix()}.
-accept(LSocket) ->
- gen_tcp:accept(LSocket).
+accept(LSocket, Timeout) ->
+ gen_tcp:accept(LSocket, Timeout).
-spec recv(Socket::socket(), Length::integer(), Timeout::timeout())
-> {ok, Packet::term()} | {error, Reason::closed | posix()}.