mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Fix concurrent body streaming getting stuck with HTTP/2
This commit is contained in:
parent
5aac00d60c
commit
03d306e6d1
2 changed files with 16 additions and 2 deletions
|
@ -235,9 +235,13 @@ info(StreamID, Data0={data, Pid, _, _}, State0=#state{stream_body_status=Status}
|
||||||
end,
|
end,
|
||||||
Data = erlang:delete_element(2, Data0),
|
Data = erlang:delete_element(2, Data0),
|
||||||
do_info(StreamID, Data, [Data], State);
|
do_info(StreamID, Data, [Data], State);
|
||||||
info(StreamID, Alarm={alarm, Name, on}, State)
|
info(StreamID, Alarm={alarm, Name, on}, State0=#state{stream_body_status=Status})
|
||||||
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
|
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
|
||||||
do_info(StreamID, Alarm, [], State#state{stream_body_status=blocking});
|
State = case Status of
|
||||||
|
normal -> State0#state{stream_body_status=blocking};
|
||||||
|
_ -> State0
|
||||||
|
end,
|
||||||
|
do_info(StreamID, Alarm, [], State);
|
||||||
info(StreamID, Alarm={alarm, Name, off}, State=#state{stream_body_pid=Pid, stream_body_status=Status})
|
info(StreamID, Alarm={alarm, Name, off}, State=#state{stream_body_pid=Pid, stream_body_status=Status})
|
||||||
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
|
when Name =:= connection_buffer_full; Name =:= stream_buffer_full ->
|
||||||
_ = case Status of
|
_ = case Status of
|
||||||
|
|
|
@ -1012,6 +1012,16 @@ stream_body_content_length_nofin_error(Config) ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
stream_body_concurrent(Config) ->
|
||||||
|
ConnPid = gun_open(Config),
|
||||||
|
Ref1 = gun:get(ConnPid, "/resp/stream_body/loop", [{<<"accept-encoding">>, <<"gzip">>}]),
|
||||||
|
Ref2 = gun:get(ConnPid, "/resp/stream_body/loop", [{<<"accept-encoding">>, <<"gzip">>}]),
|
||||||
|
{response, nofin, 200, _} = gun:await(ConnPid, Ref1, infinity),
|
||||||
|
{ok, _} = gun:await_body(ConnPid, Ref1, infinity),
|
||||||
|
{response, nofin, 200, _} = gun:await(ConnPid, Ref2, infinity),
|
||||||
|
{ok, _} = gun:await_body(ConnPid, Ref2, infinity),
|
||||||
|
gun:close(ConnPid).
|
||||||
|
|
||||||
%% @todo Crash when calling stream_body after the fin flag has been set.
|
%% @todo Crash when calling stream_body after the fin flag has been set.
|
||||||
%% @todo Crash when calling stream_body after calling reply.
|
%% @todo Crash when calling stream_body after calling reply.
|
||||||
%% @todo Crash when calling stream_body before calling stream_reply.
|
%% @todo Crash when calling stream_body before calling stream_reply.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue