aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_listener_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_listener_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_listener_sup.erl')
-rw-r--r--src/cowboy_listener_sup.erl29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/cowboy_listener_sup.erl b/src/cowboy_listener_sup.erl
index 85b17ef..e77c237 100644
--- a/src/cowboy_listener_sup.erl
+++ b/src/cowboy_listener_sup.erl
@@ -24,32 +24,19 @@
TransOpts::term(), Protocol::module(), ProtoOpts::term())
-> {ok, Pid::pid()}.
start_link(NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->
- case Transport:listen(TransOpts) of
- {ok, LSocket} ->
- start_sup(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts);
- {error, Reason} ->
- {error, Reason}
- end.
-
-%% supervisor.
-
-%% @todo These specs should be improved.
--spec init([]) -> term().
-init([]) ->
- {ok, {{one_for_one, 0, 1}, []}}.
-
-%% Internal.
-
--spec start_sup(NbAcceptors::non_neg_integer(), Transport::module(),
- TransOpts::term(), Protocol::module(), ProtoOpts::term())
- -> {ok, Pid::pid()}.
-start_sup(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts) ->
{ok, SupPid} = supervisor:start_link(?MODULE, []),
{ok, ReqsPid} = supervisor:start_child(SupPid,
{cowboy_requests_sup, {cowboy_requests_sup, start_link, []},
permanent, 5000, supervisor, [cowboy_requests_sup]}),
{ok, _PoolPid} = supervisor:start_child(SupPid,
{cowboy_acceptors_sup, {cowboy_acceptors_sup, start_link, [
- LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid
+ NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid
]}, permanent, 5000, supervisor, [cowboy_acceptors_sup]}),
{ok, SupPid}.
+
+%% supervisor.
+
+%% @todo These specs should be improved.
+-spec init([]) -> term().
+init([]) ->
+ {ok, {{one_for_one, 0, 1}, []}}.