aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_acceptors_sup.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-04-03 01:44:52 +0200
committerLoïc Hoguin <[email protected]>2011-04-03 01:44:52 +0200
commitccf7a242b4899c70595ff8fa9e531cf3bea6e0e1 (patch)
tree67a237b0cf41a42de3af871094fef57baf85dd67 /src/cowboy_acceptors_sup.erl
parent718baffa3c8cc033e06d824a7f47bc65c9b5cd74 (diff)
downloadcowboy-ccf7a242b4899c70595ff8fa9e531cf3bea6e0e1.tar.gz
cowboy-ccf7a242b4899c70595ff8fa9e531cf3bea6e0e1.tar.bz2
cowboy-ccf7a242b4899c70595ff8fa9e531cf3bea6e0e1.zip
Ensure the listening socket gets closed with the listener supervisor.
Moved the Transport:listen call to cowboy_acceptors_sup. This make it depend on a child of cowboy_listener_sup instead of cowboy_sup, which isn't getting shut down when calling cowboy:stop_listener/1 and thus didn't close the listening socket.
Diffstat (limited to 'src/cowboy_acceptors_sup.erl')
-rw-r--r--src/cowboy_acceptors_sup.erl9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cowboy_acceptors_sup.erl b/src/cowboy_acceptors_sup.erl
index c5e7db4..66ac4a9 100644
--- a/src/cowboy_acceptors_sup.erl
+++ b/src/cowboy_acceptors_sup.erl
@@ -25,14 +25,15 @@
-spec start_link(NbAcceptors::non_neg_integer(), Transport::module(),
TransOpts::term(), Protocol::module(), ProtoOpts::term(), ReqsPid::pid())
-> {ok, Pid::pid()}.
-start_link(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid) ->
- supervisor:start_link(?MODULE, [LSocket, NbAcceptors,
- Transport, Protocol, ProtoOpts, ReqsPid]).
+start_link(NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid) ->
+ supervisor:start_link(?MODULE, [NbAcceptors,
+ Transport, TransOpts, Protocol, ProtoOpts, ReqsPid]).
%% supervisor.
-spec init(list(term())) -> term(). %% @todo These specs should be improved.
-init([LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid]) ->
+init([NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid]) ->
+ {ok, LSocket} = Transport:listen(TransOpts),
Procs = [{{acceptor, self(), N}, {cowboy_acceptor, start_link, [
LSocket, Transport, Protocol, ProtoOpts, ReqsPid
]}, permanent, brutal_kill, worker, dynamic}