aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_clear.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-09-14 15:34:37 +0200
committerLoïc Hoguin <[email protected]>2017-09-14 15:34:37 +0200
commit5027d1335d1ca39e614f56bea199aacac4d3d5a7 (patch)
tree9aa59982acf82958d9547224e46e506e966608e9 /src/cowboy_clear.erl
parent3cbf885961dc93df1b39d2de89f2a871402acbd5 (diff)
downloadcowboy-5027d1335d1ca39e614f56bea199aacac4d3d5a7.tar.gz
cowboy-5027d1335d1ca39e614f56bea199aacac4d3d5a7.tar.bz2
cowboy-5027d1335d1ca39e614f56bea199aacac4d3d5a7.zip
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.
Diffstat (limited to 'src/cowboy_clear.erl')
-rw-r--r--src/cowboy_clear.erl20
1 files changed, 5 insertions, 15 deletions
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).