Skip to content

Commit

Permalink
Add cow_http2_machine:get_connection_local_buffer_size/1
Browse files Browse the repository at this point in the history
The function can be used to restrict how big all the
buffers of a single connection can get.
  • Loading branch information
essen committed Oct 1, 2019
1 parent 7d70e77 commit 0a1fb6c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cow_http2_machine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
-export([update_window/2]).
-export([update_window/3]).
-export([reset_stream/2]).
-export([get_connection_local_buffer_size/1]).
-export([get_local_setting/2]).
-export([get_last_streamid/1]).
-export([get_stream_local_buffer_size/2]).
Expand Down Expand Up @@ -1408,6 +1409,14 @@ reset_stream(StreamID, State=#http2_machine{streams=Streams0}) ->
{error, not_found}
end.

%% Retrieve the buffer size for all streams.

-spec get_connection_local_buffer_size(http2_machine()) -> non_neg_integer().
get_connection_local_buffer_size(#http2_machine{streams=Streams}) ->
lists:foldl(fun(#stream{local_buffer_size=Size}, Acc) ->
Acc + Size
end, 0, Streams).

%% Retrieve a setting value, or its default value if not set.

-spec get_local_setting(atom(), http2_machine()) -> atom() | integer().
Expand Down

0 comments on commit 0a1fb6c

Please sign in to comment.