mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
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).
This commit is contained in:
parent
4274f077a6
commit
4ab69f402e
1 changed files with 10 additions and 3 deletions
|
@ -1307,14 +1307,21 @@ stream_terminate(State0=#state{opts=Opts, in_streamid=InStreamID, in_state=InSta
|
||||||
stream_next(State)
|
stream_next(State)
|
||||||
end.
|
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,
|
NextOutStreamID = OutStreamID + 1,
|
||||||
case lists:keyfind(NextOutStreamID, #stream.id, Streams) of
|
case lists:keyfind(NextOutStreamID, #stream.id, Streams) of
|
||||||
false ->
|
false ->
|
||||||
State#state{out_streamid=NextOutStreamID, out_state=wait};
|
State0#state{out_streamid=NextOutStreamID, out_state=wait};
|
||||||
#stream{queue=Commands} ->
|
#stream{queue=Commands} ->
|
||||||
|
State = case Active of
|
||||||
|
true -> State0;
|
||||||
|
false -> active(State0)
|
||||||
|
end,
|
||||||
%% @todo Remove queue from the stream.
|
%% @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)
|
NextOutStreamID, Commands)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue