diff options
author | Andrew Thompson <[email protected]> | 2012-09-24 13:32:21 -0400 |
---|---|---|
committer | Andrew Thompson <[email protected]> | 2012-12-20 12:50:22 -0500 |
commit | 036fbd53189f0a43bd8348e517a17da0f00de980 (patch) | |
tree | 721b2159b79869459af39398f95e1fc38c9397c9 /src/ranch.erl | |
parent | f26401af19bddd74ddd1755041372c737a995b01 (diff) | |
download | ranch-036fbd53189f0a43bd8348e517a17da0f00de980.tar.gz ranch-036fbd53189f0a43bd8348e517a17da0f00de980.tar.bz2 ranch-036fbd53189f0a43bd8348e517a17da0f00de980.zip |
Add {socket, Socket} transport option, for accepting on existing sockets
Diffstat (limited to 'src/ranch.erl')
-rw-r--r-- | src/ranch.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ranch.erl b/src/ranch.erl index 6d1d5e8..0924ee7 100644 --- a/src/ranch.erl +++ b/src/ranch.erl @@ -59,8 +59,21 @@ start_listener(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) false -> {error, badarg}; true -> - supervisor:start_child(ranch_sup, child_spec(Ref, NbAcceptors, - Transport, TransOpts, Protocol, ProtoOpts)) + Res = supervisor:start_child(ranch_sup, child_spec(Ref, NbAcceptors, + Transport, TransOpts, Protocol, ProtoOpts)), + case proplists:get_value(socket, TransOpts) of + undefined -> + ok; + Socket -> + %% change the controlling process so the caller dying doesn't + %% close the port + ListenerPid = ranch_server:lookup_listener(Ref), + %%% Note: the catch is here because SSL crashes when you change + %%% the controlling process of a listen socket because of a bug. + %%% The bug will be fixed in R16. + catch(Transport:controlling_process(Socket, ListenerPid)) + end, + Res end. %% @doc Stop a listener identified by <em>Ref</em>. |