aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-09-25 12:55:30 +0200
committerLoïc Hoguin <[email protected]>2017-09-25 12:55:30 +0200
commitea80e7a3097c985befa60278dde1c4cedc145fb6 (patch)
tree6c4697fe327e66d3395ec924e0a0a9747d54d0c3 /src
parentc09b10190baaae37f4de8bc1732d79acca62b53d (diff)
downloadcowboy-ea80e7a3097c985befa60278dde1c4cedc145fb6.tar.gz
cowboy-ea80e7a3097c985befa60278dde1c4cedc145fb6.tar.bz2
cowboy-ea80e7a3097c985befa60278dde1c4cedc145fb6.zip
Avoid some crashes when HTTP/2 streams flush their response
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http2.erl7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index a446222..fb6bf41 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -291,6 +291,10 @@ frame(State0=#state{remote_window=ConnWindow, streams=Streams},
DataLen = byte_size(Data),
State = State0#state{remote_window=ConnWindow - DataLen},
case lists:keyfind(StreamID, #stream.id, Streams) of
+ Stream = #stream{state=flush, remote=nofin, remote_window=StreamWindow} ->
+ %% @todo We need to cancel streams that we don't want to receive
+ %% the full body from after we finish flushing the response.
+ after_commands(State, Stream#stream{remote=IsFin, remote_window=StreamWindow - DataLen});
Stream = #stream{state=StreamState0, remote=nofin, remote_window=StreamWindow} ->
try cowboy_stream:data(StreamID, IsFin, Data, StreamState0) of
{Commands, StreamState} ->
@@ -428,6 +432,9 @@ down(State=#state{children=Children0}, Pid, Msg) ->
info(State=#state{streams=Streams}, StreamID, Msg) ->
case lists:keyfind(StreamID, #stream.id, Streams) of
+ #stream{state=flush} ->
+ error_logger:error_msg("Received message ~p for terminated stream ~p.", [Msg, StreamID]),
+ State;
Stream = #stream{state=StreamState0} ->
try cowboy_stream:info(StreamID, Msg, StreamState0) of
{Commands, StreamState} ->