mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Use cal_increasing_window to calculate new window
This commit is contained in:
parent
5b4e78fac4
commit
3fea604ed8
2 changed files with 20 additions and 4 deletions
2
Makefile
2
Makefile
|
@ -15,7 +15,7 @@ CT_OPTS += -ct_hooks cowboy_ct_hook [] # -boot start_sasl
|
||||||
LOCAL_DEPS = crypto
|
LOCAL_DEPS = crypto
|
||||||
|
|
||||||
DEPS = cowlib ranch
|
DEPS = cowlib ranch
|
||||||
dep_cowlib = git https://github.com/ninenines/cowlib 2.7.3
|
dep_cowlib = git https://github.com/elixir-grpc/cowlib add-new-update-window
|
||||||
dep_ranch = git https://github.com/ninenines/ranch 1.7.1
|
dep_ranch = git https://github.com/ninenines/ranch 1.7.1
|
||||||
|
|
||||||
DOC_DEPS = asciideck
|
DOC_DEPS = asciideck
|
||||||
|
|
|
@ -311,7 +311,7 @@ data_frame(State=#state{opts=Opts, streams=Streams}, StreamID, IsFin, Data) ->
|
||||||
lingering_data_frame(State=#state{socket=Socket, transport=Transport,
|
lingering_data_frame(State=#state{socket=Socket, transport=Transport,
|
||||||
http2_machine=HTTP2Machine0}, DataLen) ->
|
http2_machine=HTTP2Machine0}, DataLen) ->
|
||||||
Transport:send(Socket, cow_http2:window_update(DataLen)),
|
Transport:send(Socket, cow_http2:window_update(DataLen)),
|
||||||
HTTP2Machine1 = cow_http2_machine:update_window(DataLen, HTTP2Machine0),
|
HTTP2Machine1 = cal_and_update_window(DataLen, HTTP2Machine0),
|
||||||
State#state{http2_machine=HTTP2Machine1}.
|
State#state{http2_machine=HTTP2Machine1}.
|
||||||
|
|
||||||
headers_frame(State, StreamID, IsFin, Headers,
|
headers_frame(State, StreamID, IsFin, Headers,
|
||||||
|
@ -586,8 +586,8 @@ commands(State=#state{socket=Socket, transport=Transport, http2_machine=HTTP2Mac
|
||||||
cow_http2:window_update(Size),
|
cow_http2:window_update(Size),
|
||||||
cow_http2:window_update(StreamID, Size)
|
cow_http2:window_update(StreamID, Size)
|
||||||
]),
|
]),
|
||||||
HTTP2Machine1 = cow_http2_machine:update_window(Size, HTTP2Machine0),
|
HTTP2Machine1 = cal_and_update_window(Size, HTTP2Machine0),
|
||||||
HTTP2Machine = cow_http2_machine:update_window(StreamID, Size, HTTP2Machine1),
|
HTTP2Machine = cal_and_update_window(StreamID, Size, HTTP2Machine1),
|
||||||
commands(State#state{http2_machine=HTTP2Machine}, StreamID, Tail);
|
commands(State#state{http2_machine=HTTP2Machine}, StreamID, Tail);
|
||||||
%% Supervise a child process.
|
%% Supervise a child process.
|
||||||
commands(State=#state{children=Children}, StreamID, [{spawn, Pid, Shutdown}|Tail]) ->
|
commands(State=#state{children=Children}, StreamID, [{spawn, Pid, Shutdown}|Tail]) ->
|
||||||
|
@ -666,6 +666,22 @@ maybe_send_data(State=#state{http2_machine=HTTP2Machine0}, StreamID, IsFin, Data
|
||||||
send_data(State#state{http2_machine=HTTP2Machine}, SendData)
|
send_data(State#state{http2_machine=HTTP2Machine}, SendData)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
cal_and_update_window(DataLen, HTTP2Machine) ->
|
||||||
|
case cow_http2_machine:cal_increasing_window(DataLen, HTTP2Machine) of
|
||||||
|
0 ->
|
||||||
|
HTTP2Machine;
|
||||||
|
NewSize ->
|
||||||
|
cow_http2_machine:update_window(NewSize, HTTP2Machine)
|
||||||
|
end.
|
||||||
|
|
||||||
|
cal_and_update_window(StreamID, _DataLen, HTTP2Machine) ->
|
||||||
|
case cow_http2_machine:cal_increasing_window(StreamID, HTTP2Machine) of
|
||||||
|
0 ->
|
||||||
|
HTTP2Machine;
|
||||||
|
NewSize ->
|
||||||
|
cow_http2_machine:update_window(StreamID, NewSize, HTTP2Machine)
|
||||||
|
end.
|
||||||
|
|
||||||
send_data(State, []) ->
|
send_data(State, []) ->
|
||||||
State;
|
State;
|
||||||
send_data(State0, [{StreamID, IsFin, SendData}|Tail]) ->
|
send_data(State0, [{StreamID, IsFin, SendData}|Tail]) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue