From 0a1fb6cc317f7fd15214d53c5f03b8e29506f413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 1 Oct 2019 21:13:31 +0200 Subject: Add cow_http2_machine:get_connection_local_buffer_size/1 The function can be used to restrict how big all the buffers of a single connection can get. --- src/cow_http2_machine.erl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl index de2346d..5c9e66e 100644 --- a/src/cow_http2_machine.erl +++ b/src/cow_http2_machine.erl @@ -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]). @@ -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(). -- cgit v1.2.3