aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2023-12-21 15:26:21 +0100
committerLoïc Hoguin <[email protected]>2023-12-21 15:38:51 +0100
commitffbcdf534c7bdcca545e245443cc48056bcd6944 (patch)
tree80422c5a4fac74ddb5c9201a4f4eedaa688c726d
parent5ef64557b5b4c92224d68d1445cdb7846a76a0be (diff)
downloadcowboy-ffbcdf534c7bdcca545e245443cc48056bcd6944.tar.gz
cowboy-ffbcdf534c7bdcca545e245443cc48056bcd6944.tar.bz2
cowboy-ffbcdf534c7bdcca545e245443cc48056bcd6944.zip
Don't update an HTTP/2 stream's window if stream stopped
-rw-r--r--src/cowboy_http2.erl15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index 59fd76b..cd68545 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -833,14 +833,21 @@ commands(State=#state{opts=Opts}, StreamID, [Log={log, _, _, _}|Tail]) ->
update_window(State0=#state{socket=Socket, transport=Transport,
http2_machine=HTTP2Machine0, flow=Flow, streams=Streams}, StreamID) ->
- #{StreamID := #stream{flow=StreamFlow}} = Streams,
{Data1, HTTP2Machine2} = case cow_http2_machine:ensure_window(Flow, HTTP2Machine0) of
ok -> {<<>>, HTTP2Machine0};
{ok, Increment1, HTTP2Machine1} -> {cow_http2:window_update(Increment1), HTTP2Machine1}
end,
- {Data2, HTTP2Machine} = case cow_http2_machine:ensure_window(StreamID, StreamFlow, HTTP2Machine2) of
- ok -> {<<>>, HTTP2Machine2};
- {ok, Increment2, HTTP2Machine3} -> {cow_http2:window_update(StreamID, Increment2), HTTP2Machine3}
+ {Data2, HTTP2Machine} = case Streams of
+ #{StreamID := #stream{flow=StreamFlow}} ->
+ case cow_http2_machine:ensure_window(StreamID, StreamFlow, HTTP2Machine2) of
+ ok ->
+ {<<>>, HTTP2Machine2};
+ {ok, Increment2, HTTP2Machine3} ->
+ {cow_http2:window_update(StreamID, Increment2), HTTP2Machine3}
+ end;
+ _ ->
+ %% Don't update the stream's window if it stopped.
+ {<<>>, HTTP2Machine2}
end,
State = State0#state{http2_machine=HTTP2Machine},
case {Data1, Data2} of