aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-04 20:15:23 +0200
committerLoïc Hoguin <[email protected]>2020-04-04 20:15:23 +0200
commit4ab69f402e38f77b7612ecf30f3defe9c6a76d24 (patch)
tree9c77adfcf19e89ac188d4bfc8158e0c591719051
parent4274f077a656242659112f01c25cece32ddcb487 (diff)
downloadcowboy-4ab69f402e38f77b7612ecf30f3defe9c6a76d24.tar.gz
cowboy-4ab69f402e38f77b7612ecf30f3defe9c6a76d24.tar.bz2
cowboy-4ab69f402e38f77b7612ecf30f3defe9c6a76d24.zip
Fix active mode and flow control during pipelining
We could get stuck in passive mode under certain conditions (fast and non-busy machine and perhaps other environment factors).
-rw-r--r--src/cowboy_http.erl13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 13d07b7..e7a28da 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -1307,14 +1307,21 @@ stream_terminate(State0=#state{opts=Opts, in_streamid=InStreamID, in_state=InSta
stream_next(State)
end.
-stream_next(State=#state{out_streamid=OutStreamID, streams=Streams}) ->
+stream_next(State0=#state{opts=Opts, active=Active, out_streamid=OutStreamID, streams=Streams}) ->
NextOutStreamID = OutStreamID + 1,
case lists:keyfind(NextOutStreamID, #stream.id, Streams) of
false ->
- State#state{out_streamid=NextOutStreamID, out_state=wait};
+ State0#state{out_streamid=NextOutStreamID, out_state=wait};
#stream{queue=Commands} ->
+ State = case Active of
+ true -> State0;
+ false -> active(State0)
+ end,
%% @todo Remove queue from the stream.
- commands(State#state{out_streamid=NextOutStreamID, out_state=wait},
+ %% We set the flow to the initial flow size even though
+ %% we might have sent some data through already due to pipelining.
+ Flow = maps:get(initial_stream_flow_size, Opts, 65535),
+ commands(State#state{flow=Flow, out_streamid=NextOutStreamID, out_state=wait},
NextOutStreamID, Commands)
end.