aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http2.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-09-27 14:17:27 +0200
committerLoïc Hoguin <[email protected]>2017-09-27 14:17:27 +0200
commit11ae407eed92002339fc6cde8acd767e7be953c1 (patch)
treee375c9fa324cd4b9fa988e9a83978064374be54c /src/cowboy_http2.erl
parentd47e22edaa1a876081c07bf49c79587c3c2d21d5 (diff)
downloadcowboy-11ae407eed92002339fc6cde8acd767e7be953c1.tar.gz
cowboy-11ae407eed92002339fc6cde8acd767e7be953c1.tar.bz2
cowboy-11ae407eed92002339fc6cde8acd767e7be953c1.zip
Ensure the behavior on stream handler crash is consistent
Also corrects the lack of error response when HTTP/1.1 is used.
Diffstat (limited to 'src/cowboy_http2.erl')
-rw-r--r--src/cowboy_http2.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index 8c6a0d3..dbd67cb 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -305,7 +305,7 @@ frame(State0=#state{remote_window=ConnWindow, streams=Streams},
[StreamID, IsFin, Data, StreamState0],
Class, Exception, erlang:get_stacktrace()),
stream_reset(State, StreamID, {internal_error, {Class, Exception},
- 'Exception occurred in cowboy_stream:data/4.'})
+ 'Unhandled exception in cowboy_stream:data/4.'})
end;
#stream{remote=fin} ->
stream_reset(State, StreamID, {stream_error, stream_closed,
@@ -444,7 +444,7 @@ info(State=#state{streams=Streams}, StreamID, Msg) ->
[StreamID, Msg, StreamState0],
Class, Exception, erlang:get_stacktrace()),
stream_reset(State, StreamID, {internal_error, {Class, Exception},
- 'Exception occurred in cowboy_stream:info/3.'})
+ 'Unhandled exception in cowboy_stream:info/3.'})
end;
false ->
error_logger:error_msg("Received message ~p for unknown stream ~p.", [Msg, StreamID]),
@@ -759,7 +759,7 @@ stream_handler_init(State=#state{opts=Opts,
[StreamID, Req, Opts],
Class, Exception, erlang:get_stacktrace()),
stream_reset(State, StreamID, {internal_error, {Class, Exception},
- 'Exception occurred in cowboy_stream:init/3.'})
+ 'Unhandled exception in cowboy_stream:init/3.'})
end.
%% @todo We might need to keep track of which stream has been reset so we don't send lots of them.
@@ -801,9 +801,11 @@ stream_terminate(State=#state{socket=Socket, transport=Transport,
stream_call_terminate(StreamID, Reason, StreamState),
Children = cowboy_children:shutdown(Children0, StreamID),
State#state{streams=Streams, children=Children};
+ %% The stream doesn't exist. This can occur for various reasons.
+ %% It can happen before the stream has been created, or because
+ %% the cowboy_stream:init call failed, in which case doing nothing
+ %% is correct.
false ->
- %% @todo Unknown stream. Not sure what to do here. Check again once all
- %% terminate calls have been written.
State
end.