diff options
Diffstat (limited to 'src/cowboy_tls.erl')
-rw-r--r-- | src/cowboy_tls.erl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cowboy_tls.erl b/src/cowboy_tls.erl index 375b005..c9999e3 100644 --- a/src/cowboy_tls.erl +++ b/src/cowboy_tls.erl @@ -16,13 +16,24 @@ -behavior(ranch_protocol). -export([start_link/4]). --export([init/5]). +-export([proc_lib_hack/5]). -spec start_link(ranch:ref(), inet:socket(), module(), cowboy:opts()) -> {ok, pid()}. start_link(Ref, Socket, Transport, Opts) -> - Pid = proc_lib:spawn_link(?MODULE, init, [self(), Ref, Socket, Transport, Opts]), + Pid = proc_lib:spawn_link(?MODULE, proc_lib_hack, [self(), Ref, Socket, Transport, Opts]), {ok, Pid}. +-spec proc_lib_hack(pid(), ranch:ref(), inet:socket(), module(), cowboy:opts()) -> ok. +proc_lib_hack(Parent, Ref, Socket, Transport, Opts) -> + try + init(Parent, Ref, Socket, Transport, Opts) + catch + _:normal -> exit(normal); + _:shutdown -> exit(shutdown); + _:Reason = {shutdown, _} -> exit(Reason); + _:Reason -> exit({Reason, erlang:get_stacktrace()}) + end. + -spec init(pid(), ranch:ref(), inet:socket(), module(), cowboy:opts()) -> ok. init(Parent, Ref, Socket, Transport, Opts) -> ok = ranch:accept_ack(Ref), |