From 48f417ac8f3d00039e2dc674e312d982336dcfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 2 Sep 2019 14:48:28 +0200 Subject: Fix and optimize sending of WINDOW_UPDATE frames For long-running connections it was possible for the connection window to become larger than allowed by the protocol because the window increases claimed by stream handlers were never reclaimed even if no data was consumed. The new code applies heuristics to fix this and reduce the number of WINDOW_UPDATE frames that are sent. It includes six new options to control that behavior: margin, max and threshold for both the connection and stream windows. The margin is some extra space added on top of the requested read size. The max is the maximum window size at any given time. The threshold is a minimum window size that must be reached before we even consider sending more WINDOW_UPDATE frames. We also avoid sending WINDOW_UPDATE frames when there is already enough space in the window, or when the read size is 0. Cowlib is set to master until a new tag is done. --- test/rfc8441_SUITE.erl | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test/rfc8441_SUITE.erl') diff --git a/test/rfc8441_SUITE.erl b/test/rfc8441_SUITE.erl index 3105ddb..245658f 100644 --- a/test/rfc8441_SUITE.erl +++ b/test/rfc8441_SUITE.erl @@ -389,15 +389,10 @@ accept_handshake_when_enabled(Config) -> {RespHeaders, _} = cow_hpack:decode(RespHeadersBlock), {_, <<"200">>} = lists:keyfind(<<":status">>, 1, RespHeaders), %% Masked text hello echoed back clear by the server. - %% - %% We receive WINDOW_UPDATE frames before the actual data - %% due to flow control updates every time a data frame is received. Mask = 16#37fa213d, MaskedHello = ws_SUITE:do_mask(<<"Hello">>, Mask, <<>>), ok = gen_tcp:send(Socket, cow_http2:data(1, nofin, <<1:1, 0:3, 1:4, 1:1, 5:7, Mask:32, MaskedHello/binary>>)), - {ok, <<4:24, 8:8, _:72>>} = gen_tcp:recv(Socket, 13, 1000), - {ok, <<4:24, 8:8, _:72>>} = gen_tcp:recv(Socket, 13, 1000), {ok, <>} = gen_tcp:recv(Socket, 9, 1000), {ok, <<1:1, 0:3, 1:4, 0:1, 5:7, "Hello">>} = gen_tcp:recv(Socket, Len2, 1000), ok. -- cgit v1.2.3