aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_clear.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-06-13 16:00:17 +0200
committerLoïc Hoguin <[email protected]>2016-06-13 16:00:17 +0200
commitb82bb92f7e6cf751ec74fc8aec0bfea84bfc5415 (patch)
tree5a77cc01846d9c342bf3a6e8098bb401591f178d /src/cowboy_clear.erl
parent88227898edd26a823d0942fc7226adb61a20cb5d (diff)
downloadcowboy-b82bb92f7e6cf751ec74fc8aec0bfea84bfc5415.tar.gz
cowboy-b82bb92f7e6cf751ec74fc8aec0bfea84bfc5415.tar.bz2
cowboy-b82bb92f7e6cf751ec74fc8aec0bfea84bfc5415.zip
Fix streaming HTTP/2 responses
Error reporting for connection processes has been improved, using a similar proc_lib hack as was done for the stream processes.
Diffstat (limited to 'src/cowboy_clear.erl')
-rw-r--r--src/cowboy_clear.erl15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cowboy_clear.erl b/src/cowboy_clear.erl
index cc6078e..713e11e 100644
--- a/src/cowboy_clear.erl
+++ b/src/cowboy_clear.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),