From 5027d1335d1ca39e614f56bea199aacac4d3d5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 14 Sep 2017 15:34:37 +0200 Subject: Rework the proc_lib_hack It is completely removed for connection processes, because assuming Cowboy is written properly this should bring us nothing anymore in 2.0. It is reworked for request processes, there we want to always propagate the stacktrace (including for exits) because we will print a report to help with debugging and proc_lib doesn't propagate it for exits. At the same time the initial callback for connection and request processes has been changed to connection_process and request_process, which should help with identifying processes when inspecting. --- src/cowboy_clear.erl | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/cowboy_clear.erl') diff --git a/src/cowboy_clear.erl b/src/cowboy_clear.erl index 7ff5d8b..522ede3 100644 --- a/src/cowboy_clear.erl +++ b/src/cowboy_clear.erl @@ -16,26 +16,16 @@ -behavior(ranch_protocol). -export([start_link/4]). --export([proc_lib_hack/5]). +-export([connection_process/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, proc_lib_hack, [self(), Ref, Socket, Transport, Opts]), + Pid = proc_lib:spawn_link(?MODULE, connection_process, + [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) -> +-spec connection_process(pid(), ranch:ref(), inet:socket(), module(), cowboy:opts()) -> ok. +connection_process(Parent, Ref, Socket, Transport, Opts) -> ok = ranch:accept_ack(Ref), init(Parent, Ref, Socket, Transport, Opts, cowboy_http). -- cgit v1.2.3